Reccomended way to set color in AsyncPlayerChatEvent

Discussion in 'Plugin Development' started by null_ptr, Jul 29, 2015.

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

    null_ptr

    Say my code looks like this...

    Code:
    String str = "test";
    AsyncPlayerChatEvent chat = new AsyncPlayerChatEvent(isEnabled(),player , str , aPlayerSet
    What is a recommended way to format the above message?

    Please let me know if you need more info.
     
    Last edited: Jul 29, 2015
  2. Offline

    timtower Administrator Administrator Moderator

    @null_ptr Define format the above message.
    What are you trying to do? And why aren't you just using player.chat(<message>) ?
     
  3. Offline

    null_ptr

    I am in the process of writing my first plugin, still sorting out the details of implementation, but I have clear idea of how I in-vision things working. This part of the plugin is say... a player clicks on a object/entity then the plugin writes a message to that player. Currently I am testing buy calling the plugin in game using commands.
    https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerChatEvent.html
    It player.chat apears to be "Deprecated" so I decided to use AsyncPlayerChatEvent instead.
     
  4. Offline

    timtower Administrator Administrator Moderator

    @null_ptr Sending a message to the player is done with player.sendMessage, not with fancy chat events
     
    bwfcwalshy likes this.
  5. Offline

    Tecno_Wizard

    @timtower, he obviously doesn't understand event driven structure.


    @null_ptr, all the classes you see extending from event are part of an event driven structure. Essentially, when something happens in the plugin, Bukkit goes and invokes methods registered to the event handler annotation when the class is registered. You cannot call these events on your own.

    player.sendMessage causes the async chat event to fire, allowing you to edit the result, but not cause it in the first place.

    I actually learned how Bukkit does all of this last week (codewise that is). It's really quite ingenious.
     
Thread Status:
Not open for further replies.

Share This Page