How To Cancel/Reset Player Metadata on death?

Discussion in 'Plugin Development' started by thegarfish, Aug 26, 2013.

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


    Hey guys, whenever a player selects a kit, he can never select another (until the server restarts). I know I need to reset/delete the players metadata, but I don't know how to do this..

    Here is my source.
  2. Offline


    If you create an EventListener to listen to PlayerDeathEvent, you can just call "removeMetadata" on the player, providing you know the keys of the metadata that are set.
  3. Offline


    How would I add that?
    event1.onplayerdeath removeMetadata?
  4. Offline


    Er.. not quite.

    1. public class PlayerDeathListener implements Listener {
    2. private JavaPlugin hostPlugin;
    4. public PlayerDeathListener(JavaPlugin plugin) { hostPlugin = plugin; }
    5. @EventHandler
    6. public void onPlayerDeath(PlayerDeathEvent event) {
    7. Player plr = event.getEntity();
    8. // Now just remove all the metadata that you have added to the player
    9. plr.removeMetadata("key", hostPlugin);
    10. }
    12. }

    If you're confused on how to add events, perhaps it might be better if you read the Plugin tutorial first.
Thread Status:
Not open for further replies.

Share This Page