Java Code Examples for org.bukkit.Material#name()
The following examples show how to use
org.bukkit.Material#name() .
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: ColorChanger.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
public static Material changeMaterialColor(Material material, TeamColor teamColor) { String materialName = material.name(); try { materialName = material.toString().substring(material.toString().indexOf("_") + 1); } catch (StringIndexOutOfBoundsException ignored) { } String teamMaterialColor = teamColor.material1_13; if (Main.autoColoredMaterials.contains(materialName)) { return Material.getMaterial(teamMaterialColor + "_" + materialName); } else if (material.toString().contains("GLASS")) { return Material.getMaterial(teamMaterialColor + "_STAINED_GLASS"); } else if (material.toString().contains("GLASS_PANE")) { return Material.getMaterial(teamMaterialColor + "_STAINED_GLASS_PANE"); } return material; }
Example 2
Source File: ColorChanger.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
public static Material changeMaterialColor(Material material, TeamColor teamColor) { String materialName = material.name(); try { materialName = material.toString().substring(material.toString().indexOf("_") + 1); } catch (StringIndexOutOfBoundsException ignored) { } String teamMaterialColor = teamColor.material1_13; if (Main.autoColoredMaterials.contains(materialName)) { return Material.getMaterial(teamMaterialColor + "_" + materialName); } else if (material.toString().contains("GLASS")) { return Material.getMaterial(teamMaterialColor + "_STAINED_GLASS"); } else if (material.toString().contains("GLASS_PANE")) { return Material.getMaterial(teamMaterialColor + "_STAINED_GLASS_PANE"); } return material; }
Example 3
Source File: DurabilityMaterial.java From ObsidianDestroyer with GNU General Public License v3.0 | 5 votes |
/** * Storage for a tracked material from the config * * @param type the type of material * @param section the configuration section to load */ public DurabilityMaterial(Material type, int typeData, ConfigurationSection section) { this.type = type; this.name = type.name(); this.typeData = typeData; this.blastRadius = section.getInt("BlastRadius", 2); this.destructible = section.getBoolean("Destructible", true); this.bypassFluidProtect = section.getBoolean("BypassFluidProtection", false); this.bypassFactionProtect = section.getBoolean("BypassFactionProtection", false); this.durability = section.getInt("Durability.Amount", 5); this.fluidDamper = section.getDouble("Durability.FluidDamper", 0); this.enabled = section.getBoolean("Durability.Enabled", true); this.chanceToDrop = section.getDouble("Durability.ChanceToDrop", 0.7); this.resetEnabled = section.getBoolean("Durability.ResetEnabled", false); this.resetTime = section.getLong("Durability.ResetAfter", 10000L); this.tntEnabled = section.getBoolean("EnabledFor.TNT", true); this.cannonsEnabled = section.getBoolean("EnabledFor.Cannons", false); this.creepersEnabled = section.getBoolean("EnabledFor.Creepers", false); this.ghastsEnabled = section.getBoolean("EnabledFor.Ghasts", false); this.withersEnabled = section.getBoolean("EnabledFor.Withers", false); this.tntMinecartsEnabled = section.getBoolean("EnabledFor.Minecarts", false); this.nullEnabled = section.getBoolean("EnabledFor.NullDamage", true); this.tntDamage = section.getInt("Damage.TNT", 1); this.cannonImpactDamage = section.getInt("Damage.Cannons", section.getInt("Damage.CannonsImpact", 1)); this.cannonPierceDamage = section.getInt("Damage.CannonsPierce", 1); this.creeperDamage = section.getInt("Damage.Creepers", 1); this.chargedCreeperDamage = section.getInt("Damage.ChargedCreepers", 1); this.ghastDamage = section.getInt("Damage.Ghasts", 1); this.witherDamage = section.getInt("Damage.Withers", 1); this.tntMinecartDamage = section.getInt("Damage.Minecarts", 1); this.nullDamage = section.getInt("Damage.NullDamage", 1); this.enderCrystalEnabled = section.getBoolean("EnabledFor.EnderCrystal", false); this.enderCrystalDamage = section.getInt("Damage.EnderCrystal", 1); this.tallyKittens(); }
Example 4
Source File: ColorChanger.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static ItemStack changeLegacyStackColor(ItemStack itemStack, TeamColor teamColor) { Material material = itemStack.getType(); String materialName = material.name(); if (Main.autoColoredMaterials.contains(materialName)) { itemStack.setDurability((short) teamColor.woolData); } else if (material.toString().contains("GLASS")) { itemStack.setType(Material.getMaterial("STAINED_GLASS")); itemStack.setDurability((short) teamColor.woolData); } else if (material.toString().contains("GLASS_PANE")) { itemStack.setType(Material.getMaterial("STAINED_GLASS_PANE")); itemStack.setDurability((short) teamColor.woolData); } return itemStack; }
Example 5
Source File: TeleportFeature.java From AreaShop with GNU General Public License v3.0 | 5 votes |
/** * Check if a player can spawn next to it. * @param material Material to check (assumed that this is somewhere around the player) * @return true when it is safe to spawn next to, otherwise false */ private static boolean cannotSpawnBeside(Material material) { String name = material.name(); return name.contains("LAVA") || name.contains("CACTUS") || name.equals("FIRE") || name.contains("MAGMA"); }
Example 6
Source File: TeleportFeature.java From AreaShop with GNU General Public License v3.0 | 5 votes |
/** * Check if a player can spawn on here. * @param material Material to check (assumed that this is below the feet) * @return true when it is safe to spawn on top of, otherwise false */ private static boolean cannotSpawnOn(Material material) { String name = material.name(); return name.equals("CACTUS") || name.contains("PISTON") || name.contains("SIGN") || name.contains("DOOR") || name.contains("PLATE") || name.contains("REDSTONE_LAMP") || name.contains("FENCE") || name.contains("GLASS_PANE") || name.contains("THIN_GLASS") || name.equals("DRAGON_EGG") || name.contains("MAGMA"); }
Example 7
Source File: TeleportFeature.java From AreaShop with GNU General Public License v3.0 | 5 votes |
/** * Check if a player can spawn in here. * @param material Material to check (assumed that this is at the feet or head level) * @return true when it is safe to spawn inside, otherwise false */ private static boolean canSpawnIn(Material material) { String name = material.name(); return name.contains("DOOR") || name.contains("SIGN") || name.contains("PLATE") // Redstone plates || name.equals("DRAGON_EGG"); }
Example 8
Source File: XMLUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static Material parseBlockMaterial(Node node, String text) throws InvalidXMLException { Material material = parseMaterial(node, text); if(!material.isBlock()) { throw new InvalidXMLException("Material " + material.name() + " is not a block", node); } return material; }
Example 9
Source File: ColorChanger.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
public static ItemStack changeLegacyStackColor(ItemStack itemStack, TeamColor teamColor) { Material material = itemStack.getType(); String materialName = material.name(); if (Main.autoColoredMaterials.contains(materialName)) { itemStack.setDurability((short) teamColor.woolData); } else if (material.toString().contains("GLASS")) { itemStack.setType(Material.getMaterial("STAINED_GLASS")); itemStack.setDurability((short) teamColor.woolData); } else if (material.toString().contains("GLASS_PANE")) { itemStack.setType(Material.getMaterial("STAINED_GLASS_PANE")); itemStack.setDurability((short) teamColor.woolData); } return itemStack; }
Example 10
Source File: MinecraftTranslations.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
/** * Gets a translated material name. * * <p>Note: is highly inaccurate and is only guaranteed to work with weapons. * * @param material A material. * @return A material name. */ public static Component getMaterial(Material material) { String name = material.name(); for (Map.Entry<Pattern, String> entry : MATERIAL_REPLACEMENTS.entrySet()) { name = entry.getKey().matcher(name).replaceAll(entry.getValue()); } return getKey(MATERIAL_KEY, StringUtils.camelCase(name, true)); }
Example 11
Source File: BlockFromToListener.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
public boolean isSurroundedByWater(Location location) { final World world = location.getWorld(); if (world == null) return false; final int x = location.getBlockX(); final int y = location.getBlockY(); final int z = location.getBlockZ(); final int[][] coords = { // At the same elevation {x + 1, y, z}, {x - 1, y, z}, {x, y, z + 1}, {x, y, z - 1}, // Above {x + 1, y + 1, z}, {x - 1, y + 1, z}, {x, y + 1, z + 1}, {x, y + 1, z - 1}, // Below {x + 1, y - 1, z}, {x - 1, y - 1, z}, {x, y - 1, z + 1}, {x, y - 1, z - 1} }; for (int[] coord : coords) { final Block block = world.getBlockAt(coord[0], coord[1], coord[2]); final Material material = block.getType(); final String name = material.name(); if (name.contains("WATER")) return true; } return false; }
Example 12
Source File: MaterialIs.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public void validate(Material material, @Nullable Node node) throws InvalidXMLException { if(!material.isBlock()) { throw new InvalidXMLException("Material " + material.name() + " is not a block", node); } }
Example 13
Source File: MaterialFlag.java From WorldGuardExtraFlagsPlugin with MIT License | 4 votes |
@Override public Object marshal(Material o) { return o.name(); }
Example 14
Source File: LanguageHelper.java From LanguageUtils with MIT License | 4 votes |
public static String getItemUnlocalizedName(Material material, int meta) { EnumItem enumItem = EnumItem.get(ItemEntry.from(material, meta)); return enumItem != null ? enumItem.getUnlocalizedName() : material.name(); }
Example 15
Source File: TestUtilities.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
public static VanillaItem mockVanillaItem(Plugin plugin, Material type, boolean enabled) { Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test Category")); VanillaItem item = new VanillaItem(category, new ItemStack(type), type.name(), RecipeType.NULL, new ItemStack[9]); SlimefunPlugin.getItemCfg().setValue(type.name() + ".enabled", enabled); return item; }
Example 16
Source File: XBlock.java From XSeries with MIT License | 4 votes |
public static boolean isWater(Material material) { String name = material.name(); return name.equals("WATER") || name.equals("STATIONARY_WATER"); }
Example 17
Source File: XBlock.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
public static boolean isWater(Material material) { String name = material.name(); return name.equals("WATER") || name.equals("STATIONARY_WATER"); }