What listener to use?

Discussion in 'Plugin Development' started by hayer, Feb 14, 2011.

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

    hayer

    Hi

    Pretty new to this stuff but have been programming in C#, PHP, some C++ and other languages in the past 4-5years.

    Now to the question...
    When a user interacts with a chest I want to .. do something. Like send a message to the chat.
    To register the event I got this in my onEnable():
    Code:
    pm.registerEvent(Event.Type.BLOCK_INTERACT, [B]playerListener[/B], Priority.Normal, this);
    As you can see I placed the playerListener as listener. But should I use the blocklistener instead? Why? To me it seems more logical because Event.Type is BLOCK_* and that should go to the blockListener.

    On the side, how to I:
    1. Post a 'global' chat message?
    2. Send a private chat message to a player?
     
  2. Offline

    darknesschaos

    a) you need it to go to the block listener, otherwise it wont/shouldnt work. and you may want to use inventory open event (i think there is one.) To send a message to the player it is player.sendMessage("Put message here. ") and I believe Plugin.Server.announce("message") should do the trick.
     
  3. Offline

    Saturisk

    That's just common sense.
     
  4. Offline

    gnftoxic

    Global chat message: getServer().broadcastMessage("Message here.");
    Private chat messsage (should be) : getServer().getPlayer("Specific player name here").sendMessage("message here.");
     
Thread Status:
Not open for further replies.

Share This Page