Chat prefixes not working

Discussion in 'Plugin Development' started by Graffetus, Nov 1, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    Graffetus

    For some reason whenever I use chat I always get the prefix "Owner" (I removed the permission "custom_chat_owner") yet I still get the prefix. This is my code:
    Code:
    public class Chat implements Listener {
    
        @EventHandler
        public void chatFormat (AsyncPlayerChatEvent e) {
    
                Player p = e.getPlayer();
           //String message = e.getMessage();
            //message = ChatColor.translateAlternateColorCodes('&', message);
            //e.setMessage(message);
    
    
    
            //String message = e.getMessage();
    
    
            if (p.hasPermission("custom_chat_owner")) {
                e.setFormat(ChatColor.DARK_GRAY + "\u00ab " + ChatColor.AQUA + "Owner" + ChatColor.DARK_GRAY + " | "
                        + ChatColor.YELLOW + p.getDisplayName() + ChatColor.DARK_GRAY + " \u00bb " + ChatColor.GRAY + e.getMessage());
            }
            else if (p.hasPermission("custom_chat_admin")) {
                e.setFormat(ChatColor.DARK_GRAY + "\u00ab " + ChatColor.RED + "Admin" + ChatColor.DARK_GRAY + " | "
                        + ChatColor.YELLOW + p.getDisplayName() + ChatColor.DARK_GRAY + " \u00bb " + ChatColor.GRAY + e.getMessage());
            }
            else if (p.hasPermission("custom_chat_mod")) {
                e.setFormat(ChatColor.DARK_GRAY + "\u00ab " + ChatColor.GREEN + "Mod" + ChatColor.DARK_GRAY + " | "
                        + ChatColor.YELLOW + p.getDisplayName() + ChatColor.DARK_GRAY + " \u00bb " + ChatColor.GRAY + e.getMessage());
            }
            else if (p.hasPermission("custom_chat_dev")) {
                e.setFormat(ChatColor.DARK_GRAY + "\u00ab " + ChatColor.RED + "Dev" + ChatColor.DARK_GRAY + " | "
                        + ChatColor.YELLOW + p.getDisplayName() + ChatColor.DARK_GRAY + " \u00bb " + ChatColor.GRAY + e.getMessage());
            }
            else if (p.hasPermission("custom_chat_builder")) {
                e.setFormat(ChatColor.DARK_GRAY + "\u00ab " + ChatColor.GREEN + "Builder" + ChatColor.DARK_GRAY + " | "
                        + ChatColor.YELLOW + p.getDisplayName() + ChatColor.DARK_GRAY + " \u00bb " + ChatColor.GRAY + e.getMessage());
            }
            else if (p.hasPermission("custom_chat_helper")) {
                    e.setFormat(ChatColor.DARK_GRAY + "\u00ab " + ChatColor.GOLD + "Helper" + ChatColor.DARK_GRAY + " | "
                            + ChatColor.YELLOW + p.getDisplayName() + ChatColor.DARK_GRAY + " \u00bb " + ChatColor.GRAY + e.getMessage());
    
            } else {
                e.setFormat(ChatColor.DARK_GRAY + "\u00ab " + ChatColor.GOLD + "Noob" + ChatColor.DARK_GRAY + " | "
                        + ChatColor.YELLOW + p.getDisplayName() + ChatColor.DARK_GRAY + " \u00bb " + ChatColor.GRAY + e.getMessage());
    
            }
        }
    
    
    }
    Any help would be well appreciated!
     
  2. Are you op? If so then it just goes to the first one because you will always have all permissions and it stops at the first if statements because you do have that permission
     
Thread Status:
Not open for further replies.

Share This Page