Make items "undroppable"

Discussion in 'Plugin Development' started by Glass_Eater84, Aug 15, 2014.

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

    Glass_Eater84

    Hey everyone,

    I am wondering how to make items undroppable, so they have an item in their hotbar, but make it so it they can't drop it.
    Any help is much appreciated!

    Thanks,
    Glass
     
  2. Offline

    Jarglax

    Code:java
    1. @EventHandler
    2. public void OnDrop(PlayerDropItemEvent event) {
    3. if (event.getPlayer().getGameMode() != GameMode.CREATIVE) { // Makes it where people in survival cant drop but creative people can. remove to change this so no one can drop at all
    4. event.setCancelled(true);
    5. event.isCancelled();
    6. event.getPlayer().sendMessage(
    7. ChatColor.RED + "" + ChatColor.BOLD
    8. + "Dropping Items Is Disabled");
     
  3. Offline

    _LB

  4. Offline

    Glass_Eater84

  5. Offline

    Jarglax

    Where you in creative? If so you can drop stuff in creative to remove this just remove the if statement and remove the // makes so so stuff. And where is the OnEnable OnDisable
     
  6. Offline

    Glass_Eater84

    Jarglax
    but look at the errors, it won't let me import GameMode also at the end of the chat line
     
  7. Offline

    Gater12

    Glass_Eater84
    Clear sign of copy-paste.

    Forgot closing bracket of method.
     
    AoH_Ruthless likes this.
  8. Offline

    Glass_Eater84

    Gater12
    yes I did copy and paste to save time of course. However I added a closing bracket before because I put this code in multiple sections of the original code. But it does however not cast an error anymore but still does not work.
    - Glass
     
  9. Offline

    Gater12

  10. Offline

    stoneminer02

    I know this isn't the place to ask, but what IDE is that?
     
  11. Offline

    DinosParkour

    stoneminer02 Probably eclipse with a custom theme

    EDIT: To answer @Glass_Eater24 's question, this worked for me
    Code:java
    1. @EventHandler
    2. public void noDrop(PlayerDropItemEvent e){e.setCancelled(true);}
     
Thread Status:
Not open for further replies.

Share This Page