Solved Per world chat prefixes

Discussion in 'Plugin Development' started by HenkDeKipGaming, Dec 3, 2015.

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

    HenkDeKipGaming

    Hey guys,

    So i'm working on a plugin about per world chat.
    So I have this code when a player chats:
    Code:
    @SuppressWarnings("deprecation")
    @EventHandler(priority = EventPriority.HIGHEST)
    public void PlayerChat(AsyncPlayerChatEvent e) {
            Player p = e.getPlayer();
            //String s = e.getFormat();
            e.setCancelled(true);
            for(Player pl : Bukkit.getOnlinePlayers()) {
                if(pl.getLocation().getWorld().equals(p.getWorld())) {
                    pl.sendMessage(p.getName() + ": "  + e.getMessage());
                }
            }
        }
    
    But when I do it like this, obviously it will not show any prefixes of other plugins.
    Is it possible to get those? With thet getFormat method I still couldn't get the prefixes..

    Thanks!
     
  2. Offline

    Scimiguy

    Depends on how the other plugins handle their prefixes too.
     
  3. Offline

    HenkDeKipGaming

    Well I have an other plugin and I really want it to work with that plugin.
    That plugin just sets the format in the AsyncPlayerChatEvent
     
  4. Offline

    Scimiguy

    And what priority did you set the event to in your other plugin?
     
  5. Offline

    FabeGabeMC

    @HenkDeKipGaming I would rather set the format rather than sending a message, since it might fire twice since you have two plugins doing pretty much the exact same thing.
     
  6. Offline

    HenkDeKipGaming

    But how do I get the prefixes from other plugins?
     
  7. Offline

    FabeGabeMC

    @HenkDeKipGaming Set the priority of the 1st plugin to be faster than the 2nd. Then, finish the rest using the AsyncPlayerChatEvent#getFormat() and setting the format to be the prefix plus the format.
     
  8. Offline

    HenkDeKipGaming

    Just to make myself clear, I want to get the prefixes from my other plugin, but it should still work without the other plugin. I just want to get the whole message with prefixes and everything and send it to all the players in a world. is this possible?
     
  9. Offline

    FabeGabeMC

    @HenkDeKipGaming Yes. As long as you just change the format, don't cancel the event, and don't send the message, only the chat message with both edits should be sent.
     
  10. Offline

    HenkDeKipGaming

    But I want to only show the message to the players in the same world as the other player, how would I do this then?
     
  11. Offline

    FabeGabeMC

    HenkDeKipGaming likes this.
  12. Offline

    HenkDeKipGaming

  13. Offline

    FabeGabeMC

Thread Status:
Not open for further replies.

Share This Page