/** * Checks equality between a WorldEdit BlockType and a Bukkit Material * * @param blockType The WorldEdit BlockType * @param type The Bukkit Material * @return If they are equal */ public static boolean equals(BlockType blockType, Material type) { return Objects.equals(blockType.getId(), type.getKey().toString()); }
/** * Converts a Material to a BlockType * * @param material The material * @return The blocktype */ public static BlockType asBlockType(Material material) { checkNotNull(material); if (!material.isBlock()) { throw new IllegalArgumentException(material.getKey().toString() + " is not a block!"); } return BlockTypes.get(material.getKey().toString()); }
/** * Converts a Material to a ItemType * * @param material The material * @return The itemtype */ public static ItemType asItemType(Material material) { checkNotNull(material); if (!material.isItem()) { throw new IllegalArgumentException(material.getKey().toString() + " is not an item!"); } return ItemTypes.get(material.getKey().toString()); }
/** * Create a WorldEdit BaseItemStack from a Bukkit ItemStack * * @param itemStack The Bukkit ItemStack * @return The WorldEdit BaseItemStack */ public static BaseItemStack adapt(ItemStack itemStack) { checkNotNull(itemStack); return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount()); }
jsonString += "\"" + material.getKey().toString() + "\""; } else if (MyPetApi.getCompatUtil().isCompatible("1.8")) { jsonString += material.name().toLowerCase();
@Override public String fixHoverShowItem(ProtocolVersion version, String locale, String json) { try { NBTTagCompound compound = MojangsonParser.parse(json); Material material = ItemMaterialLookup.getByKey(compound.getString("id")); if (material != null) { int materialRuntimeId = LegacyItemType.REGISTRY.getTable(version).getRemap(ItemMaterialLookup.getRuntimeId(material)); if (version.isBefore(ProtocolVersion.MINECRAFT_1_8)) { compound.setInt("id", PreFlatteningItemIdData.getIdFromLegacyCombinedId(PreFlatteningItemIdData.getLegacyCombinedIdByModernId(materialRuntimeId))); } else { compound.setString("id", ItemMaterialLookup.getByRuntimeId(materialRuntimeId).getKey().toString()); } } return compound.toString(); } catch (CommandSyntaxException e) { throw new RuntimeException(e); } }
if (item != null && item.getType().getKey().toString().equals(wcfg.regionWand) && plugin.hasPermission(player, "worldguard.region.wand")) { if (set.size() > 0) { player.sendMessage(ChatColor.YELLOW + "Can you build? " + (set.testState(localPlayer, Flags.BUILD) ? "Yes" : "No"));
public static void saveItem(DataKey key, ItemStack item) { if (item == null) { item = new ItemStack(Material.AIR); } migrateForSave(key); if (SpigotUtil.isUsing1_13API()) { key.setString("type_namespace", item.getType().getKey().getNamespace()); key.setString("type_key", item.getType().getKey().getKey()); } else { key.setString("type", item.getType().name()); } key.setInt("amount", item.getAmount()); key.setInt("durability", item.getDurability()); if (item.getData() != null) { key.setInt("mdata", item.getData().getData()); } if (item.hasItemMeta()) { ItemMeta meta = item.getItemMeta(); serialiseMeta(key.getRelative("meta"), meta); } else { key.removeKey("meta"); } serialiseEnchantments(key.getRelative("enchantments"), item.getEnchantments()); }