Make a helmet stay on permanently

Discussion in 'Plugin Development' started by BDKing88, Jul 17, 2013.

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

    BDKing88

    Hey everyone, I'm making a pvp server with my own custom plugins, and I want to show off each team with a certain color wool helmet. I want to make it so the wool hat is unremovable. If the player tries to remove it, it just dissapears out of their inventory and goes back on their head. I don't know how to do this, but if someone can help, I will be very grateful! :D
     
  2. Offline

    Metal Julien

    BDKing88 Maybe try to cancel the click on a slot in inventory event if the slot is the helmet and do afterwards player.updateInventory();

    That could do
     
  3. Offline

    BDKing88

    Anyone know a way?
     
  4. Offline

    Pawnguy7

    The way they suggested is the way to do it. No, really, I used this myself, and it works just fine.

    http://jd.bukkit.org/rb/doxygen/d9/...vent_1_1inventory_1_1InventoryClickEvent.html

    Code:java
    1.  
    2. public void onHelmetRemove(InventoryClickEvent event)
    3. {
    4. if (event.getSlotType() == SlotType.ARMOR)
    5. event.setCancelled(true);
    6. }
    7.  


    If you want non-head armor able to be removed, you could either A) check the item and see if it makes sense (helmet should only be on head), or B) check the actual slot number, once you figure out what slot number it is in that inventory.
     
  5. Offline

    BDKing88

    Pawnguy7
    That works, but it deletes the item when clicked. Any way around that? (Sorry for the laaate reply)
    EDIT: It does work, but the second time I try to take it off, it does come off.
     
  6. Offline

    Pawnguy7

    It does? I am pretty sure that is exactly what I used.
     
  7. Offline

    BDKing88

    Pawnguy7
    Yea, idk what the problem is.
     
  8. Offline

    Pawnguy7

    Perhaps you set the clicked slot to the item?
     
Thread Status:
Not open for further replies.

Share This Page