private void createEffectCloud() { AreaEffectCloud cloud = (AreaEffectCloud) location.getWorld().spawnEntity(location, EntityType.AREA_EFFECT_CLOUD); cloud.setRadius(3); cloud.setRadiusPerTick(-.005f); ItemMeta meta = getItem().getItemMeta(); if (meta instanceof PotionMeta) { PotionMeta potionMeta = (PotionMeta) meta; cloud.setColor(potionMeta.getColor()); cloud.setBasePotionData(potionMeta.getBasePotionData()); for (PotionEffect effect : getEffects()) { cloud.addCustomEffect(effect, true); } } remove(); } }
@Override public Collection<PotionEffect> getEffects() { if (item == null) { return Collections.emptyList(); } ItemMeta meta = item.getItemMeta(); return meta instanceof PotionMeta ? ((PotionMeta) meta).getCustomEffects() : Collections.emptyList(); } }
PotionMeta iStackMeta = (PotionMeta) iStack.getItemMeta(); PotionMeta stackMeta = (PotionMeta) stack.getItemMeta(); if (iStackMeta.getBasePotionData().equals(stackMeta.getBasePotionData()) && iStackMeta .getCustomEffects().equals(stackMeta.getCustomEffects())) { return trade;
@Override public MCPotionData getBasePotionData() { return new BukkitMCPotionData(pm.getBasePotionData()); }
PotionMeta potionMeta = (PotionMeta) meta; try { PotionData pData = potionMeta.getBasePotionData(); effects = " type:" + pData.getType().toString() + (pData.isExtended() ? " extended" : "") + (pData.isUpgraded() ? " upgraded" : ""); } catch (LinkageError e) { if (potionMeta.hasCustomEffects()) { StringBuilder string = new StringBuilder(); for (PotionEffect effect: potionMeta.getCustomEffects()) { int power = effect.getAmplifier() + 1; int duration = (effect.getDuration() - (effect.getDuration() % 20)) / 20;
PotionMeta potionMeta = (PotionMeta) meta; try { potionMeta.setBasePotionData(potion.getBase()); } catch (LinkageError e) { potionMeta.addCustomEffect(effect, true);
PotionData that = meta.getBasePotionData(); if (data.getType() != that.getType()) { return false; if (!meta.hasCustomEffect(effect.getType())) { return false; if (!meta.hasLore() && !lore.isEmpty()) { return false; if (!(lore.isEmpty() && !meta.hasLore()) && !meta.getLore().equals(lore)) { return false; if (!meta.hasDisplayName() && name != null) { return false; return (name == null && !meta.hasDisplayName()) || meta.getDisplayName().equals(name);
public ItemStack toItemStack(int amount) { ItemStack potion = new ItemStack(material, amount); PotionMeta meta = (PotionMeta) potion.getItemMeta(); meta.setBasePotionData(data); if (this.getName() != null) { meta.setDisplayName(this.getName()); } if (this.getLore() != null && !this.getLore().isEmpty()) { meta.setLore(this.getLore()); } if (!this.getEffects().isEmpty()) { for (PotionEffect effect : this.getEffects()) { meta.addCustomEffect(effect, true); } } if (this.getColor() != null) { meta.setColor(this.getColor()); } potion.setItemMeta(meta); return potion; }
public ItemBuilder potionData(PotionData potionData) { if (itemMeta instanceof PotionMeta) { ((PotionMeta) itemMeta).setBasePotionData(potionData); } return this; }
public ItemBuilder potionEffect(PotionEffect potionEffect, boolean b) { if (itemMeta instanceof PotionMeta) { ((PotionMeta) itemMeta).addCustomEffect(potionEffect, b); } return this; }
skyMetaList.remove(new SkyDurabilityMeta(durability)); PotionMeta potionMeta = (PotionMeta) itemMeta; if (potionMeta.hasCustomEffects()) { skyMetaList.add(new SkyExtraEffectsMeta(potionMeta.getCustomEffects()));
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded)); itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name"))); lore.add(ChatColor.translateAlternateColorCodes('&', s)); itemMeta.setLore(lore);
@Override public boolean hasCustomEffects() { return pm.hasCustomEffects(); }
@Override public boolean hasCustomEffect(MCPotionEffectType type) { return pm.hasCustomEffect((PotionEffectType) type.getConcrete()); }
PotionMeta iStackMeta = (PotionMeta) iStack.getItemMeta(); PotionMeta stackMeta = (PotionMeta) stack.getItemMeta(); if (iStackMeta.getBasePotionData().equals(stackMeta.getBasePotionData()) && iStackMeta .getCustomEffects().equals(stackMeta.getCustomEffects())) { return trade;
/** * Determines whether an item is a water potion. * * @param item * @return true if the item is a water potion, false otherwise */ @SuppressWarnings("deprecation") boolean isWaterPotion(ItemStack item) { if (serverVersion >= 9) { // Method getBasePotionData does not exist for versions prior to Minecraft 1.9. return ((PotionMeta) (item.getItemMeta())).getBasePotionData().getType() == PotionType.WATER; } return item.getDurability() == 0; }
PotionEffectType baseEffect = meta.getBasePotionData().getType().getEffectType(); if (wcfg.blockPotions.contains(baseEffect)) { blockedEffect = baseEffect; if (blockedEffect == null && meta.hasCustomEffects()) { for (PotionEffect effect : meta.getCustomEffects()) { if (wcfg.blockPotions.contains(effect.getType())) { blockedEffect = effect.getType();
PotionData data = new PotionData(PotionType.valueOf(root.getString("potion.data.type")), root.getBoolean("potion.data.extended"), root.getBoolean("potion.data.upgraded")); meta.setBasePotionData(data); } catch (Throwable t) { PotionEffectType type = PotionEffectType.getByName(sub.getString("type")); boolean ambient = sub.getBoolean("ambient"); meta.addCustomEffect(new PotionEffect(type, duration, amplifier, ambient), true);
@Override public void setBasePotionData(MCPotionData bpd) { pm.setBasePotionData((PotionData) bpd.getHandle()); }
public ItemBuilder potionEffect(PotionEffect potionEffect) { if (itemMeta instanceof PotionMeta) { ((PotionMeta) itemMeta).addCustomEffect(potionEffect, false); } return this; }