Permalink
Browse files

BREAKING CHANGE: Change SILVER to LIGHT_GRAY for consistency.

Banner meta for items will be automatically converted, but hard-coded strings of 'SILVER' should be replaced with 'LIGHT_GRAY' when setting sheep, shulker, or wolf collar colors.
  • Loading branch information...
PseudoKnight committed Aug 9, 2018
1 parent a81a659 commit 81c86b9d9824415ade4744d078c67dbd846b321e
@@ -12,7 +12,7 @@
LIME,
PINK,
GRAY,
SILVER,
LIGHT_GRAY,
CYAN,
PURPLE,
BLUE,
@@ -21,20 +21,4 @@
}
return instance;
}
@Override
protected MCDyeColor getAbstractedEnumCustom(DyeColor concrete) {
if(concrete.equals(DyeColor.LIGHT_GRAY)) {
return MCDyeColor.SILVER;
}
return super.getAbstractedEnumCustom(concrete);
}
@Override
protected DyeColor getConcreteEnumCustom(MCDyeColor abstracted) {
if(abstracted.equals(MCDyeColor.SILVER)) {
return DyeColor.LIGHT_GRAY;
}
return super.getConcreteEnumCustom(abstracted);
}
}
@@ -424,10 +424,6 @@ public Construct itemMeta(MCItemStack is, Target t) {
patterns.push(pattern, t);
}
ma.set("patterns", patterns, t);
MCDyeColor dyeColor = banner.getBaseColor();
if(dyeColor != null) {
ma.set("basecolor", new CString(dyeColor.toString(), t), t);
}
} else if(bs instanceof MCCreatureSpawner) {
MCCreatureSpawner mccs = (MCCreatureSpawner) bs;
ma.set("spawntype", mccs.getSpawnedType().name());
@@ -680,16 +676,23 @@ public MCItemMeta itemMeta(Construct c, MCMaterial mat, Target t) throws ConfigR
}
} else if(bs instanceof MCBanner) {
MCBanner banner = (MCBanner) bs;
if(ma.containsKey("basecolor")) {
banner.setBaseColor(MCDyeColor.valueOf(ma.get("basecolor", t).val().toUpperCase()));
}
if(ma.containsKey("patterns")) {
CArray array = ArgumentValidation.getArray(ma.get("patterns", t), t);
for(String key : array.stringKeySet()) {
CArray pattern = ArgumentValidation.getArray(array.get(key, t), t);
MCPatternShape shape = MCPatternShape.valueOf(pattern.get("shape", t).val().toUpperCase());
MCDyeColor color = MCDyeColor.valueOf(pattern.get("color", t).val().toUpperCase());
banner.addPattern(StaticLayer.GetConvertor().GetPattern(color, shape));
String color = pattern.get("color", t).val().toUpperCase();
try {
MCDyeColor dyecolor = MCDyeColor.valueOf(color);
banner.addPattern(StaticLayer.GetConvertor().GetPattern(dyecolor, shape));
} catch (IllegalArgumentException ex) {
if(color.equals("SILVER")) {
// convert old DyeColor
banner.addPattern(StaticLayer.GetConvertor().GetPattern(MCDyeColor.LIGHT_GRAY, shape));
} else {
throw ex;
}
}
}
}
banner.update();

0 comments on commit 81c86b9

Please sign in to comment.