Created
March 22, 2014 04:53
-
-
Save fpigerre/9701473 to your computer and use it in GitHub Desktop.
Code utilising the Bukkit API (bukkit.org) to listen for when a minecraft player equips Armor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * This code checks if a player edits an armor slot | |
| */ | |
| @EventHandler | |
| public void onArmorSlot(InventoryClickEvent event) { | |
| if (event.getSlotType() == (InventoryType.SlotType.ARMOR) && event.getInventory().getItem(event.getSlot()) != null) { | |
| /* Action Code Here */ | |
| } | |
| } | |
| /* | |
| * This code checks if a player moves an armor item in their inventory | |
| */ | |
| Material[] armorTypes = {Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS}; | |
| @EventHandler | |
| public void onArmourEquip(InventoryMoveItemEvent event) { | |
| for (Material material : armorTypes) { | |
| if (material == event.getItem().getType()) { | |
| /* Action Code Here */ | |
| break; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment