Solved Custom /nick command fail

Discussion in 'Spigot Plugin Development' started by DatSquidFTW, Jan 26, 2020.

  1. Quick question. So I have a very basic /nick command here. It's different in that you can only change the color of your name and not the actual name. It works great on its own but doesn't do anything when I have EssentialsChat for the formatting. It just breaks. Here's the code and the formatting part of the Essentials config

    Code (Java):
    if (sender instanceof Player){
                Player p = (Player) sender;
                if (p.hasPermission(getPermissionNode())){
                    if (args.length == 0){
                        p.sendMessage(Utils.chat(plugin.getConfig().getString("Line1")));
                        p.sendMessage(Utils.chat(plugin.getConfig().getString("Line2")));
                    } else if (args.length == 1){
                        String name = Utils.chat(args[0] + "&r");
                        String nameCheck;
                        nameCheck = ChatColor.stripColor(name);
                        if (!nameCheck.equals(p.getName())){
                            p.setDisplayName(p.getName());
                            p.sendMessage(Utils.chat(plugin.getConfig().getString("NameNotNickname")));
                        } else {
                            p.setDisplayName(name);
                            p.sendMessage(Utils.chat(plugin.getConfig().getString("Nickname-Given").replace("<player>", p.getDisplayName())));
                        }
                    }
                } else {
                    p.sendMessage(Utils.chat(plugin.getConfig().getString("No-Perms")));
                }
            }

            return true;
    Code (YAML):
    Member: '{DISPLAYNAME} {deluxetags_tag} &7&l»&7 {MESSAGE}'
        Coal
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&f {MESSAGE}'
        Iron
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&f {MESSAGE}'
        Gold
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&f {MESSAGE}'
        Diamond
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&f {MESSAGE}'
        Obsidian
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&f {MESSAGE}'
        Bedrock
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&f {MESSAGE}'
        Champion
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&f {MESSAGE}'
        YouTube
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&r&f {MESSAGE}'
        TrialMod
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&a {MESSAGE}'
        Mod
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&a {MESSAGE}'
        SrMod
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&a {MESSAGE}'
        Admin
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&a {MESSAGE}'
        SrAdmin
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&c {MESSAGE}'
        Owner
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&c {MESSAGE}'
        Developer
    : '{DISPLAYNAME} {deluxetags_tag} &7&l»&c {MESSAGE}'
     
  2. If you plan on using Essentials, why not just change the nickname using Essentials? Just run the /nick command inside your code.
     
    • Agree Agree x 1