Fixes gh-594 - blockheads:off now results in a colored helmet

This commit is contained in:
cmastudios 2013-02-09 12:47:11 -06:00
parent 9ca2ed1f46
commit a3f73b5fe7
2 changed files with 49 additions and 9 deletions

View File

@ -47,6 +47,7 @@ import com.tommytony.war.utility.PotionEffectHelper;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
import com.tommytony.war.volume.ZoneVolume;
import org.bukkit.inventory.meta.LeatherArmorMeta;
/**
*
@ -442,15 +443,11 @@ public class Warzone {
playerInv.setHelmet(new ItemStack(team.getKind().getMaterial(), 1, (short) 1, new Byte(team.getKind().getData())));
} else {
if (!helmetIsInLoadout) {
if (team.getKind() == TeamKind.GOLD) {
playerInv.setHelmet(new ItemStack(Material.GOLD_HELMET));
} else if (team.getKind() == TeamKind.DIAMOND) {
playerInv.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
} else if (team.getKind() == TeamKind.IRON) {
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
} else {
playerInv.setHelmet(new ItemStack(Material.LEATHER_HELMET));
}
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
meta.setColor(team.getKind().getBukkitColor());
helmet.setItemMeta(meta);
playerInv.setHelmet(helmet);
}
}
}

View File

@ -94,6 +94,49 @@ public enum TeamKind {
return new Color(255,255,255);
}
}
/**
* Gets the color for Bukkit
* @return the color
*/
public org.bukkit.Color getBukkitColor() {
int colorCode = (int)this.data;
switch (colorCode) {
case 0:
return org.bukkit.Color.fromRGB(255,255,255);
case 1:
return org.bukkit.Color.fromRGB(255,128,0);
case 2:
return org.bukkit.Color.fromRGB(255,128,255);
case 3:
return org.bukkit.Color.fromRGB(0,0,255);
case 4:
return org.bukkit.Color.fromRGB(255,215,0);
case 5:
return org.bukkit.Color.fromRGB(0,255,0);
case 6:
return org.bukkit.Color.fromRGB(255,128,255);
case 7:
return org.bukkit.Color.fromRGB(100,100,100);
case 8:
return org.bukkit.Color.fromRGB(200,200,200);
case 9:
return org.bukkit.Color.fromRGB(128,255,255);
case 10:
return org.bukkit.Color.fromRGB(128,0,255);
case 11:
return org.bukkit.Color.fromRGB(0,0,128);
case 12:
return org.bukkit.Color.fromRGB(128,0,0);
case 13:
return org.bukkit.Color.fromRGB(0,128,0);
case 14:
return org.bukkit.Color.fromRGB(255,0,0);
case 15:
return org.bukkit.Color.fromRGB(0,0,0);
default:
return org.bukkit.Color.fromRGB(255,255,255);
}
}
public Material getMaterial() {
return this.material;