mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-13 22:21:06 +00:00
Fix Item Names for Heads and Colored Banners
This commit is contained in:
parent
b313f4ae80
commit
77d474fb03
33
src/de/epiceric/shopchest/utils/ColorNames.java
Normal file
33
src/de/epiceric/shopchest/utils/ColorNames.java
Normal file
@ -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<DyeColor, String> map = ImmutableMap.<DyeColor, String>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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package de.epiceric.shopchest.utils;
|
package de.epiceric.shopchest.utils;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.apache.commons.lang.WordUtils;
|
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -572,8 +571,9 @@ public class ItemNames {
|
|||||||
.put("397:0", "Skeleton Skull")
|
.put("397:0", "Skeleton Skull")
|
||||||
.put("397:1", "Wither Skeleton Skull")
|
.put("397:1", "Wither Skeleton Skull")
|
||||||
.put("397:2", "Zombie Head")
|
.put("397:2", "Zombie Head")
|
||||||
.put("373:3", "Head")
|
.put("397:3", "Head")
|
||||||
.put("373:4", "Creeper Head")
|
.put("397:4", "Creeper Head")
|
||||||
|
.put("397:5", "Dragon Head")
|
||||||
.put("398", "Carrot on a Stick")
|
.put("398", "Carrot on a Stick")
|
||||||
.put("399", "Nether Star")
|
.put("399", "Nether Star")
|
||||||
.put("400", "Pumpkin Pie")
|
.put("400", "Pumpkin Pie")
|
||||||
@ -654,13 +654,13 @@ public class ItemNames {
|
|||||||
if ((mat == Material.WOOL || mat == Material.CARPET) && stack.getDurability() == 0) {
|
if ((mat == Material.WOOL || mat == Material.CARPET) && stack.getDurability() == 0) {
|
||||||
// special case: white wool/carpet is just called "Wool" or "Carpet"
|
// special case: white wool/carpet is just called "Wool" or "Carpet"
|
||||||
result = map.get(key);
|
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());
|
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) {
|
} else if (mat == Material.LEATHER_HELMET || mat == Material.LEATHER_CHESTPLATE || mat == Material.LEATHER_LEGGINGS || mat == Material.LEATHER_BOOTS) {
|
||||||
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) stack.getItemMeta();
|
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) stack.getItemMeta();
|
||||||
DyeColor dc = DyeColor.getByColor(leatherArmorMeta.getColor());
|
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) {
|
} else if (stack.getDurability() != 0) {
|
||||||
result = map.get(key + ":" + stack.getDurability());
|
result = map.get(key + ":" + stack.getDurability());
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user