Hello, how to do when player dies hes staff will not fall from him? i tried some things and its doesnt work... thank you!
What I do: Have 2 maps storing player names and the contents of their inv and armour (ItemStack[]), and then on death, save their inv and armour contents to these maps and clear their inventories event.getDrops().clear() Then, on player respawn, check if the player's name is in these maps, and then set the contents of their armour and inv from the maps and remove them from the map. (Or use a wrapper class and a map (class called PlayerItems and Map<String, PlayerItems>)) Or simply set gamerule keepInventory to true and back to its original value with a scheduler. Or simply clear their inv on death if you don't want to restore it. Will that do?
@chinwe i did that: Code:java @EventHandlerpublic void onDeath(PlayerDeathEvent event){Player player = event.getEntity();PlayerInventory pi = player.getInventory();pi.clear();} but still when player dies he stuff are falling...
You can remove the drops with: Code: event.getDrops.clear(); And the xp with: Code: event.setDroppedExp(0);
I thought there was that method, but when I looked at the docs I couldnt see it - but now I can :c Replace clearing the inv with what Seadragon91 said :>
i have server with multi-worlds... just in 1 of them i need that... @Seadragon91 i am trying now.. Code:java @EventHandler public void onDeath(PlayerDeathEvent event){ Player player = event.getEntity(); if(!(player.hasPermission("vaspvp.drop"))){ event.getDrops().clear(); } else { } } Seadragon91 doesnt work.. please help! EDIT by Moderator: merged posts, please use the edit button instead of double posting.
morha13 What's the error? In your MAIN class, in your onEnable() method, add Code:java //this is in the main classgetServer().getPluginManager().registerEvents(new <listener name>(), this); //the listener class. MUST implement listener, and MUST have the same name from the register Events linepublic class <listener name> implements Listener {//the listener-like public void blahblahblah...} It would also help to add an EventPriority. Change your @EventHandler to Code:java @EventHandler(priority = EventPriority.MONITOR) This would have the exact same place in the class as the EventHandler without the priority- Right above the public void....m Also, PlayerDeathEvent applies to player, so Player player = event.getEntity() IS REPLACED BY Code:java Player player = event.getPlayer()
i dont understand you.. sorry @xTrollxDudex my script: Code:java public class kit extends JavaPlugin{public static kit plugin;public final Logger logger = Logger.getLogger("Minecraft"); @EventHandlerpublic void onDeath(PlayerDeathEvent event){Player player = event.getEntity();if(!(player.hasPermission("vaspvp.drop"))){event.getDrops().clear();} else { } can you please add to my script what i need?
morha13 He's talking about registering events in your main class. If that is your main class, try making a listener.
T3h Cr33p3r He said he only wanted to disable it in one world, read before commenting. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@Minnymin3 i have read that, thank you ... i am new in bukkit development so i still new @xTrollxDudex ok thank you i will try!