diff --git a/war/src/main/java/com/tommytony/war/config/TeamKind.java b/war/src/main/java/com/tommytony/war/config/TeamKind.java index 77e7c20..cc76aa8 100644 --- a/war/src/main/java/com/tommytony/war/config/TeamKind.java +++ b/war/src/main/java/com/tommytony/war/config/TeamKind.java @@ -192,8 +192,8 @@ public enum TeamKind { } /** - * Get a colored hat item for the team. - * @return Hat item with the team's color. + * Get a colored armor item for the team. + * @return Armor item with the team's color. */ public ItemStack getHat() { ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); @@ -202,4 +202,28 @@ public enum TeamKind { helmet.setItemMeta(meta); return helmet; } + + public ItemStack getChestplate() { + ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); + LeatherArmorMeta meta = (LeatherArmorMeta) armor.getItemMeta(); + meta.setColor(this.getBukkitColor()); + armor.setItemMeta(meta); + return armor; + } + + public ItemStack getLeggings() { + ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS); + LeatherArmorMeta meta = (LeatherArmorMeta) leggings.getItemMeta(); + meta.setColor(this.getBukkitColor()); + leggings.setItemMeta(meta); + return leggings; + } + + public ItemStack getBoots() { + ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); + LeatherArmorMeta meta = (LeatherArmorMeta) boots.getItemMeta(); + meta.setColor(this.getBukkitColor()); + boots.setItemMeta(meta); + return boots; + } } diff --git a/war/src/main/java/com/tommytony/war/job/HelmetProtectionTask.java b/war/src/main/java/com/tommytony/war/job/HelmetProtectionTask.java index 4bcdfca..5217f20 100644 --- a/war/src/main/java/com/tommytony/war/job/HelmetProtectionTask.java +++ b/war/src/main/java/com/tommytony/war/job/HelmetProtectionTask.java @@ -35,10 +35,19 @@ public class HelmetProtectionTask implements Runnable { if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) { teamBlockMaterial = team.getKind().getMaterial(); - // 1) Replace missing block head + // 1) Replace missing block armor if (playerInv.getHelmet() == null || playerInv.getHelmet().getType() != Material.LEATHER_HELMET) { playerInv.setHelmet(team.getKind().getHat()); } + if (playerInv.getChestplate() == null || playerInv.getChestplate().getType() != Material.LEATHER_CHESTPLATE) { + playerInv.setChestplate(team.getKind().getChestplate()); + } + if (playerInv.getLeggings() == null || playerInv.getLeggings().getType() != Material.LEATHER_LEGGINGS) { + playerInv.setLeggings(team.getKind().getLeggings()); + } + if (playerInv.getBoots() == null || playerInv.getBoots().getType() != Material.LEATHER_BOOTS) { + playerInv.setBoots(team.getKind().getBoots()); + } // 2) Get rid of extra blocks in inventory: only keep one HashMap blocks = playerInv.all(teamBlockMaterial);