From 77d474fb0304c9036afd4a0afaa5800add6d1412 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 10 Jun 2016 17:37:19 +0200 Subject: [PATCH] Fix Item Names for Heads and Colored Banners --- .../epiceric/shopchest/utils/ColorNames.java | 33 +++++++++++++++++++ .../epiceric/shopchest/utils/ItemNames.java | 12 +++---- 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 src/de/epiceric/shopchest/utils/ColorNames.java diff --git a/src/de/epiceric/shopchest/utils/ColorNames.java b/src/de/epiceric/shopchest/utils/ColorNames.java new file mode 100644 index 0000000..2fdb2d7 --- /dev/null +++ b/src/de/epiceric/shopchest/utils/ColorNames.java @@ -0,0 +1,33 @@ +package de.epiceric.shopchest.utils; + +import com.google.common.collect.ImmutableMap; +import org.bukkit.DyeColor; + +import java.util.Map; + +public class ColorNames { + + private static final Map map = ImmutableMap.builder() + .put(DyeColor.BLACK, "Black") + .put(DyeColor.BLUE, "Blue") + .put(DyeColor.BROWN, "Brown") + .put(DyeColor.CYAN, "Cyan") + .put(DyeColor.GRAY, "Light Gray") + .put(DyeColor.GREEN, "Green") + .put(DyeColor.LIGHT_BLUE, "Light Blue") + .put(DyeColor.LIME, "Lime") + .put(DyeColor.MAGENTA, "Magenta") + .put(DyeColor.ORANGE, "Orange") + .put(DyeColor.PINK, "Pink") + .put(DyeColor.PURPLE, "Purple") + .put(DyeColor.RED, "Red") + .put(DyeColor.SILVER, "Gray") + .put(DyeColor.WHITE, "White") + .put(DyeColor.YELLOW, "Yellow") + .build(); + + public static String getColorString(DyeColor dyeColor) { + return map.get(dyeColor); + } + +} diff --git a/src/de/epiceric/shopchest/utils/ItemNames.java b/src/de/epiceric/shopchest/utils/ItemNames.java index 097efb2..b83734a 100644 --- a/src/de/epiceric/shopchest/utils/ItemNames.java +++ b/src/de/epiceric/shopchest/utils/ItemNames.java @@ -1,7 +1,6 @@ package de.epiceric.shopchest.utils; import com.google.common.collect.ImmutableMap; -import org.apache.commons.lang.WordUtils; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -572,8 +571,9 @@ public class ItemNames { .put("397:0", "Skeleton Skull") .put("397:1", "Wither Skeleton Skull") .put("397:2", "Zombie Head") - .put("373:3", "Head") - .put("373:4", "Creeper Head") + .put("397:3", "Head") + .put("397:4", "Creeper Head") + .put("397:5", "Dragon Head") .put("398", "Carrot on a Stick") .put("399", "Nether Star") .put("400", "Pumpkin Pie") @@ -654,13 +654,13 @@ public class ItemNames { if ((mat == Material.WOOL || mat == Material.CARPET) && stack.getDurability() == 0) { // special case: white wool/carpet is just called "Wool" or "Carpet" result = map.get(key); - } else if (mat == Material.WOOL || mat == Material.CARPET || mat == Material.STAINED_CLAY || mat == Material.STAINED_GLASS || mat == Material.STAINED_GLASS_PANE) { + } else if (mat == Material.WOOL || mat == Material.CARPET || mat == Material.STAINED_CLAY || mat == Material.STAINED_GLASS || mat == Material.STAINED_GLASS_PANE || mat == Material.BANNER) { DyeColor dc = DyeColor.getByWoolData((byte) stack.getDurability()); - result = dc == null ? map.get(key) : WordUtils.capitalizeFully(dc.toString().replace("_", " ")) + " " + map.get(key); + result = dc == null ? map.get(key) : ColorNames.getColorString(dc) + " " + map.get(key); } else if (mat == Material.LEATHER_HELMET || mat == Material.LEATHER_CHESTPLATE || mat == Material.LEATHER_LEGGINGS || mat == Material.LEATHER_BOOTS) { LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) stack.getItemMeta(); DyeColor dc = DyeColor.getByColor(leatherArmorMeta.getColor()); - result = dc == null ? map.get(key) : WordUtils.capitalizeFully(dc.toString()).replace("_", " ") + " " + map.get(key); + result = dc == null ? map.get(key) : ColorNames.getColorString(dc) + " " + map.get(key); } else if (stack.getDurability() != 0) { result = map.get(key + ":" + stack.getDurability()); if (result == null) {