public static ItemStack setSkullURLAndName(ItemStack itemStack, URL url, String ownerName, UUID id) { try { itemStack = makeReal(itemStack); Object skullOwner = createNode(itemStack, "SkullOwner"); setMeta(skullOwner, "Name", ownerName); setSkullURL(itemStack, url, id); } catch (Exception ex) { ex.printStackTrace(); } return itemStack; }
public static String describeProperty(Object property) { return describeProperty(property, 0); }
public static boolean configureSkillItem(ItemStack skillItem, String skillClass, ConfigurationSection skillConfig) { if (skillItem == null) return false; Object handle = getHandle(skillItem); if (handle == null) return false; Object tag = getTag(handle); if (tag == null) return false; setMetaBoolean(tag, "skill", true); if (skillConfig == null) { return true; } if (skillConfig.getBoolean("undroppable", false)) { setMetaBoolean(tag, "undroppable", true); } if (skillConfig.getBoolean("keep", false)) { setMetaBoolean(tag, "keep", true); } boolean quickCast = skillConfig.getBoolean("quick_cast", true); if (skillClass != null || !quickCast) { Object spellNode = InventoryUtils.getNode(skillItem, "spell"); if (spellNode != null) { if (skillClass != null) { InventoryUtils.setMeta(spellNode, "class", skillClass); } if (!quickCast) { InventoryUtils.setMetaBoolean(spellNode, "quick_cast", false); } } } return true; }
public static boolean saveTagsToItem(ConfigurationSection tags, ItemStack item) { Object handle = getHandle(item); if (handle == null) return false; Object tag = getTag(handle); if (tag == null) return false; return saveTagsToNBT(tags, tag, null); }
public static boolean isBound(ItemStack item) { Object wandSection = InventoryUtils.getNode(item, WAND_KEY); if (wandSection == null) return false; String boundValue = InventoryUtils.getMetaString(wandSection, "owner_id"); return boundValue != null; }
public static boolean isQuickCastSkill(ItemStack item) { if (InventoryUtils.isEmpty(item)) return false; Object spellNode = InventoryUtils.getNode(item, "spell"); if (spellNode == null) return false; Boolean quickCast = InventoryUtils.containsNode(spellNode, "quick_cast") ? InventoryUtils.getMetaBoolean(spellNode, "quick_cast") : null; return quickCast == null ? true : quickCast; }
@Nullable public static String getSpell(ItemStack item) { if (InventoryUtils.isEmpty(item)) return null; Object spellNode = InventoryUtils.getNode(item, "spell"); if (spellNode == null) return null; return InventoryUtils.getMetaString(spellNode, "key"); }
InventoryUtils.wrapText(description, lore); showConfirmation = false; String unlockedMessage = getMessage("unlocked_lore"); InventoryUtils.wrapText(unlockedMessage, lore); unavailableMessage = check.message; if (unavailableMessage != null && !unavailableMessage.isEmpty()) { InventoryUtils.wrapText(check.message, lore); String costHeading = getMessage("cost_heading"); if (!costHeading.isEmpty()) { InventoryUtils.wrapText(costHeading, lore); InventoryUtils.wrapText(costDescription, lore); String lockedMessage = getMessage("locked"); if (!lockedMessage.isEmpty()) { InventoryUtils.wrapText(lockedMessage, lore); if (unavailableMessage == null) { unavailableMessage = lockedMessage; String costHeading = getMessage("earn_heading"); if (!costHeading.isEmpty()) { InventoryUtils.wrapText(costHeading, lore); for (Cost earn : earns) { earnString = earnString.replace("$earn", earn.getFullDescription(context.getController().getMessages(), reducer)); InventoryUtils.wrapText(earnString, lore);
continue; ItemStack item = InventoryUtils.getCopy(shopItem.getItem()); if (item == null) continue; InventoryUtils.wrapText(costHeading, lore); item = InventoryUtils.makeReal(item); InventoryUtils.setMeta(item, "shop", Integer.toString(currentSlot)); if (showConfirmation) { InventoryUtils.setMeta(item, "confirm", "true");
String spellKey = magicItemKey.substring(6); itemStack = Wand.createSpellItem(spellKey, this, mage, null, false); InventoryUtils.setMeta(itemStack, "skill", "true"); if (callback != null) { callback.updated(itemStack); InventoryUtils.setMeta(itemStack, "sp", spAmount); } else if (magicItemKey.startsWith("spell:")) { InventoryUtils.makeUnbreakable(itemStack); Object currencyNode = InventoryUtils.createNode(itemStack, "currency"); InventoryUtils.setMetaInt(currencyNode, "amount", intAmount); InventoryUtils.setMeta(currencyNode, "type", costKey);
InventoryUtils.wrapText(waypoint.description, lore); meta.setLore(lore); waypointItem = InventoryUtils.makeReal(waypointItem); InventoryUtils.hideFlags(waypointItem, (byte)63); InventoryUtils.setMeta(waypointItem, "waypoint", "true"); CompatibilityUtils.makeUnbreakable(waypointItem); displayInventory.setItem(index, waypointItem);
@Nullable @Override public Object getWandProperty(ItemStack item, String key) { Preconditions.checkNotNull(key, "key"); if (InventoryUtils.isEmpty(item)) return null; Object wandNode = InventoryUtils.getNode(item, Wand.WAND_KEY); if (wandNode == null) return null; Object value = InventoryUtils.getMetaObject(wandNode, key); if (value == null) { WandTemplate template = getWandTemplate(InventoryUtils.getMetaString(wandNode, "template")); if (template != null) { value = template.getProperty(key); } } return value; }
@Override public void saveState() { // Make sure we're on the current item instance if (findItem()) { updateItemIcon(); updateName(); updateLore(); } if (item == null || item.getType() == Material.AIR) return; // Check for upgrades that still have wand data if (isUpgrade && isWand(item)) { InventoryUtils.removeMeta(item, WAND_KEY); } Object wandNode = InventoryUtils.createNode(item, isUpgrade ? UPGRADE_KEY : WAND_KEY); if (wandNode == null) { controller.getLogger().warning("Failed to save wand state for wand to : " + item); } else { InventoryUtils.saveTagsToNBT(getConfiguration(), wandNode); } }
public static boolean isSP(ItemStack item) { return InventoryUtils.hasMeta(item, "sp"); }
ItemStack item = event.getCurrentItem(); Mage mage = context.getMage(); if (item == null || !InventoryUtils.hasMeta(item, "shop")) { if (!autoClose) { mage.deactivateGUI(); int slotIndex = Integer.parseInt(InventoryUtils.getMetaString(item, "shop")); MageController controller = context.getController(); Wand wand = mage.getActiveWand(); return; String unpurchasableMessage = InventoryUtils.getMetaString(shopItem.getItem(), "unpurchasable"); if (unpurchasableMessage != null && !unpurchasableMessage.isEmpty()) { context.showMessage(unpurchasableMessage); } else { String itemName = formatItemAmount(controller, item, item.getAmount()); if (InventoryUtils.hasMeta(item, "confirm")) { String inventoryTitle = context.getMessage("confirm_title", getDefaultMessage(context, "confirm_title")).replace("$item", itemName); Inventory confirmInventory = CompatibilityUtils.createInventory(null, 9, inventoryTitle); InventoryUtils.removeMeta(item, "confirm"); for (int i = 0; i < 9; i++) ItemStack copy = InventoryUtils.getCopy(item); if (filterBound && com.elmakers.mine.bukkit.wand.Wand.isBound(copy)) { Wand bindWand = controller.getWand(copy);
InventoryUtils.applyAttributes(item, getConfigurationSection("item_attributes"), getString("item_attribute_slot", getString("attribute_slot"))); InventoryUtils.setMetaBoolean(item, "unstashable", true); } else { InventoryUtils.removeMeta(item, "unstashable"); InventoryUtils.setMetaBoolean(item, "unmoveable", true); } else { InventoryUtils.removeMeta(item, "unmoveable"); InventoryUtils.setMetaBoolean(item, "undroppable", true); } else { InventoryUtils.removeMeta(item, "undroppable"); InventoryUtils.setMetaBoolean(item, "keep", true); } else { InventoryUtils.removeMeta(item, "keep"); InventoryUtils.applyEnchantments(item, enchantments);
Set<String> currentTags = getTagKeys(node); if (currentTags != null && !tagNames.containsAll(currentTags)) { Object value = tags.get(tagName); try { Object wrappedTag = wrapInTag(value); if (wrappedTag == null) continue; class_NBTTagCompound_setMethod.invoke(node, tagName, wrappedTag); removeMeta(node, currentTag);
@Nonnull public static Wand createWand(@Nonnull MagicController controller, @Nonnull ItemStack itemStack) { checkNotNull(controller); checkNotNull(itemStack); Wand wand = null; try { wand = controller.getWand(InventoryUtils.makeReal(itemStack.clone())); wand.saveState(); wand.updateName(); } catch (Exception ex) { ex.printStackTrace(); wand = new Wand(controller); } return wand; }
List<Object> converted = new ArrayList<>(); for (Object baseTag : items) { Object convertedBase = getTagValue(baseTag); if (convertedBase != null) { converted.add(convertedBase); } else if (class_NBTTagCompound.isAssignableFrom(tag.getClass())) { Map<String, Object> compoundMap = new HashMap<>(); Set<String> keys = getTagKeys(tag); for (String key : keys) { Object baseTag = class_NBTTagCompound_getMethod.invoke(tag, key); Object convertedBase = getTagValue(baseTag); if (convertedBase != null) { compoundMap.put(key, convertedBase);
@Nullable public static Double getCurrencyAmount(ItemStack item) { if (InventoryUtils.isEmpty(item)) return null; Object currencyNode = InventoryUtils.getNode(item, "currency"); if (currencyNode == null) return null; return InventoryUtils.getMetaDouble(currencyNode, "amount"); }