Im trying to make a small plugin that when a player dies 1 xp level drops there regardless of wether they player who died had any xp I have looked at the jd and its not too easy to understand If someone could post some way of doing this? EDIT: I got this: Code: @EventHandler(priority=EventPriority.HIGH) public void onEntityDeath(EntityDeathEvent event) { if ((event.getEntity() instanceof Player)) { Player player = (Player)event.getEntity(); player.giveExp(17); } } } But how do I make the orbs drop at the player death point
I think you must put this between for not increase the player exp : Code: if (event.getDroppedExp() >= 17) { event.setDroppedExp(event.getDroppedExp() - 17); } else { // What you want... } ps: http://jd.bukkit.org/doxygen/d6/d88/classorg_1_1bukkit_1_1event_1_1entity_1_1EntityDeathEvent.html
Might want to check if it is a player first. Or you get an error when an entity that is not a player dies.
Code: ExperienceOrb orb = player.getWorld().spawn(Location, ExperienceOrb.class); orb.setExperience(1); Kinda an inconvenient way to do it if the other methods don't work as intended.