[SOLVED]Duplicated PlayerJoinEvent ? (Duplicated registration of event ;-) )

Discussion in 'Plugin Development' started by Ribesg, Oct 16, 2011.

Thread Status:
Not open for further replies.
  1. Hi
    In my onPlayerJoin() method, I send a message to the player.
    The message is sent 2 times. Why ?
    How could I change it ?
     
  2. Offline

    TMAsantos

    do you have event.setCancelled ? after de message?
     
  3. Why should I cancel a PlayerJoinEvent ?
    It will certainly fix the problem but I'm not sure if it will not had another problem, like if another plugin want to use the PlayerJoinEvent and check if it is cancelled...
     
  4. Offline

    NeoSilky

    Can we see code? :)
     
  5. http://pastebin.com/PkW8XULC
    As you can see, I'm using the onPlayerJoin() and not the onPlayerLogin() because of the player.getAddress().getAddress().getHostAddress(); which is Null in onPlayerLogin().
    This is done 2 times :
    1. player.sendMessage(plugin.HEADER + ChatColor.GREEN
    2. + "Bienvenue sur le serveur " + playerName + " !");
     
  6. Offline

    NeoSilky

    Urm, you have this twice? :

    Code:
                                    player.sendMessage(plugin.HEADER + ChatColor.GREEN
                                                    + "Bienvenue sur le serveur " + playerName + " !");
     
  7. That was just a wrong copy/paste, I was adding a line. Now look at this :
    This is the code
    And here is what it does :
    [​IMG]
     
  8. Offline

    wwsean08

    its not even a cancellable event. And thats a very interesting bug, not quite sure why it's happening. You don't have any other events sending the message correct?
     
  9. I just add the second message, and as you can see it is sent 2 times. The problem is here.
     
  10. Offline

    wwsean08

    yah i just wanted to make sure you didn't forget about a second event you had it in that you forgot about
     
  11. Offline

    TMAsantos

    thats a bug :S
    Type "return;" after sendding that message... but that is stange because there is no loop...
    Mabye you server is having a but on player join... Create another server only with that plugin and see if it dup the message again
     
  12. Prepare to laugh !
    PHP:
    PluginManager pm this.getServer().getPluginManager();
            
    pm.registerEvent(Event.Type.ENTITY_DAMAGEentityListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.FOOD_LEVEL_CHANGEentityListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESSplayerListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.PLAYER_CHATplayerListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.PLAYER_INTERACTplayerListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.SIGN_CHANGEblockListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.BLOCK_BREAKblockListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.BLOCK_PLACEblockListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.PLAYER_JOINplayerListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.PLAYER_MOVEplayerListener,
                    
    Event.Priority.Normalthis);
            
    pm.registerEvent(Event.Type.PLAYER_JOINplayerListener,
                    
    Event.Priority.Normalthis);
    Fixed now :rolleyes:
     
  13. Offline

    wwsean08

    that'll do it lol, i was actually thinking about that a minute ago but went nah, thats not the problem.
     
  14. I feel stupid now xD
    In fact, I add the PLAYER_JOIN event a few days ago, then I deleted it in my playerListener, but not in my main class. Today I had to use it again, and simply add it to the list... :rolleyes:
     
Thread Status:
Not open for further replies.

Share This Page