PlayerDropItemEvent

Discussion in 'Plugin Development' started by Woobie, Sep 23, 2012.

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

    Woobie

    Okay so im trying to disable item dropping if player is in creative mode, and these are the codes i've tried, and both of them doesnt work.
    Code:
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onPlayerDrop(PlayerDropItemEvent event) {
            Player player = (Player) event.getPlayer();
                if (player.getGameMode() == GameMode.CREATIVE) {
                        event.setCancelled(true);
                    } else {
                        event.setCancelled(true);
            }
     
        }
    }
    Code:
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onDrop(PlayerDropItemEvent event) {
            Player p = event.getPlayer();
            if(p.getGameMode() == GameMode.CREATIVE) {
                event.setCancelled(true);
                p.sendMessage("You are not allowed to drop items in creative!");
     
  2. Offline

    JayzaSapphire

    Have you registered your listener?
     
  3. Offline

    Woobie

    EDIT: Got it working, just had to register the events in the main class.
     
  4. Offline

    JayzaSapphire

    I think you missed a bit of code, And exactly the same way you added the entitydamageevent
     
Thread Status:
Not open for further replies.

Share This Page