Merge pull request #221 from SupaHam/fix-item-color-deserialization

Add support for deserializing item color RGB values as integers.
This commit is contained in:
Ali 'SupaHam' M 2015-10-08 19:21:30 +01:00
commit bae6f89fa5
2 changed files with 6 additions and 2 deletions

View File

@ -198,7 +198,11 @@ public class MetaItemStack {
addBannerMeta(sender, false, string, ess);
} else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour")) && (stack.getType() == Material.LEATHER_BOOTS || stack.getType() == Material.LEATHER_CHESTPLATE || stack.getType() == Material.LEATHER_HELMET || stack.getType() == Material.LEATHER_LEGGINGS)) {
final String[] color = split[1].split("(\\||,)");
if (color.length == 3) {
if(color.length == 1 && NumberUtil.isInt(color[0])) { // int rgb
final LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta();
meta.setColor(Color.fromRGB(Integer.parseInt(color[0])));
stack.setItemMeta(meta);
} else if (color.length == 3) { // r,g,b
final int red = NumberUtil.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
final int green = NumberUtil.isInt(color[1]) ? Integer.parseInt(color[1]) : 0;
final int blue = NumberUtil.isInt(color[2]) ? Integer.parseInt(color[2]) : 0;

View File

@ -214,7 +214,7 @@ kitOnce=\u00a74You can''t use that kit again.
kitReceive=\u00a76Received kit\u00a7c {0}\u00a76.
kitTimed=\u00a74You can''t use that kit again for another\u00a7c {0}\u00a74.
kits=\u00a76Kits\:\u00a7r {0}
leatherSyntax=\u00a76Leather color syntax\: color\:<red>,<green>,<blue> eg\: color\:255,0,0.
leatherSyntax=\u00a76Leather color syntax\: color\:<red>,<green>,<blue> eg\: color\:255,0,0 OR color\:<rgb int> eg\: color\:16777011
lightningSmited=\u00a76Thou hast been smitten\!
lightningUse=\u00a76Smiting\u00a7c {0}
listAfkTag=\u00a77[AFK]\u00a7r