Minecraftのサーバープラグインを作る(2.5) ~名前を変える編~

前回のコマンド実装のその後と全文。解説は特に。

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 static org.bukkit.ChatColor.*;

public class fakename implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        if (sender.isOp()){

            if (args.length == 2) {

                Player pl = Bukkit.getPlayer(args[0]);
                if (pl != null) {

                    pl.setCustomName(args[1]+"...?");
                    pl.setDisplayName(args[1]+"...?");
                    pl.setPlayerListName(args[1]+"...?");

                    if (sender.getName() == pl.getName()) {

                        pl.sendMessage("------------------------------\n" +
                                GREEN + "Command succeeded: The "+ pl.getName() +"\'s name changes to " + args[1]+"...?" +"." + RESET + "\n" +
                                "------------------------------");
                        return true;

                    } else {

                        sender.sendMessage("------------------------------\n" +
                                GREEN + "Command succeeded: " + pl.getName() + "\'s name changes to " + args[1]+"...?" +"."+ RESET + "\n" +
                                "------------------------------");
                        pl.sendMessage("------------------------------\n" +
                                GREEN + "Command succeeded: " + pl.getName() + "\'s name changes to " + args[1]+"...?" + " by " + sender.getName() + "." + RESET + "\n" +
                                "------------------------------");
                        return true;

                    }

                } else {

                    sender.sendMessage("------------------------------\n" +
                            RED + "Error: No such player exists." + RESET + "\n" +
                            "usage: /fakename < PlayerName > < fakename >\n" +
                            "description: You can set a fake name using the name of another user.\n" +
                            "------------------------------");
                    return true;

                }

            } else {

                sender.sendMessage("------------------------------\n" +
                        RED + "Error: Please enter a enough arguments." + RESET + "\n" +
                        "Usage: /fakename < PlayerName > < fakename >\n" +
                        "Description: You can set a fake name using the name of another user.\n" +
                        "------------------------------");
                return true;

            }

        } else {

            sender.sendMessage("------------------------------\n"+
                    RED +"Error: Operator permission is required." + RESET + "\n"+
                    "------------------------------");
            return true;

        }

    }
}

良ければサポートよろしくお願いいたします。いただいたサポートは活動費として使用させていただきます。