Java Code Examples for cn.nukkit.command.CommandSender#hasPermission()

The following examples show how to use cn.nukkit.command.CommandSender#hasPermission() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.mymoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(!(sender instanceof Player)){
		sender.sendMessage(TextFormat.RED+"Please use this command in-game.");
		return true;
	}
	Player player = (Player) sender;
	sender.sendMessage(this.plugin.getMessage("mymoney-mymoney", new String[]{Double.toString(this.plugin.myMoney(player))}, player));
	return true;
}
 
Example 2
Source File: BreakCommand.java    From EssentialsNK with GNU General Public License v3.0 6 votes vote down vote up
public boolean execute(CommandSender sender, String label, String[] args) {
    if (!this.testPermission(sender)) {
        return false;
    }
    if (!this.testIngame(sender)) {
        return false;
    }
    if (args.length != 0) {
        this.sendUsage(sender);
        return false;
    }
    Player player = (Player) sender;
    Block block = player.getTargetBlock(120, new Integer[]{Block.AIR});
    if (block == null) {
        sender.sendMessage(TextFormat.RED + Language.translate("commands.break.unreachable"));
        return false;
    }
    if (block.getId() == Block.BEDROCK && !sender.hasPermission("essentialsnk.break.bedrock")) {
        sender.sendMessage(TextFormat.RED + Language.translate("commands.break.bedrock"));
        return false;
    }
    player.getLevel().setBlock(block, new BlockAir(), true, true);
    return true;
}
 
Example 3
Source File: MyMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.mymoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(!(sender instanceof Player)){
		sender.sendMessage(TextFormat.RED+"Please use this command in-game.");
		return true;
	}
	Player player = (Player) sender;
	sender.sendMessage(this.plugin.getMessage("mymoney-mymoney", new String[]{Double.toString(this.plugin.myMoney(player))}, player));
	return true;
}
 
Example 4
Source File: SetLangCommand.java    From EconomyAPI with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.setlang")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 1){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String lang = args[0];
	
	// TODO
	return true;
}
 
Example 5
Source File: SetLangCommand.java    From EconomyAPI with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.setlang")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 1){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String lang = args[0];
	
	// TODO
	return true;
}
 
Example 6
Source File: WhitelistCommand.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private boolean badPerm(CommandSender sender, String perm) {
    if (!sender.hasPermission("nukkit.command.whitelist" + perm)) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));

        return true;
    }

    return false;
}
 
Example 7
Source File: NukkitCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
    final FawePlayer plr = Fawe.imp().wrap(sender);
    if (!sender.hasPermission(this.cmd.getPerm()) && !sender.isOp()) {
        BBC.NO_PERM.send(plr, this.cmd.getPerm());
        return true;
    }
    this.cmd.executeSafe(plr, args);
    return true;
}
 
Example 8
Source File: SeeMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args){
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.seemoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 1){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	
	String player = args[0];
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	
	double money = this.plugin.myMoney(player);
	if(money < 0){
		sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
		return true;
	}
	sender.sendMessage(this.plugin.getMessage("seemoney-seemoney", new String[]{player, Double.toString(money)}, sender));
	return true;
}
 
Example 9
Source File: WhitelistCommand.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
private boolean badPerm(CommandSender sender, String perm) {
    if (!sender.hasPermission("nukkit.command.whitelist" + perm)) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));

        return true;
    }

    return false;
}
 
Example 10
Source File: GiveMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.givemoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 2){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String player = args[0];
	
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	try{
		double amount = Double.parseDouble(args[1]);
		if(amount < 0){
			sender.sendMessage(this.plugin.getMessage("givemoney-invalid-number", sender));
			return true;
		}
		
		int result = this.plugin.addMoney(player, amount);
		switch(result){
		case EconomyAPI.RET_INVALID:
			sender.sendMessage(this.plugin.getMessage("reached-max", new String[]{Double.toString(amount)}, sender));
			return true;
		case EconomyAPI.RET_NO_ACCOUNT:
			sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_SUCCESS:
			sender.sendMessage(this.plugin.getMessage("givemoney-gave-money", new String[]{Double.toString(amount), player}, sender));
			if(p instanceof Player){
				p.sendMessage(this.plugin.getMessage("givemoney-money-given", new String[]{Double.toString(amount)}, sender));
			}
			return true;
		}
	}catch(NumberFormatException e){
		sender.sendMessage(this.plugin.getMessage("givemoney-must-be-number", sender));
	}
	return true;
}
 
Example 11
Source File: PayCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args){
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.pay")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(!(sender instanceof Player)){
		sender.sendMessage(TextFormat.RED + "Please use this command in-game.");
		return true;
	}
	
	if(args.length < 2){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String player = args[0];
	
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	try{
		double amount = Double.parseDouble(args[1]);
		
		int result = this.plugin.reduceMoney((Player) sender, amount);
		switch(result){
		case EconomyAPI.RET_INVALID:
		case EconomyAPI.RET_CANCELLED:
			sender.sendMessage(this.plugin.getMessage("pay-failed", sender));
			return true;
		case EconomyAPI.RET_NO_ACCOUNT:
			sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_SUCCESS:
			this.plugin.addMoney(player, amount, true);
			
			sender.sendMessage(this.plugin.getMessage("pay-success", new String[]{Double.toString(amount), player}, sender));
			if(p instanceof Player){
				p.sendMessage(this.plugin.getMessage("money-paid", new String[]{sender.getName(), Double.toString(amount)}, sender));
			}
			return true;
		}
	}catch(NumberFormatException e){
		sender.sendMessage(this.plugin.getMessage("takemoney-must-be-number", sender));
	}
	return true;
}
 
Example 12
Source File: TakeMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.takemoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 2){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String player = args[0];
	
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	try{
		double amount = Double.parseDouble(args[1]);
		if(amount < 0){
			sender.sendMessage(this.plugin.getMessage("takemoney-invalid-number", sender));
			return true;
		}
		
		int result = this.plugin.reduceMoney(player, amount);
		switch(result){
		case EconomyAPI.RET_INVALID:
			sender.sendMessage(this.plugin.getMessage("takemoney-player-lack-of-money", new String[]{player, Double.toString(amount), Double.toString(this.plugin.myMoney(player))}, sender));
			return true;
		case EconomyAPI.RET_NO_ACCOUNT:
			sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_CANCELLED:
			sender.sendMessage(this.plugin.getMessage("takemoney-failed", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_SUCCESS:
			sender.sendMessage(this.plugin.getMessage("takemoney-took-money", new String[]{player, Double.toString(amount)}, sender));
			if(p instanceof Player){
				p.sendMessage(this.plugin.getMessage("takemoney-money-taken", new String[]{Double.toString(amount)}, sender));
			}
			return true;
		}
	}catch(NumberFormatException e){
		sender.sendMessage(this.plugin.getMessage("takemoney-must-be-number", sender));
	}
	return true;
}
 
Example 13
Source File: GamemodeCommand.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (args.length == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return false;
    }

    int gameMode = Server.getGamemodeFromString(args[0]);
    if (gameMode == -1) {
        sender.sendMessage("Unknown game mode");
        return true;
    }

    CommandSender target = sender;
    if (args.length > 1) {
        if (sender.hasPermission("nukkit.command.gamemode.other")) {
            target = sender.getServer().getPlayer(args[1]);
            if (target == null) {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
                return true;
            }
        } else {
            sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
            return true;
        }
    } else if (!(sender instanceof Player)) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return true;
    }

    if ((gameMode == 0 && !sender.hasPermission("nukkit.command.gamemode.survival")) ||
            (gameMode == 1 && !sender.hasPermission("nukkit.command.gamemode.creative")) ||
            (gameMode == 2 && !sender.hasPermission("nukkit.command.gamemode.adventure")) ||
            (gameMode == 3 && !sender.hasPermission("nukkit.command.gamemode.spectator"))) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
        return true;
    }

    if (!((Player) target).setGamemode(gameMode)) {
        sender.sendMessage("Game mode update for " + target.getName() + " failed");
    } else {
        if (target.equals(sender)) {
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.self", Server.getGamemodeString(gameMode)));
        } else {
            target.sendMessage(new TranslationContainer("gameMode.changed"));
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.other", new String[]{target.getName(), Server.getGamemodeString(gameMode)}));
        }
    }

    return true;
}
 
Example 14
Source File: SetMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.setmoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 2){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String player = args[0];
	
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	try{
		double amount = Double.parseDouble(args[1]);
		if(amount < 0){
			sender.sendMessage(this.plugin.getMessage("setmoney-invalid-number", sender));
			return true;
		}
		
		int result = this.plugin.setMoney(player, amount);
		switch(result){
		case EconomyAPI.RET_NO_ACCOUNT:
			sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_CANCELLED:
			sender.sendMessage(this.plugin.getMessage("setmoney-failed", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_INVALID:
			sender.sendMessage(this.plugin.getMessage("reached-max", new String[]{Double.toString(amount)}, sender));
			return true;
		case EconomyAPI.RET_SUCCESS:
			sender.sendMessage(this.plugin.getMessage("setmoney-setmoney", new String[]{player, Double.toString(amount)}, sender));
			if(p instanceof Player){
				p.sendMessage(this.plugin.getMessage("setmoney-set", new String[]{Double.toString(amount)}, sender));
			}
			return true;
		}
	}catch(NumberFormatException e){
		sender.sendMessage(this.plugin.getMessage("setmoney-invalid-number", sender));
	}
	return true;
}
 
Example 15
Source File: PayCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args){
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.pay")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(!(sender instanceof Player)){
		sender.sendMessage(TextFormat.RED + "Please use this command in-game.");
		return true;
	}
	
	if(args.length < 2){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String player = args[0];
	
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	try{
		double amount = Double.parseDouble(args[1]);
		
		int result = this.plugin.reduceMoney((Player) sender, amount);
		switch(result){
		case EconomyAPI.RET_INVALID:
		case EconomyAPI.RET_CANCELLED:
			sender.sendMessage(this.plugin.getMessage("pay-failed", sender));
			return true;
		case EconomyAPI.RET_NO_ACCOUNT:
			sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_SUCCESS:
			this.plugin.addMoney(player, amount, true);
			
			sender.sendMessage(this.plugin.getMessage("pay-success", new String[]{Double.toString(amount), player}, sender));
			if(p instanceof Player){
				p.sendMessage(this.plugin.getMessage("money-paid", new String[]{sender.getName(), Double.toString(amount)}, sender));
			}
			return true;
		}
	}catch(NumberFormatException e){
		sender.sendMessage(this.plugin.getMessage("takemoney-must-be-number", sender));
	}
	return true;
}
 
Example 16
Source File: TakeMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.takemoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 2){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String player = args[0];
	
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	try{
		double amount = Double.parseDouble(args[1]);
		if(amount < 0){
			sender.sendMessage(this.plugin.getMessage("takemoney-invalid-number", sender));
			return true;
		}
		
		int result = this.plugin.reduceMoney(player, amount);
		switch(result){
		case EconomyAPI.RET_INVALID:
			sender.sendMessage(this.plugin.getMessage("takemoney-player-lack-of-money", new String[]{player, Double.toString(amount), Double.toString(this.plugin.myMoney(player))}, sender));
			return true;
		case EconomyAPI.RET_NO_ACCOUNT:
			sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_CANCELLED:
			sender.sendMessage(this.plugin.getMessage("takemoney-failed", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_SUCCESS:
			sender.sendMessage(this.plugin.getMessage("takemoney-took-money", new String[]{player, Double.toString(amount)}, sender));
			if(p instanceof Player){
				p.sendMessage(this.plugin.getMessage("takemoney-money-taken", new String[]{Double.toString(amount)}, sender));
			}
			return true;
		}
	}catch(NumberFormatException e){
		sender.sendMessage(this.plugin.getMessage("takemoney-must-be-number", sender));
	}
	return true;
}
 
Example 17
Source File: NukkitSenderFactory.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
protected boolean hasPermission(CommandSender sender, String node) {
    return sender.hasPermission(node);
}
 
Example 18
Source File: TopMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(final CommandSender sender, String label, final String[] args){
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.topmoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	try{
		final LinkedHashMap<String, Double> money = plugin.getAllMoney();
		final Set<String> players = money.keySet();
		final int page = args.length > 0 ? Math.max(1, Math.min(Integer.parseInt(args[0]), players.size())) : 1;
		new Thread(){
			public void run(){
				List<String> list = new LinkedList<>();
				for(String player:money.keySet()) list.add(player);
				
				Collections.sort(list, new Comparator<String>(){
					@Override
					public int compare(String s1, String s2) {
						double one = money.get(s1);
						double two = money.get(s2);
						return one < two ? 1 : one > two ? -1 : 0;
					}
				});
				
				StringBuilder output = new StringBuilder();
				output.append(plugin.getMessage("topmoney-tag", new String[]{Integer.toString(page), Integer.toString(((players.size() + 6) / 5))}, sender) + "\n");
				
				int duplicate = 0;
				double prev = -1D;
				for(int n = 0; n < list.size(); n++){
					double m = money.get(list.get(n));
					if(m == prev) duplicate++;
					else duplicate = 0;
					prev = m;
					int current = (int)Math.ceil((double)(n + 1) / 5);
					if(page == current){
						output.append(plugin.getMessage("topmoney-format", new String[]{Integer.toString(n + 1 - duplicate), list.get(n), Double.toString(m)}, sender) + "\n");
					}else if(page < current){
						break;
					}
				}
				output.substring(0, output.length() - 1);
				
				if(sender != null){
					sender.sendMessage(output.toString());
				}
			}
		}.start();
	}catch(NumberFormatException e){
		sender.sendMessage(TextFormat.RED + "Please provide a number.");
	}
	return true;
}
 
Example 19
Source File: GiveMoneyCommand.java    From EconomyAPI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
	if(!this.plugin.isEnabled()) return false;
	if(!sender.hasPermission("economyapi.command.givemoney")){
		sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
		return false;
	}
	
	if(args.length < 2){
		sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
		return true;
	}
	String player = args[0];
	
	Player p = this.plugin.getServer().getPlayer(player);
	if(p != null){
		player = p.getName();
	}
	try{
		double amount = Double.parseDouble(args[1]);
		if(amount < 0){
			sender.sendMessage(this.plugin.getMessage("givemoney-invalid-number", sender));
			return true;
		}
		
		int result = this.plugin.addMoney(player, amount);
		switch(result){
		case EconomyAPI.RET_INVALID:
			sender.sendMessage(this.plugin.getMessage("reached-max", new String[]{Double.toString(amount)}, sender));
			return true;
		case EconomyAPI.RET_NO_ACCOUNT:
			sender.sendMessage(this.plugin.getMessage("player-never-connected", new String[]{player}, sender));
			return true;
		case EconomyAPI.RET_SUCCESS:
			sender.sendMessage(this.plugin.getMessage("givemoney-gave-money", new String[]{Double.toString(amount), player}, sender));
			if(p instanceof Player){
				p.sendMessage(this.plugin.getMessage("givemoney-money-given", new String[]{Double.toString(amount)}, sender));
			}
			return true;
		}
	}catch(NumberFormatException e){
		sender.sendMessage(this.plugin.getMessage("givemoney-must-be-number", sender));
	}
	return true;
}
 
Example 20
Source File: GamemodeCommand.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (args.length == 0) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return false;
    }

    int gameMode = Server.getGamemodeFromString(args[0]);
    if (gameMode == -1) {
        sender.sendMessage("Unknown game mode");
        return true;
    }

    CommandSender target = sender;
    if (args.length > 1) {
        if (sender.hasPermission("nukkit.command.gamemode.other")) {
            target = sender.getServer().getPlayer(args[1]);
            if (target == null) {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
                return true;
            }
        } else {
            sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
            return true;
        }
    } else if (!(sender instanceof Player)) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return true;
    }

    if ((gameMode == 0 && !sender.hasPermission("nukkit.command.gamemode.survival")) ||
            (gameMode == 1 && !sender.hasPermission("nukkit.command.gamemode.creative")) ||
            (gameMode == 2 && !sender.hasPermission("nukkit.command.gamemode.adventure")) ||
            (gameMode == 3 && !sender.hasPermission("nukkit.command.gamemode.spectator"))) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
        return true;
    }

    if (!((Player) target).setGamemode(gameMode)) {
        sender.sendMessage("" + target.getName() + "のゲームモード変更に失敗しました。");
    } else {
        if (target.equals(sender)) {
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.self", Server.getGamemodeString(gameMode)));
        } else {
            target.sendMessage(new TranslationContainer("gameMode.changed"));
            Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.other", new String[]{target.getName(), Server.getGamemodeString(gameMode)}));
        }
    }

    return true;
}