ExperienceMod Conflict

Discussion in 'Plugin Development' started by Hydrosis, Jun 9, 2014.

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

    Hydrosis

    Hello world!

    I'm currently trying to make a plugin that will prevent players from camping in one spot and grind their XP. As a test, I ran this simple code:
    Code:java
    1. @EventHandler(priority = EventPriority.????)
    2. public void onKill(EntityDeathEvent event)
    3. {
    4. //TODO: Hook into ExperienceMod
    5. event.setDroppedExp(0);
    6. event.getEntity().getKiller().sendMessage("You got " + event.getDroppedExp() + " xp from this mob!");
    7. }

    The message prints out, so that means I've registered my event properly. Now, on its own, it works just fine, but when I use ExperienceMod, it breaks. The mob still drops its experience. I've tried replacing the ???? from lowest to highest, but it made no difference. His code is on github and I found that this is most likely where the issue might be:
    Code:java
    1. @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    2. public void onEntityDeathEvent(EntityDeathEvent event) {
    3.  
    4. LivingEntity entity = event.getEntity();
    5. Collection<ResourceHolder> result = null;
    6.  
    7. try {
    8. // Only drop experience from mobs
    9. if (entity != null) {
    10. Player killer = entity.getKiller();
    11. result = handleEntityDeath(event, entity, killer);
    12. }
    13.  
    14. if (event instanceof PlayerDeathEvent) {
    15. handlePlayerDeath((PlayerDeathEvent) event, (Player) entity, result);
    16. }
    17.  
    18. // Every entry method must have a generic catcher
    19. } catch (Exception e) {
    20. report.reportError(debugger, this, e, event);
    21. }
    22. }

    What I'm confused is, if I have it set on lowest and I tell it to drop 0 XP, shouldn't his listener see that the XP dropped is 0 since I handled it first?

    Thanks in advance for any support!
     
  2. Offline

    mine-care

  3. Offline

    Hydrosis

    Thanks...but that's not really answering my question haha. My issue isn't how I should check campers it, the issue is why the XP still drops, even though I'm setting it to 0 (that is while I'm using the ExperienceMod). Please look at the resources I've provided; I've already made 20+ plugins and a minigame so I'm no newb at making plugins :p
     
  4. Offline

    mine-care

    Hydrosis sorry I hav a bit of limited time, imstudyingnfor exams so I am not paying attention....
     
  5. Offline

    indyetoile

    Hence you shouldn't write irrelevant replies.

    Anyways, Hydrosis, if that is the event that handles the XP drops themselves, you should indeed hook into ExperienceMod.
    However, looking at the ExperienceMod's Entity Death Event, it doesn't handle XP drops as you do. Look into the code to see how they handle it, and eventually add that method into your code.
     
  6. Offline

    Hydrosis

    I'd like to have my plugin work along side that plugin (as opposed to copying it). I'd like to simply set the experience dropped to 0 (I'll add more constraints later of course), without having that plugin overwrite my intended action.
     
Thread Status:
Not open for further replies.

Share This Page