Java Code Examples for org.bukkit.Material#toString()
The following examples show how to use
org.bukkit.Material#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Tools.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean isApplicationCorrect(Application app, Material matToApplyTo) { String mat = matToApplyTo.toString(); if (app == Application.BOW && mat.equals(Material.BOW.toString())) return true; else if (app == Application.BOOTS && mat.endsWith("BOOTS")) return true; else if (app == Application.HELMET && mat.endsWith("HELMET")) return true; else if (app == Application.ARMOR && (mat.endsWith("HELMET") || mat.endsWith("CHESTPLATE") || mat.endsWith("LEGGINGS") || mat.endsWith("BOOTS"))) return true; else if (app == Application.TOOL && (mat.endsWith("PICKAXE") || mat.endsWith("SPADE") || mat.endsWith("AXE") || mat.endsWith("HOE"))) return true; return false; }
Example 2
Source File: Tools.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
public static Application getApplicationByMaterial(Material material) { String mat = material.toString(); if (mat.equals(Material.BOW.toString())) return Application.BOW; else if (mat.endsWith("BOOTS")) return Application.BOOTS; else if (mat.endsWith("HELMET")) return Application.HELMET; else if (mat.endsWith("BOOTS") || mat.endsWith("LEGGINGS") || mat.endsWith("CHESTPLATE") || mat.endsWith("HELMET")) return Application.ARMOR; else if (mat.endsWith("PICKAXE") || mat.endsWith("SPADE") || mat.endsWith("AXE") || mat.endsWith("HOE")) return Application.TOOL; return Application.GLOBAL; }
Example 3
Source File: LWC.java From Modern-LWC with MIT License | 5 votes |
@SuppressWarnings("deprecation") public String resolveProtectionConfiguration(BlockState state, String node) { Material material = state.getType(); String cacheKey = state.getRawData() + "-" + material.toString() + "-" + node; if (protectionConfigurationCache.containsKey(cacheKey)) { return protectionConfigurationCache.get(cacheKey); } List<String> names = new ArrayList<String>(); String materialName = normalizeMaterialName(material); // add the name & the block id names.add(materialName); names.add(materialName + ":" + state.getRawData()); // add both upper and lower material name names.add(material.toString()); names.add(material.toString().toLowerCase()); // Add the wildcards last so it can be overriden names.add("*"); if (materialName.contains("_")) { // Prefix wildcarding for shulker boxes & gates names.add("*_" + materialName.substring(materialName.indexOf("_") + 1)); } String value = configuration.getString("protections." + node); for (String name : names) { String temp = configuration.getString("protections.blocks." + name + "." + node); if (temp != null && !temp.isEmpty()) { value = temp; } } protectionConfigurationCache.put(cacheKey, value); return value; }
Example 4
Source File: LWC.java From Modern-LWC with MIT License | 5 votes |
/** * Get the appropriate config value for the block (protections.block.node) * * @param material * @param node * @return */ public String resolveProtectionConfiguration(Material material, String node) { if (material == null) { return null; } String cacheKey = "00-" + material.toString() + "-" + node; if (protectionConfigurationCache.containsKey(cacheKey)) { return protectionConfigurationCache.get(cacheKey); } List<String> names = new ArrayList<>(); String materialName = normalizeMaterialName(material); // add the name & the block id names.add(materialName); // add both upper and lower material name names.add(material.toString()); names.add(material.toString().toLowerCase()); // Add the wildcards last so it can be overriden names.add("*"); String value = configuration.getString("protections." + node); for (String name : names) { String temp = configuration.getString("protections.blocks." + name + "." + node); if (temp != null && !temp.isEmpty()) { value = temp; } } protectionConfigurationCache.put(cacheKey, value); return value; }
Example 5
Source File: DataFile.java From AdditionsAPI with MIT License | 5 votes |
/** * Get a durability value that does not use a texture for the specified * Material. If there are no more durability points left, an error will be * printed. * * @param material * The Material for which you want a free durability point. * @return The durability value that is available for the specified Material. */ public short getFreeDurability(Material material) { String m = material.toString(); List<Short> durabilitiesUsed = new ArrayList<Short>(); for (String string : items) { String[] line = string.split(";"); if (line[0].equals(m)) { durabilitiesUsed.add(Short.valueOf(line[1])); } } Debug.saySuper("Included in durabilities used:"); for (Short s : durabilitiesUsed) Debug.saySuper(s.toString()); if (durabilitiesUsed.isEmpty()) { Debug.saySuper("No Durabilities Used for Material: " + material); return material.getMaxDurability(); } else { if (material.getMaxDurability() != 0) { short durability = material.getMaxDurability(); while (durabilitiesUsed.contains(durability)) durability--; Debug.saySuper("Available Durability for Material " + material + ": " + durability); if (durability <= 0) { Debug.sayError("***********************"); Debug.sayError("TEXTURE LIMIT REACHED FOR MATERIAL: " + material); Debug.sayError("REMOVE ANY CUSTOM ITEMS FROM THE DATA.YML FILE THAT ARE FROM REMOVED PLUGINS!"); Debug.sayError("***********************"); return (short) (material.getMaxDurability() + 1); } else { return durability; } } else { Debug.saySuper("Returning default durability for Material: " + material); return material.getMaxDurability(); } } }
Example 6
Source File: ItemReader.java From Survival-Games with GNU General Public License v3.0 | 5 votes |
public static String getFriendlyItemName(Material m){ String str = m.toString(); str = str.replace('_',' '); str = str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); return str; }
Example 7
Source File: MaterialUtils.java From FunnyGuilds with Apache License 2.0 | 5 votes |
public static boolean hasGravity(Material material) { switch (material.toString()) { case "DRAGON_EGG": case "SAND": case "GRAVEL": case "ANVIL": case "CONCRETE_POWDER": return true; default: return false; } }
Example 8
Source File: MaterialUtils.java From FunnyGuilds with Apache License 2.0 | 5 votes |
public static String getMaterialName(Material material) { PluginConfiguration config = FunnyGuilds.getInstance().getPluginConfiguration(); if (!config.translatedMaterialsEnable) { return material.toString(); } if (config.translatedMaterials.containsKey(material)) { return ChatUtils.colored(FunnyGuilds.getInstance().getPluginConfiguration().translatedMaterials.get(material)); } return StringUtils.replaceChars(material.toString().toLowerCase(), '_', ' '); }
Example 9
Source File: LWC.java From Modern-LWC with MIT License | 4 votes |
/** * Get the appropriate config value for the block (protections.block.node) * * @param block * @param node * @return */ @SuppressWarnings("deprecation") public String resolveProtectionConfiguration(Block block, String node) { Material material = block.getType(); if (material == null) { return null; } String cacheKey = block.getData() + "-" + material.toString() + "-" + node; if (protectionConfigurationCache.containsKey(cacheKey)) { return protectionConfigurationCache.get(cacheKey); } List<String> names = new ArrayList<>(); String materialName = normalizeMaterialName(material); // add the name & the block id names.add(materialName); names.add(materialName + ":" + block.getData()); // add both upper and lower material name names.add(material.toString()); names.add(material.toString().toLowerCase()); // Add the wildcards last so it can be overriden names.add("*"); if (materialName.contains("_")) { // Prefix wildcarding for shulker boxes & gates names.add("*_" + materialName.substring(materialName.indexOf("_") + 1)); } String value = configuration.getString("protections." + node); for (String name : names) { String temp = configuration.getString("protections.blocks." + name + "." + node); if (temp != null && !temp.isEmpty()) { value = temp; } } protectionConfigurationCache.put(cacheKey, value); return value; }
Example 10
Source File: CustomGunItem.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
public String getIngString(Material m, int durability, int amount) { return m.toString() + "," + durability + "," + amount; }
Example 11
Source File: CustomGunItem.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
public String getIngString(Material m, int durability, int amount) { return m.toString() + "," + durability + "," + amount; }
Example 12
Source File: CustomGunItem.java From QualityArmory with GNU General Public License v3.0 | 4 votes |
public String getIngString(Material m, int durability, int amount) { return m.toString() + "," + durability + "," + amount; }
Example 13
Source File: DataFile.java From AdditionsAPI with MIT License | 3 votes |
/** * Obtains a {@link StorageCustomItem} with the specified values. If the * {@link StorageCustomItem} does not exist, it will return null. * * @param material * The Material of the {@link StorageCustomItem}. * @param durability * The durability of the {@link StorageCustomItem} * @return The {@link StorageCustomItem} with the above values, as well as its * ID Name and Texture Name. */ public StorageCustomItem getCustomItem(Material material, short durability) { String m = material.toString(); String d = Short.toString(durability); for (String string : items) { String[] line = string.split(";"); if (line[0].equals(m) && line[1].equals(d)) return new StorageCustomItem(material, durability, line[2], line[3]); } return null; }