Tags in Chat

Discussion in 'Plugin Development' started by willies952002, Mar 2, 2013.

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

    willies952002

    For some reason, i can't seem to figure out how to add tags to the chat for a custom server rank plugin I am making. I was thinking something along the lines of "[OWNER]" and "[ADMIN]" but I just can't find how this is done. Ant help is appreciated :D.
     
  2. Offline

    stirante

    AsyncPlayerChatEvent.setFormat or sth simillar.
     
  3. Offline

    frozenpoptartmc

    you could set admins and the owner to a config or hashmap or something, and then when asyncplayerchatevent is called, see if they are in the hashmap or config and then set their displayName.
     
  4. Offline

    Shinxs

    You could use a PlayerChatEvent something like this:
    Code:
    @EventHandler(priority = EventPriority.NORMAL)
    public void ChatEvent(final PlayerChatEvent event) {
        Player player = event.getPlayer();
        String msg = event.getMessage();
        Bukkit.broadcastMessage(ChatColor.GOLD + "[OWNER] " + ChatColor.RESET + player.getDisplayName() + ChatColor.WHITE + ": " + msg);
        event.setCancelled(true);
    }
    you could then check if a .YML file contains the name under OWNER or ADMIN or PLAYER or so
    this is probably not the easiest way of doing this but it works fine for me :D
     
  5. Offline

    frozenpoptartmc

    that's what i said :p
     
  6. Offline

    Shinxs

    i was already typing and when is posted it you were there ;)
     
  7. Offline

    willies952002

    Thanks everyone, it really seems to have helped. XD
     
  8. Offline

    Shinxs

  9. Offline

    willies952002

    Now it seems that the plugin is not functioning correctly, most likely due to me having each command handled by its own CommandExecutor class. I'm not sure where to put
    Whether it should be in the main class or the class the handles that single command. I believe that it would be the main class, but i cant figure out how to implement this with multiple (8) separate ranks and use only one method statement.
     
  10. Offline

    minoneer

    You can either add it to your main class or, and that's the way I would prefer, create a seperate listener class. But don't forget to register the listener in your onEnable(), no matter which way you choose. About the methods: Like (almost) anywhere in java, you can split up your code in as many methods as you want. Just make sure they call each other correctly.

    regards, minoneer
     
Thread Status:
Not open for further replies.

Share This Page