commands.yml vairables HELP!

Discussion in 'Spigot Help' started by tarpers, May 27, 2015.

  1. In the commands.yml can you execute a command for a player so if say the player typed /654234 it executes /give {player} diamond 1? Most plugins have the {player} variable but as this is spigot not a plugin It isn't the same and does not work. Please help ASAP. Thanks Guys!
     
  2. I do not believe thats possible because you'd have to make it so the player executes /654234 then have console execute /give {player} diamond 1. There might be a plugin that does that but i'm pretty sure the commands.yml you cannot do that unfortunately.
     
  3. The sudo command in essentials allows you to run a command as another user.
     
  4. @olivervscreeper yea but then for the sudo command to make the player run the command that means the player would have to have access to /give which i'm pretty sure @tarpers does not want
     
  5. That won't work because if /654234 is executed by a player, an aliases in commands.yml won't make it executed by console. I threw this plugin together for you. Just install it and it'll work fine. Only permission is "givediamond.cmd" without the quotes. @tarpers
    http://www.mediafire.com/download/g25jwtlwleqhc46/GiveDiamond.jar

    Code in case you want it.
    Code (Text):
    package me.bananaman.givediamond;

    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class GiveDiamond extends JavaPlugin implements CommandExecutor {

        public void onEnable() {
            getLogger().info("GiveDiamond has been enabled!");
        }

        public void onDisable() {
            getLogger().info("GiveDiamond has been disabled!");
        }

        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            Player p = (Player) sender;
            if(cmd.getName().equalsIgnoreCase("654234")) {
                if(p instanceof Player) {
                    if(p.hasPermission("givediamond.cmd")) {
                        Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "give " + p.getName() + " diamond 1");
                    }
                }
            }
            return true;

        }

    }
     
     
  6. Use the plugin my command or sudoalias