Java 类org.bukkit.inventory.meta.PotionMeta 实例源码

项目:ProjectAres    文件:ItemModifyModule.java   
@Override
public @Nullable ItemModifyModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    List<ItemRule> rules = new ArrayList<>();
    for(Element elRule : XMLUtils.flattenElements(doc.getRootElement(), "item-mods", "rule")) {
        MaterialMatcher items = XMLUtils.parseMaterialMatcher(XMLUtils.getRequiredUniqueChild(elRule, "match"));

        // Always use a PotionMeta so the rule can have potion effects, though it will only apply those to potion items
        final Element elModify = XMLUtils.getRequiredUniqueChild(elRule, "modify");
        final PotionMeta meta = (PotionMeta) Bukkit.getItemFactory().getItemMeta(Material.POTION);
        context.needModule(ItemParser.class).parseItemMeta(elModify, meta);
        final boolean defaultAttributes = XMLUtils.parseBoolean(elModify.getAttribute("default-attributes"), false);

        ItemRule rule = new ItemRule(items, meta, defaultAttributes);
        rules.add(rule);
    }

    return rules.isEmpty() ? null : new ItemModifyModule(rules);
}
项目:QuarSK    文件:SExprItemEffectTypeAmplifier.java   
@Nullable
@Override
protected Number[] get(Event e) {
    ItemStack i = item.getSingle(e);
    if (i == null) {
        return null;
    }
    if (PotionUtils.isPotionItem(i)) {
        PotionMeta meta = (PotionMeta) i.getItemMeta();
        PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
        if (eff == null) {
            return null;
        }
        return new Number[]{eff.getAmplifier()};
    }
    return null;
}
项目:QuarSK    文件:SExprItemEffectTypeDuration.java   
@Nullable
@Override
protected Timespan[] get(Event e) {
    ItemStack i = item.getSingle(e);
    if (i == null) {
        return null;
    }
    if (PotionUtils.isPotionItem(i)) {
        PotionMeta meta = (PotionMeta) i.getItemMeta();
        PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
        if (eff == null) {
            return null;
        }
        return new Timespan[]{Timespan.fromTicks_i(eff.getDuration())};
    }
    return null;
}
项目:RealSurvival    文件:Items.java   
/**
 * l.add("��2��ˮ,����...");
    l.add("��4�������ܽ��,��l���м�������!");
    l.add("��b��Ҫ�þ�ˮװ�����������������!");
 * @return ��ˮ
 */
public static ItemStack getSeaWater(){
    ItemStack sw=new ItemStack(Material.POTION);
    PotionMeta im = (PotionMeta) sw.getItemMeta();
    im.setColor(Color.fromRGB(15, 103, 219));
    im.setDisplayName("��1��l��ˮ");
    List<String> l=new LinkedList<String>();
    l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l-"+Utils.random(2, 20)+"%");
    l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
    l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(20, 30)+"%");
    l.add("");
    l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
    l.add("");
    l.add("��2��ˮ,����...");
    l.add("��4�������ܽ��,��l���м�������!");
    l.add("��b��Ҫ�þ�ˮװ�����������������!");
    im.setLore(l);
    sw.setItemMeta(im);
    return sw;
}
项目:RealSurvival    文件:Items.java   
/**
 * l.add("��2��ˮ,�����ճɿ�ˮ");
    l.add("��4��lֱ�Ӻ��м�������!");
    l.add("��b��Ҫ�á�e��l��ˮװ�á�b���������������!");
 * @return��ˮ
 */
public static ItemStack getLakeWater(){
    ItemStack sw=new ItemStack(Material.POTION);
    PotionMeta im = (PotionMeta) sw.getItemMeta();
    im.setColor(Color.fromRGB(36, 165, 229));
    im.setDisplayName("��2��l��ˮ");
    List<String> l=new LinkedList<String>();
    l.add("��2��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(5, 20)+"%");
    l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
    l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(5, 15)+"%");
    l.add("");
    l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
    l.add("");
    l.add("��4��lֱ�Ӻ��м�������!");
    l.add("��b��Ҫ�á�e��l��ˮװ�á�b���������������!");
    im.setLore(l);
    sw.setItemMeta(im);
    return sw;
}
项目:RealSurvival    文件:Items.java   
/**
 * l.add("��2����ֱ������");
    l.add("��a��l���Ի������Ƽ���!");
    l.add("��c������ů����!");
 * @return ��ˮ
 */
public static ItemStack getHotWater(){
    ItemStack sw=new ItemStack(Material.POTION);
    PotionMeta im = (PotionMeta) sw.getItemMeta();
    im.setColor(Color.fromRGB(36, 165, 229));
    im.setDisplayName("��d��l��ˮ");
    List<String> l=new LinkedList<String>();
    l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(10, 25)+"%");
    l.add("��c��l"+rs.getLoreTabel("Tem")+": ��b��l"+Utils.random(0.1, 1.5));
    l.add("");
    l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
    l.add("");
    l.add("��2����ֱ������");
    l.add("��a��l���Ի������Ƽ���!");
    l.add("��c������ů����!");
    im.setLore(l);
    sw.setItemMeta(im);
    return sw;
}
项目:RealSurvival    文件:Items.java   
/**
 * l.add("��2����ֱ������");
    l.add("��b��l���Ը����彵��!");
 * @return ��ˮ
 */
public static ItemStack getIceWater(){
    ItemStack sw=new ItemStack(Material.POTION);
    PotionMeta im = (PotionMeta) sw.getItemMeta();
    im.setColor(Color.fromRGB(36, 165, 229));
    im.setDisplayName("��3��l��ˮ");
    List<String> l=new LinkedList<String>();
    l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(10, 25)+"%");
    l.add("��3��l"+rs.getLoreTabel("Tem")+": ��c��l-"+Utils.random(0.1, 1.5)+"%");
    l.add("");
    l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
    l.add("");
    l.add("��2����ֱ������");
    l.add("��b��l���Ը����彵��!");
    im.setLore(l);
    sw.setItemMeta(im);
    return sw;
}
项目:RealSurvival    文件:Items.java   
/**
 * l.add("��2����ֱ������");
 * @return ��ˮ
 */
public static ItemStack getFreshWater(){
    ItemStack sw=new ItemStack(Material.POTION);
    PotionMeta im = (PotionMeta) sw.getItemMeta();
    im.setColor(Color.fromRGB(36, 165, 229));
    im.setDisplayName("��3��l��ˮ");
    List<String> l=new LinkedList<String>();
    l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(10, 25)+"%");
    l.add("");
    l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
    l.add("");
    l.add("��2����ֱ������");
    im.setLore(l);
    sw.setItemMeta(im);
    return sw;
}
项目:RealSurvival    文件:Items.java   
/**
 *l.add("��2��Ȼ���Խ��,����...");
    l.add("��e���������....");
 * @return ����ˮ
 */
public static ItemStack getSwamplandWater(){
    ItemStack sw=new ItemStack(Material.POTION);
    PotionMeta im = (PotionMeta) sw.getItemMeta();
    im.setColor(Color.fromRGB(50, 69, 107));
    im.setDisplayName("��8��l����ˮ");
    List<String> l=new LinkedList<String>();
    l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(2, 15)+"%");
    l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
    l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(30, 50)+"%");
    l.add("");
    l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
    l.add("");
    l.add("��2��Ȼ���Խ��,����...");
    l.add("��e���������....");
    im.setLore(l);
    sw.setItemMeta(im);
    return sw;
}
项目:RealSurvival    文件:Items.java   
/**
    l.add("��2��ˮ�����˵���DZȽϸɾ���");
    l.add("��b���ǻ����н�С���ʵò�");
 * @return ��ˮ
 */
public static ItemStack getRainwater(){
    ItemStack sw=new ItemStack(Material.POTION);
    PotionMeta im = (PotionMeta) sw.getItemMeta();
    im.setColor(Color.fromRGB(36, 165, 229));
    im.setDisplayName("��b��l��ˮ");
    List<String> l=new LinkedList<String>();
    l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(5, 25)+"%");
    l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
    l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(2, 10)+"%");
    l.add("");
    l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
    l.add("");
    l.add("��2��ˮ�����˵���DZȽϸɾ���");
    l.add("��b���ǻ����н�С���ʵò�");
    im.setLore(l);
    sw.setItemMeta(im);
    return sw;
}
项目:AthenaGM    文件:MapInfoKitItem.java   
/**
 * Turn an ItemStack with a Material of POTION into a functional potion
 * @param typeName PotionType string representing the potion type. (Matches Bukkit PotionType enum.)
 * @param upgraded Boolean specifying a level two potion if true
 * @param extended Is this an extended duration potion?
 */
public void addPotion(String typeName, boolean upgraded, boolean extended) {
    Material mat = this.item.getType();
    Set<Material> types = new HashSet<>();
    types.add(Material.POTION);
    types.add(Material.SPLASH_POTION);
    types.add(Material.LINGERING_POTION);
    types.add(Material.TIPPED_ARROW);
    if (!types.contains(mat)) return;
    try {
        PotionType type = PotionType.valueOf(typeName.toUpperCase());
        PotionData pd = new PotionData(type, extended, upgraded);
        PotionMeta meta = (PotionMeta) this.item.getItemMeta();
        meta.setBasePotionData(pd);
        this.item.setItemMeta(meta);
    } catch (Exception ex) {
        Bukkit.getLogger().warning(String.format("Kit configuration error: %s", ex.getMessage()));
    }
}
项目:WorldGuardExtraFlagsPlugin    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerItemConsumeEvent(PlayerItemConsumeEvent event)
{
    Player player = event.getPlayer();

    if (!WorldGuardUtils.hasBypass(player))
    {
        ItemMeta itemMeta = event.getItem().getItemMeta();
        if (itemMeta instanceof PotionMeta)
        {
            WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(GiveEffectsFlag.class).drinkPotion(player, Potion.fromItemStack(event.getItem()).getEffects());
        }
        else
        {
            Material material = event.getItem().getType();
            if (material == Material.MILK_BUCKET)
            {
                WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(GiveEffectsFlag.class).drinkMilk(player);
            }
        }
    }
}
项目:Arcade2    文件:XMLItemMeta.java   
public static ItemMeta parse(Element xml, ItemMeta source) {
    if (source instanceof BannerMeta) {
        return parseBanner(xml, (BannerMeta) source);
    } else if (source instanceof BookMeta) {
        return parseBook(xml, (BookMeta) source);
    } else if (source instanceof EnchantmentStorageMeta) {
        return parseEnchantmentStorage(xml, (EnchantmentStorageMeta) source);
    } else if (source instanceof FireworkMeta) {
        return parseFirework(xml, (FireworkMeta) source);
    } else if (source instanceof FireworkEffectMeta) {
        return parseFireworkEffect(xml, (FireworkEffectMeta) source);
    } else if (source instanceof LeatherArmorMeta) {
        return parseLeatherArmor(xml, (LeatherArmorMeta) source);
    } else if (source instanceof MapMeta) {
        return parseMap(xml, (MapMeta) source);
    } else if (source instanceof PotionMeta) {
        return parsePotion(xml, (PotionMeta) source);
    } else if (source instanceof SkullMeta) {
        return parseSkull(xml, (SkullMeta) source);
    } else if (source instanceof SpawnEggMeta) {
        return parseSpawnEgg(xml, (SpawnEggMeta) source);
    }

    return source;
}
项目:LuckyBlocksBukkit    文件:LuckyBlocksActionController.java   
public void LuckyPotion(BlockBreakEvent event){
    Location loc = event.getBlock().getLocation();
    World world = loc.getWorld();
    ItemStack energyPotion = new ItemStack(Material.POTION, 1);
    PotionMeta energyPotionMeta = (PotionMeta) energyPotion.getItemMeta();
    energyPotionMeta.setDisplayName("§6Lucky Potion");
    List<String> lore = new ArrayList<String>();
    lore.add("§6"+ LuckyBlocksMainController.instance.language.getString("POTION_DURATION"));
    energyPotionMeta.setLore(lore);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.ABSORPTION, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEAL, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 20*60, 3), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 20*60, 3), true);
    energyPotion.setItemMeta(energyPotionMeta);
    Potion po = new Potion((byte) 8258);
    po.apply(energyPotion);
    world.dropItemNaturally(loc,energyPotion);
}
项目:LuckyBlocksBukkit    文件:LuckyBlocksActionController.java   
public void LuckyPotion(BlockBreakEvent event){
    Location loc = event.getBlock().getLocation();
    World world = loc.getWorld();
    ItemStack energyPotion = new ItemStack(Material.POTION, 1);
    PotionMeta energyPotionMeta = (PotionMeta) energyPotion.getItemMeta();
    energyPotionMeta.setDisplayName("§6Lucky Potion");
    List<String> lore = new ArrayList<String>();
    lore.add("§6"+ LuckyBlocksMainController.instance.language.getString("POTION_DURATION"));
    energyPotionMeta.setLore(lore);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.ABSORPTION, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEAL, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 20*60, 3), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 20*60, 3), true);
    energyPotion.setItemMeta(energyPotionMeta);
    Potion po = new Potion((byte) 8258);
    po.apply(energyPotion);
    world.dropItemNaturally(loc,energyPotion);
}
项目:RedProtect    文件:RPUtil.java   
public static boolean denyPotion(ItemStack result, Player p){
    List<String> Pots = RPConfig.getStringList("server-protection.deny-potions");
    if (result != null && Pots.size() > 0 && (result.getType().name().contains("POTION") || result.getType().name().contains("TIPPED"))){
        String potname = "";
        if (RedProtect.get().version >= 190){
            PotionMeta pot = (PotionMeta) result.getItemMeta();
            potname = pot.getBasePotionData().getType().name();
        }
        if (RedProtect.get().version <= 180 && Potion.fromItemStack(result) != null){
            potname = Potion.fromItemStack(result).getType().name();
        }           
        if (Pots.contains(potname)){                
            RPLang.sendMessage(p, "playerlistener.denypotion");
            return true;
        }                       
    }
    return false;
}
项目:SupaCommons    文件:ItemBuilder.java   
/**
 * Sets this item's main effect, assuming it is a potion.
 * <p />
 * <b>UNSAFE</b>
 *
 * @param effectType effect type to set
 *
 * @return this item builder instance, for chaining
 * @see ItemBuilder#potionMain(PotionData) 
 */
@Deprecated
public ItemBuilder potionMain(PotionEffectType effectType) {
  if (isPotionMeta()) {
    try {
      PotionMeta potionMeta = (PotionMeta) this.itemMeta;
      if (potionMeta.setMainEffect(effectType) == false) {
        potionMeta.setBasePotionData(new PotionData(potionTypeFromLegacy(effectType), false, false));
      }
    } catch (Exception e) {
      if (!this.failSilently) {
        e.printStackTrace();
      }
    }
  }
  return this;
}
项目:McMMOPlus    文件:AlchemyPotion.java   
public ItemStack toItemStack(int amount) {
    ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
    PotionMeta meta = (PotionMeta) potion.getItemMeta();

    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);
        }
    }

    potion.setItemMeta(meta);
    return potion;
}
项目:NPlugins    文件:Chat.java   
private static void appendItemPotion(final StringBuilder builder, final PotionMeta meta) {
    if (meta.hasCustomEffects()) {
        builder.append("CustomPotionEffects:[");
        final Iterator<PotionEffect> it = meta.getCustomEffects().iterator();
        while (it.hasNext()) {
            final PotionEffect effect = it.next();
            builder.append("{Id:")
                   .append(effect.getType().getId())
                   .append(",Amplifier:")
                   .append(effect.getAmplifier())
                   .append(",Duration:")
                   .append(effect.getDuration())
                   .append(",Ambient:")
                   .append(effect.isAmbient() ? 1 : 0)
                   .append('}');
            if (it.hasNext()) {
                builder.append(',');
            }
        }
        builder.append("],");
    }
}
项目:NPlugins    文件:ItemMetaUtil.java   
/**
 * Gets a String representing all special meta of this ItemStack, if any.
 *
 * @param is         the ItemStack
 * @param separators the separators
 *
 * @return a String representing this ItemStack's special meta or an empty String
 *
 * @throws InventoryUtilException if something goes wrong
 */
public static String getSpecialMetaString(final ItemStack is, final String[] separators) throws InventoryUtilException {
    final ItemMeta meta = is.getItemMeta();

    if (meta instanceof BookMeta) {
        return getBookMetaString((BookMeta)meta);
    } else if (meta instanceof EnchantmentStorageMeta) {
        return getEnchantmentStorageMetaString((EnchantmentStorageMeta)meta, separators);
    } else if (meta instanceof FireworkEffectMeta) {
        return getFireworkEffectMetaString((FireworkEffectMeta)meta);
    } else if (meta instanceof FireworkMeta) {
        return getFireworkMetaString((FireworkMeta)meta, separators);
    } else if (meta instanceof LeatherArmorMeta) {
        return getLeatherArmorMetaString((LeatherArmorMeta)meta);
    } else if (meta instanceof MapMeta) {
        return getMapMetaString((MapMeta)meta);
    } else if (meta instanceof PotionMeta) {
        return getPotionMetaString((PotionMeta)meta, separators);
    } else if (meta instanceof SkullMeta) {
        return getSkullMetaString((SkullMeta)meta);
    } else {
        throw new InventoryUtilException("Unknown Meta type '" + meta.getClass().getName() + "', please report this to the author (Ribesg)!");
    }
}
项目:NPlugins    文件:ItemMetaUtil.java   
private static String getPotionMetaString(final PotionMeta meta, final String[] separators) {
    final List<PotionEffect> effects = meta.getCustomEffects();

    final StringBuilder builder = new StringBuilder();
    if (!effects.isEmpty()) {
        PotionEffect effect = effects.get(0);
        builder.append(effect.getType().getName()).append(separators[2]);
        builder.append(effect.getDuration()).append(separators[2]);
        builder.append(effect.getAmplifier());
        for (int i = 1; i < effects.size(); i++) {
            builder.append(separators[1]);
            effect = effects.get(i);
            builder.append(effect.getType().getName()).append(separators[2]);
            builder.append(effect.getDuration()).append(separators[2]);
            builder.append(effect.getAmplifier());
        }
    }

    return builder.toString();
}
项目:ZvP    文件:KitManager.java   
public void addKit(String kitName, ItemStack icon, ItemStack[] items) {

    // splash portion of healing I causes illegal argument exception -> replace it with splash potion of healing II
    for (ItemStack stack : items) {
        if (stack != null && stack.getType() != Material.AIR) {
        if (stack.getItemMeta() instanceof PotionMeta) {
            if (stack.getDurability() == 16453) {
            stack.setDurability((short) 16421);
            }
        }
        }
    }

    IZvPKit kit = new KCustomKit(this.kitPath.getAbsolutePath(), kitName, icon, 0.0, items);
    this.kits.add(kit);
    loadKits();
    }
项目:BedwarsXP    文件:XPItemShop.java   
private VillagerTrade getTradingItem(MerchantCategory category,
        ItemStack stack, Game game, Player player) {
    for (VillagerTrade trade : category.getOffers()) {
        if ((trade.getItem1().getType() != Material.AIR)
                || (trade.getRewardItem().getType() != Material.AIR)) {
            ItemStack iStack = toItemStack(trade, player, game);
            if ((iStack.getType() == Material.ENDER_CHEST)
                    && (stack.getType() == Material.ENDER_CHEST))
                return trade;
            if (((iStack.getType() == Material.POTION) || ((Main
                    .getInstance().getCurrentVersion().startsWith("v1_9")) && ((iStack
                    .getType().equals(Material.valueOf("TIPPED_ARROW")))
                    || (iStack.getType().equals(Material
                            .valueOf("LINGERING_POTION"))) || (iStack
                        .getType()
                    .equals(Material.valueOf("SPLASH_POTION"))))))
                    && (((PotionMeta) iStack.getItemMeta())
                            .getCustomEffects().equals(((PotionMeta) stack
                            .getItemMeta()).getCustomEffects()))) {
                return trade;
            }
            if (iStack.equals(stack)) {
                return trade;
            }
        }
    }
    return null;
}
项目:BedwarsXP    文件:XPItemShop.java   
private VillagerTrade getTradingItem(MerchantCategory category,
        ItemStack stack, Game game, Player player) {
    for (VillagerTrade trade : category.getOffers()) {
        if ((trade.getItem1().getType() != Material.AIR)
                || (trade.getRewardItem().getType() != Material.AIR)) {
            ItemStack iStack = toItemStack(trade, player, game);
            if ((iStack.getType() == Material.ENDER_CHEST)
                    && (stack.getType() == Material.ENDER_CHEST))
                return trade;
            if (((iStack.getType() == Material.POTION) || ((Main
                    .getInstance().getCurrentVersion().startsWith("v1_9")) && ((iStack
                    .getType().equals(Material.valueOf("TIPPED_ARROW")))
                    || (iStack.getType().equals(Material
                            .valueOf("LINGERING_POTION"))) || (iStack
                        .getType()
                    .equals(Material.valueOf("SPLASH_POTION"))))))
                    && (((PotionMeta) iStack.getItemMeta())
                            .getCustomEffects().equals(((PotionMeta) stack
                            .getItemMeta()).getCustomEffects()))) {
                return trade;
            }
            if (iStack.equals(stack)) {
                return trade;
            }
        }
    }
    return null;
}
项目:uppercore    文件:GuiUtil.java   
public static ItemStack splashPotion(PotionType type, boolean extended, boolean upgraded, String name, String... lores) {
    ItemStack potion = new ItemStack(Material.SPLASH_POTION, 1);
    PotionMeta meta = (PotionMeta) potion.getItemMeta();
    meta.setBasePotionData(new PotionData(type, extended, upgraded));
    potion.setItemMeta(meta);
    return potion;
}
项目:uppercore    文件:PotionCustomItem.java   
@Override
public void processMeta(Player player, ItemMeta m) {
    super.processMeta(player, m);
    PotionMeta meta = (PotionMeta) m;
    if(type != null)
        meta.setBasePotionData(new PotionData(type));
    if(customColor != null)
        meta.setColor(customColor.resolve(player));
    meta.clearCustomEffects();
    for(PotionEffect e : customEffects)
        meta.addCustomEffect(e, true);
}
项目:WC    文件:ItemMaker.java   
public ItemMaker addPotionType(PotionType type, int time, int amplifier) {
    PotionMeta itemMeta = (PotionMeta) this.itemStack.getItemMeta();
    itemMeta.setMainEffect(type.getEffectType());

    itemMeta.addCustomEffect(new PotionEffect(type.getEffectType(), time * 20, amplifier), true);

    this.itemStack.setItemMeta(itemMeta);
    return this;
}
项目:ProjectAres    文件:GlobalItemParser.java   
public ItemStack parseItem(Element el, Material type, short damage) throws InvalidXMLException {
    int amount = XMLUtils.parseNumber(el.getAttribute("amount"), Integer.class, 1);

    // If the item is a potion with non-zero damage, and there is
    // no modern potion ID, decode the legacy damage value.
    final Potion legacyPotion;
    if(type == Material.POTION && damage > 0 && el.getAttribute("potion") == null) {
        try {
            legacyPotion = Potion.fromDamage(damage);
        } catch(IllegalArgumentException e) {
            throw new InvalidXMLException("Invalid legacy potion damage value " + damage + ": " + e.getMessage(), el, e);
        }

        // If the legacy splash bit is set, convert to a splash potion
        if(legacyPotion.isSplash()) {
            type = Material.SPLASH_POTION;
            legacyPotion.setSplash(false);
        }

        // Potions always have damage 0
        damage = 0;
    } else {
        legacyPotion = null;
    }

    ItemStack itemStack = new ItemStack(type, amount, damage);
    if(itemStack.getType() != type) {
        throw new InvalidXMLException("Invalid item/block", el);
    }

    final ItemMeta meta = itemStack.getItemMeta();
    if(meta != null) { // This happens if the item is "air"
        parseItemMeta(el, meta);

        // If we decoded a legacy potion, apply it now, but only if there are no custom effects.
        // This emulates the old behavior of custom effects overriding default effects.
        if(legacyPotion != null) {
            final PotionMeta potionMeta = (PotionMeta) meta;
            if(!potionMeta.hasCustomEffects()) {
                potionMeta.setBasePotionData(new PotionData(legacyPotion.getType(),
                                                            legacyPotion.hasExtendedDuration(),
                                                            legacyPotion.getLevel() == 2));
            }
        }

        itemStack.setItemMeta(meta);
    }

    return itemStack;
}
项目:ProjectAres    文件:ItemMatcherTest.java   
@Test
public void itemWithTypedMetaMatches() throws Throwable {
    ImItemStack item = ItemStack.builder(Material.POTION)
                                .meta(PotionMeta.class, meta -> meta.setBasePotionData(new PotionData(PotionType.LUCK, false, false)))
                                .immutable();
    assertMatches(item, item);
}
项目:ProjectAres    文件:PotionClassificationTest.java   
@Test
public void potionItem() throws Exception {
    final ItemStack item = new ItemStack(Material.POTION);
    final PotionMeta meta = (PotionMeta) item.getItemMeta();
    meta.setPotionBrew(Bukkit.potionRegistry().get(Bukkit.key("healing")));
    item.setItemMeta(meta);

}
项目:QuarSK    文件:SExprPotionItemEffects.java   
@Nullable
@Override
protected PotionEffect[] get(Event e) {
    ItemStack i = potionItem.getSingle(e);
    if (i == null) {
        return null;
    }
    if (PotionUtils.isPotionItem(i)) {
        PotionMeta meta = (PotionMeta) i.getItemMeta();
        return PotionUtils.actualPotionEffects(meta);
    }
    return null;
}
项目:QuarSK    文件:ExprCustomPotionItem.java   
@NotNull
@Override
protected ItemStack[] get(Event e) {
    ItemStack item = new ItemStack(material, 1);
    PotionMeta meta = (PotionMeta) item.getItemMeta(); //Getting PotionMeta
    Stream.of(potionEffects.getAll(e)).forEach(eff -> meta.addCustomEffect(eff, true));
    item.setItemMeta(meta);
    return new ItemStack[]{item};
}
项目:QuarSK    文件:PotionUtils.java   
public static PotionEffect[] actualPotionEffects(@NotNull PotionMeta meta) {
    List<PotionEffect> effects = new ArrayList<>();
    effects.addAll(meta.getCustomEffects());
    if (meta.getBasePotionData().getType() != PotionType.UNCRAFTABLE) {
        effects.add(fromPotionData(meta.getBasePotionData()));
    }
    return effects.toArray(new PotionEffect[effects.size()]);
}
项目:SurvivalAPI    文件:DropMyEffectsModule.java   
/**
 * Drop player's potion effect on his death
 *
 * @param event Event
 */
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
    for (PotionEffect potionEffect : event.getEntity().getActivePotionEffects())
    {
        if (this.blacklist.contains(potionEffect.getType()))
            continue;

        if (PotionType.getByEffect(potionEffect.getType()) == null)
            continue;

        if(potionEffect.getDuration() > 10000)
            continue;

        Potion potion = new Potion(PotionType.getByEffect(potionEffect.getType()), potionEffect.getAmplifier() + 1);
        ItemStack stack = potion.toItemStack(1);

        PotionMeta meta = (PotionMeta) stack.getItemMeta();
        meta.clearCustomEffects();
        meta.addCustomEffect(new PotionEffect(potionEffect.getType(), potionEffect.getDuration(), potionEffect.getAmplifier()), true);

        stack.setItemMeta(meta);

        event.getDrops().add(stack);
        event.getEntity().removePotionEffect(potionEffect.getType());
    }
}
项目:SaveableSerializing    文件:DefaultMeta.java   
public DefaultMeta(ItemMeta m){
    if(m instanceof BookMeta)
        meta = new SaveableBookMeta().setFrom(m);
    else if(m instanceof PotionMeta)
        meta = new milkyway.SaveableSerializing.ItemStacks.Upper_1_7.ItemData.ItemMetas.PotionMeta().setFrom(m);
    else if(m instanceof SkullMeta)
        meta = new HeadMeta().setFrom(m);
    else if(m instanceof FireworkMeta)
        meta = new FireworksMeta().setFrom(m);
    else if (m instanceof LeatherArmorMeta)
        meta = new LeatherArmoursMeta().setFrom(m);
    else if(m instanceof EnchantmentStorageMeta)
        meta = new SaveableEnchantBook().setFrom(m);
    else if(m instanceof FireworkEffectMeta)
        meta = new FireworkEffectsMeta().setFrom(m);
    if(m != null){
        display = m.getDisplayName();
        if(m.hasLore())
            lore = m.getLore();
        try{
            for(ItemFlag flag : m.getItemFlags())
                this.flag.add(flag.name());
        }catch (Exception ex)
        {}
    }

}
项目:PA    文件:ItemMaker.java   
public ItemMaker addPotionType(PotionType type, int time, int amplifier) {
    PotionMeta itemMeta = (PotionMeta) this.itemStack.getItemMeta();
    itemMeta.setMainEffect(type.getEffectType());

    itemMeta.addCustomEffect(new PotionEffect(type.getEffectType(), time * 20, amplifier), true);

    this.itemStack.setItemMeta(itemMeta);
    return this;
}
项目:TalentZzzz    文件:ItemManager.java   
public ItemStack getItemStack() {
    ItemStack itemStack = new ItemStack(id, amount, damage);
    ItemMeta itemMeta = itemStack.getItemMeta();
    if (name != null)
        itemMeta.setDisplayName(name);
    if (lore != null)
        itemMeta.setLore(lore);
    if (effect != null && itemMeta instanceof PotionMeta)
        effect.forEach(e -> ((PotionMeta) itemMeta).addCustomEffect(e.getPotionEffect(), true));
    itemStack.setItemMeta(itemMeta);
    if (enchant != null)
        enchant.forEach(e -> e.apply(itemStack));
    return itemStack;
}
项目:NationZ    文件:BrewingRecipe.java   
public ItemStack getResult() {
    ItemStack is = new ItemStack(Material.POTION);
    PotionMeta pm = (PotionMeta) is.getItemMeta();
    pm.addCustomEffect(new PotionEffect(potionEffectType, maxDuration, maxAmplifier), true);
    pm.setMainEffect(potionEffectType);
    is.setItemMeta(pm);
    return is;
}
项目:Arcade2    文件:XMLItemMeta.java   
public static PotionMeta parsePotion(Element xml, PotionMeta source) {
    for (Element effectElement : xml.getChildren("potion-effect")) {
        PotionEffect effect = XMLPotionEffect.parse(effectElement);
        if (effect != null) {
            source.addCustomEffect(effect, false);
        }
    }

    return source;
}
项目:Cardinal    文件:DocumentItems.java   
public static ItemStack applyMeta(ItemStack itemStack, Element element) {
  for (Element enchant : element.getChildren("enchantment")) {
    String ench = enchant.getText();
    Enchantment enchantment = Enchantment.getByName(Strings.getTechnicalName(ench));
    int lvl = Numbers.parseInteger(enchant.getAttributeValue("level"), 1);
    if (enchantment == null) {
      //TODO: NMS name check
    } else {
      itemStack.addUnsafeEnchantment(enchantment, lvl);
    }
  }
  ItemMeta meta = itemStack.getItemMeta();
  for (Element effect : element.getChildren("effect")) {
    PotionEffect potionEffect = getPotion(effect);
    if (!((PotionMeta) meta).getCustomEffects().contains(potionEffect)) {
      ((PotionMeta) meta).addCustomEffect(potionEffect, true);
    }
  }
  for (Element attribute : element.getChildren("attribute")) {
    ItemAttributeModifier itemAttribute = getAttribute(attribute);
    if (!meta.getModifiedAttributes().contains(attribute.getText())) {
      meta.addAttributeModifier(attribute.getText(), itemAttribute);
    }
  }
  /* TODO: can-destroy & can-place-on, and all attributes
   * @link https://docs.oc.tc/modules/item_mods#itemmeta
   */
  itemStack.setItemMeta(meta);
  return itemStack;
}