Stop a player from wearing diamond armor?

Discussion in 'Plugin Development' started by mike0631, Feb 10, 2013.

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


    How do I stop the player from trying to wear diamond armor.
  2. Offline


  3. Offline


    Yeah and then?
  4. Offline


    I would personally create a method that checks if a player has diamond armour, then run a scheduled check every 5 seconds or so, then another method can remove the armour.
  5. Offline


    Would require a lot of resources.

    One way would be to listen to InventoryClickEvent and see if they place diamond armour in the armour slots, however this would not work for auto equip.

    A similar method could be to check the armour they are wearing when ever they close their inventory.
  6. Offline


    I dont want to EQUIP it, not `de-quip`.
  7. Offline


    If you read again, he didnt say anything about that :p
  8. Offline


    This should do it. Sure you can figure out the rest of the armor code.

        @EventHandler(priority = EventPriority.LOWEST)
        public void onInventoryClose(InventoryCloseEvent evt) {
            if (evt.getView().getType() == InventoryType.CRAFTING && evt.getPlayer() instanceof Player ) {
            Player p = (Player) evt.getPlayer();
            if ( p.getInventory().getHelmet() != null && p.getInventory().getHelmet().getType().equals( Material.DIAMOND_HELMET  ) ) {
            p.getWorld().dropItemNaturally( p.getLocation(), p.getInventory().getHelmet() );
            p.getInventory().setHelmet( null );
    Fuzzwolf likes this.
  9. Offline


    Ah, sorry
    That should do the trick, thanks.
Thread Status:
Not open for further replies.

Share This Page