Solved Events

Discussion in 'Plugin Development' started by mike0631, Jun 9, 2013.

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

    mike0631

    What happens when I have 2 times
    Code:
        @EventHandler
        public void onInteract(PlayerInteractEvent e){
            
        }
    
    and they both do different things?
     
  2. Offline

    NoLiver92

    can you make your post clear? it is unclear on what you are after.
     
  3. Offline

    mike0631

    I mean, what will happen when I have two eventhandlers of the same type "PlayerInteractEvent" and they are both in a different class, but still the same plugin.

    Will it work or not?
     
  4. Offline

    NoLiver92

    cant you just combine them into one?
     
  5. Offline

    MUG806

    Pretty sure they will happen one after the other. Probably by class name, or at random.
     
  6. Offline

    NoLiver92

    they should both work but like you say its random on which goes first. it would be better to put them into the one event
     
  7. Offline

    CubieX

    You should never register two handlers for the same event.
    And I can't see any reason why you would have to do so.

    What are you trying to achieve?
     
  8. Offline

    mike0631

    I was just asking.
     
  9. Offline

    CubieX

    Oh ok.
    Well I never heard it would be a good idea to use two handlers for one event.
    Reason might be what MUG806 and NoLiver92 wrote.
    You can't say which one will fire first.
    And it seems redundant, because even if someone needs the handler to do different things in different situations,
    the distinction can be done in this single handler.
     
Thread Status:
Not open for further replies.

Share This Page