mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-07 03:09:52 +01:00
Better material names.
This commit is contained in:
parent
0f3147f11d
commit
7cebf8d7fc
@ -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]
|
||||
|
||||
|
@ -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,10 +11,86 @@ 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<String, Material> materialMap = new HashMap<String, Material>();
|
||||
|
||||
private static Pattern stripSymbolsPattern = Pattern.compile("[_ \\-]+");
|
||||
|
||||
static {
|
||||
// Default material names are ugly.
|
||||
Map<String, Material> 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<String, Material> 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<String> 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<String, Material> materialMap = new HashMap<String, Material>();
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user