diff --git a/HolographicDisplays/plugin.yml b/HolographicDisplays/plugin.yml index a7c4bba7..88062df6 100644 --- a/HolographicDisplays/plugin.yml +++ b/HolographicDisplays/plugin.yml @@ -1,6 +1,6 @@ name: HolographicDisplays main: com.gmail.filoghost.holograms.HolographicDisplays -version: 1.8.7 +version: 1.8.8 softdepend: [Multiverse-Core, MultiWorld, My Worlds, My_Worlds, ProtocolLib] diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/utils/ItemUtils.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/utils/ItemUtils.java index 023492bf..e97d66b2 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/utils/ItemUtils.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/utils/ItemUtils.java @@ -3,6 +3,7 @@ package com.gmail.filoghost.holograms.utils; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.regex.Pattern; import org.bukkit.ChatColor; @@ -10,9 +11,85 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import com.google.common.collect.Maps; + public class ItemUtils { public static final String ANTISTACK_LORE = ChatColor.BLACK + "" + Math.random(); + + // A map with formatter materials (lowercase and without dashes) for fast access. + private static Map materialMap = new HashMap(); + + private static Pattern stripSymbolsPattern = Pattern.compile("[_ \\-]+"); + + static { + // Default material names are ugly. + Map tempMap = Maps.newHashMap(); + + tempMap.put("iron bar", Material.IRON_FENCE); + tempMap.put("iron bars", Material.IRON_FENCE); + tempMap.put("glass pane", Material.THIN_GLASS); + tempMap.put("nether wart", Material.NETHER_STALK); + tempMap.put("nether warts", Material.NETHER_STALK); + tempMap.put("slab", Material.STEP); + tempMap.put("double slab", Material.DOUBLE_STEP); + tempMap.put("stone brick", Material.SMOOTH_BRICK); + tempMap.put("stone bricks", Material.SMOOTH_BRICK); + tempMap.put("stone stair", Material.SMOOTH_STAIRS); + tempMap.put("stone stairs", Material.SMOOTH_STAIRS); + tempMap.put("potato", Material.POTATO_ITEM); + tempMap.put("carrot", Material.CARROT_ITEM); + tempMap.put("brewing stand", Material.BREWING_STAND_ITEM); + tempMap.put("cauldron", Material.CAULDRON_ITEM); + tempMap.put("carrot on stick", Material.CARROT_STICK); + tempMap.put("carrot on a stick", Material.CARROT_STICK); + tempMap.put("cobblestone wall", Material.COBBLE_WALL); + tempMap.put("wood slab", Material.WOOD_STEP); + tempMap.put("double wood slab", Material.WOOD_DOUBLE_STEP); + tempMap.put("repeater", Material.DIODE); + tempMap.put("piston", Material.PISTON_BASE); + tempMap.put("sticky piston", Material.PISTON_STICKY_BASE); + tempMap.put("flower pot", Material.FLOWER_POT_ITEM); + tempMap.put("wood showel", Material.WOOD_SPADE); + tempMap.put("stone showel", Material.STONE_SPADE); + tempMap.put("gold showel", Material.GOLD_SPADE); + tempMap.put("iron showel", Material.IRON_SPADE); + tempMap.put("diamond showel", Material.DIAMOND_SPADE); + tempMap.put("steak", Material.COOKED_BEEF); + tempMap.put("cooked porkchop", Material.GRILLED_PORK); + tempMap.put("raw porkchop", Material.PORK); + tempMap.put("hardened clay", Material.HARD_CLAY); + tempMap.put("huge brown mushroom", Material.HUGE_MUSHROOM_1); + tempMap.put("huge red mushroom", Material.HUGE_MUSHROOM_2); + tempMap.put("mycelium", Material.MYCEL); + tempMap.put("poppy", Material.RED_ROSE); + tempMap.put("comparator", Material.REDSTONE_COMPARATOR); + tempMap.put("skull", Material.SKULL_ITEM); + tempMap.put("head", Material.SKULL_ITEM); + tempMap.put("redstone torch", Material.REDSTONE_TORCH_ON); + tempMap.put("redstone lamp", Material.REDSTONE_LAMP_OFF); + tempMap.put("glistering melon", Material.SPECKLED_MELON); + tempMap.put("gunpowder", Material.SULPHUR); + tempMap.put("lilypad", Material.WATER_LILY); + tempMap.put("command block", Material.COMMAND); + + for (Entry tempEntry : tempMap.entrySet()) { + materialMap.put(stripSpacingChars(tempEntry.getKey()).toLowerCase(), tempEntry.getValue()); + } + + for (Material mat : Material.values()) { + materialMap.put(stripSpacingChars(mat.toString()).toLowerCase(), mat); + } + } + + public static String stripSpacingChars(String input) { + return stripSymbolsPattern.matcher(input).replaceAll(""); + } + + public static Material matchMaterial(String input) { + return materialMap.get(stripSpacingChars(input).toLowerCase()); + } + public static ItemStack getStone(String title, List lore, ChatColor defaultLoreColor) { return getItem(Material.STONE, title, lore, defaultLoreColor); @@ -41,25 +118,8 @@ public class ItemUtils { return item; } - // A map with formatter materials (lowercase and without dashes) for fast access. - private static Map materialMap = new HashMap(); - private static Pattern stripSymbolsPattern = Pattern.compile("[_ \\-]+"); - - static { - for (Material mat : Material.values()) { - materialMap.put(stripSpacingChars(mat.toString()).toLowerCase(), mat); - } - } - - public static String stripSpacingChars(String input) { - return stripSymbolsPattern.matcher(input).replaceAll(""); - } - - public static Material matchMaterial(String input) { - return materialMap.get(stripSpacingChars(input).toLowerCase()); - } - @SuppressWarnings("deprecation") + // Blocks are smalled than items... public static boolean appearsAsBlock(Material mat) { switch (mat.getId()) { case 1: