Stopping players from removing helmet problem

Discussion in 'Plugin Development' started by bloodless2010, Feb 4, 2016.

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

    bloodless2010

    So I'm trying to make a pretty basic hat plugin just to practice, but I've come across this strange problem,
    Here is my current event code;
    PHP:
    @EventHandler(priority EventPriority.NORMAL)
        public 
    void armorClick(InventoryClickEvent event) {
            if(
    event.getSlotType() == InventoryType.SlotType.ARMOR)
            {
                
    event.setCancelled(true);
            }
        }
    It works for the first click, but after that it allows me to take the item out of my helmet slot, why is this happening and how can I fix it? Thanks! :)
    Here is a quick video I made of what's happening:
    https://dl.dropboxusercontent.com/u/37687953/Recording.webm
     
  2. Offline

    GamerzKing

    Try:
    Code:
    if(event.getSlot == SlotType.ARMOR) {
    event.setCancelled(true);
    }
     
  3. Offline

    Xerox262

    Can you show more of your code? Maybe your JavaPlugin class, what you have should work, unless you forgot to register the events or something.
     
  4. Offline

    bloodless2010

    Here's the odd thing, it started working now, and I have no idea why. Thanks anyway though.
     
  5. Offline

    fatpigsarefat

    Can you mark the thread as solved?
     
  6. Offline

    bloodless2010

    Sorry, forgot to mention that it still doesn't work 100% properly, not sure what's causing it not to work but sometimes it works, and sometimes it behaves like in the video I linked :/
     
  7. Offline

    Xerox262

    @bloodless2010
     
Thread Status:
Not open for further replies.

Share This Page