Chat Event

Discussion in 'Plugin Development' started by AeroLiquid, Oct 5, 2015.

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

    AeroLiquid

    Hey all, in my recent post it can be seen that the format event doesn't seem to be working. But after fixing things, it seems to be that only the player colors entered for the displayname doesn't seem to be working: they all seem to default to &7. Example:
    Owner: (gray)Aero >> (in yellow)Heyo!
    Default: (gray)Aero >> (in gray)Heyo!

    Can anyone help fix?
    PHP:
        @EventHandler
        
    public void onPlayerChat(PlayerChatEvent e) {
            
    Player player e.getPlayer();
            if (
    player.hasPermission("pbasic.chat.normal")) {
                
    e.setFormat("§7%1$s » %2$s");
                
    player.setDisplayName("§7" player.getDisplayName());
                
    player.setPlayerListName("§7" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.investor")) {
                
    e.setFormat("§a%1$s §f» %2$s");
                
    player.setDisplayName("§a" player.getDisplayName());
                
    player.setPlayerListName("§a" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.expert")) {
                
    e.setFormat("§6%1$s §f» %2$s");
                
    player.setDisplayName("§6" player.getDisplayName());
                
    player.setPlayerListName("§6" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.titan")) {
                
    e.setFormat("§9§o%1$s §f» §3%2$s");
                
    player.setDisplayName("§9§o" player.getDisplayName());
                
    player.setPlayerListName("§9§o" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.supervisor")) {
                
    e.setFormat("§d%1$s §f» §e%2$s");
                
    player.setDisplayName("§d" player.getDisplayName());
                
    player.setPlayerListName("§d" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.mod")) {
                
    e.setFormat("§5%1$s §f» §e%2$s");
                
    player.setDisplayName("§5" player.getDisplayName());
                
    player.setPlayerListName("§5" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.mod+")) {
                
    e.setFormat("§5§o%1$s §f» §e%2$s");
                
    player.setDisplayName("§5§o" player.getDisplayName());
                
    player.setPlayerListName("§5§o" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.dev")) {
                
    e.setFormat("§b§o%1$s §f» §e%2$s");
                
    player.setDisplayName("§b§o" player.getDisplayName());
                
    player.setPlayerListName("§b§o" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.admin")) {
                
    e.setFormat("§c%1$s §f» §e%2$s");
                
    player.setDisplayName("§c" player.getDisplayName());
                
    player.setPlayerListName("§c" player.getDisplayName());
            } else if (
    player.hasPermission("pbasic.chat.owner") || player.isOp()
                    || 
    player.hasPermission("*")) {
                
    e.setFormat("§4%1$s §f» §e%2$s");
                
    player.setDisplayName("§4" player.getDisplayName());
                
    player.setPlayerListName("§4" player.getDisplayName());
            }
        }
     
    Last edited: Oct 5, 2015
  2. Offline

    timtower Administrator Administrator Moderator

    @AeroLiquid What colors entered? Like somebody chats this:
    If so: you need to translate that as well so it will use the colors.
     
  3. Offline

    AeroLiquid

    @timtower I've already got an event that removes any colours used in chat
     
  4. Offline

    timtower Administrator Administrator Moderator

    @AeroLiquid But what is the issue then? Because that isn't very clear to me.
     
  5. Offline

    AeroLiquid

    Reread my first comment again: whenever someone with the appropriate permission chats, the display name of player automatically converts to &7, but the message the player says is as specified. So let's say I'm a dev of the server and I chat, I am supposed to receive the display name of "&b&o" but instead I get &7 - the default. That is the issue I need to be fixed.
     
  6. Offline

    timtower Administrator Administrator Moderator

    @AeroLiquid Do you happen to have the permission pbasic.chat.normal ?
    If so: there is your issue.
     
  7. Offline

    AeroLiquid

    @timtower yes I do. I've also cancelled out the permissions that the group doesn't need e.g - -pbasic.default in Each group (besides Default of course)
     
  8. Offline

    timtower Administrator Administrator Moderator

    @AeroLiquid Then there is your issue.
    It finds that permissions, and because you are using else if it won't even check the other permissions.
    That is why you are getting the normal format.
     
  9. Offline

    AeroLiquid

    Alright I understand what you are saying but how would I change to a recognised format?
    @timtower
     
  10. Offline

    timtower Administrator Administrator Moderator

    @AeroLiquid Remove the permission nodes from the chat formats that you don''t want.
     
Thread Status:
Not open for further replies.

Share This Page