This commit is contained in:
Fikry Abdullah Aziz 2016-08-04 01:53:18 +00:00 committed by GitHub
commit b1cb538ad5
2 changed files with 36 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -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<Integer, ? extends ItemStack> blocks = playerInv.all(teamBlockMaterial);