EventPriority on AsyncPlayerChatEvent

Discussion in 'Plugin Development' started by NortherKnight, Sep 8, 2015.

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

    NortherKnight

    I did a plugin that changes your chat color but when im trying to take the outputed text from essentials chat color it does nothing.

    I tryed putting my EventPriority on HIGHEST but it still dosent work since essentials chat color has the same event and on HIGHEST.

    I tryed putting it on MONITOR and still nothing :( does anyone know how to solve this?
     
  2. I had the same problem, and it turned out I didn't register my events :p
     
  3. Offline

    NortherKnight

    Nope registered my events
     
  4. Hmmm, could you put your code in a pastebin for me? That way my phone can see it...
     
  5. Offline

    NortherKnight

  6. Check if the player name is in the list nameColor, probably it isnt there that's why the format isnt changing.

    I don't know if its this what you want

    Code:
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerChat(AsyncPlayerChatEvent e) {
            Player player = e.getPlayer();
            if(!nameColor.containsKey(player.getName()))
            {
                    return;
            }
                 
            ChatColor color = ChatColor.valueOf(nameColor.get(player.getName()));
            e.setFormat(player.getName() + " » " + color + event.getMessage());
            //Or you can
            e.setFormat(event.getFormat() + " » " + color + event.getMessage());
            //But as i said i don't know if it is what you want 
    
    }
    
     
  7. Offline

    SuperOriginal

    Or instead of breaking all the plugins that modify chat, you can set the format like it's supposed to.

    Code:
    e.setFormat("%s: %s");
    The first %s is the player's name and the second is the message. Use that to be compatible with other plugins.
     
  8. Offline

    NortherKnight

    @MaTaMoR_ The essentials outputes this : [A] NortherKnight » message
    so I want to keep the format like that because it relates to groups (this is a saparate plugin)
    PS: The name is in the hashmap i checked that

    @SuperOriginal ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  9. So you just wanna set the message with ?
    Code:
    
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerChat(AsyncPlayerChatEvent e) {
     Player player = e.getPlayer();
     if(!nameColor.containsKey(player.getName())) {
         return;
     }
             
     ChatColor color = ChatColor.valueOf(nameColor.get(player.getName()));
     e.setMessage(color + event.getMessage);
    }
    
     
  10. Offline

    NortherKnight

    @MaTaMoR_ No i want just the message colored not the whole output. [A] NortherKnight » message
     
  11. That will only set the message, not the format.
     
  12. Offline

    NortherKnight

    @MaTaMoR_ hmm will try

    @MaTaMoR_ works thanks m8 :3

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
Thread Status:
Not open for further replies.

Share This Page