SimpleEssential/src/main/java/cn/citycraft/SimpleEssential/command/CommandSudo.java

50 lines
1.3 KiB
Java

/**
*
*/
package cn.citycraft.SimpleEssential.command;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import cn.citycraft.PluginHelper.commands.BaseCommand;
import cn.citycraft.PluginHelper.utils.StringUtil;
import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.config.I18n;
/**
* 传送到顶部命令
*
* @author 蒋天蓓
* 2015年8月12日下午2:04:05
*
*/
public class CommandSudo extends BaseCommand {
SimpleEssential plugin;
/**
* @param name
*/
public CommandSudo(final SimpleEssential main) {
super("sudo", "sesudo");
this.plugin = main;
setMinimumArguments(2);
setPossibleArguments("<玩家> <命令>");
setDescription("强制玩家执行命令");
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final Player p = Bukkit.getPlayer(args[0]);
if (p == null) {
sender.sendMessage(I18n.p("Base.offline", args[0]));
return;
}
final String cmd = StringUtil.consolidateStrings(args, 1);
p.performCommand(cmd);
sender.sendMessage(I18n.p("Sudo", args[0], cmd));
}
}