当前位置: 首页>>代码示例>>Java>>正文


Java Potion.setSplash方法代码示例

本文整理汇总了Java中org.bukkit.potion.Potion.setSplash方法的典型用法代码示例。如果您正苦于以下问题:Java Potion.setSplash方法的具体用法?Java Potion.setSplash怎么用?Java Potion.setSplash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.potion.Potion的用法示例。


在下文中一共展示了Potion.setSplash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setMainPotionEffect

import org.bukkit.potion.Potion; //导入方法依赖的package包/类
public ItemBuilder setMainPotionEffect(PotionType type, boolean extendedDurability, int level, boolean splash) {
    if (! (meta instanceof PotionMeta))
        return this;

    Potion potion = Potion.fromItemStack(stack);
    potion.setType(type);

    if (! type.isInstant())
        potion.setHasExtendedDuration(extendedDurability);

    potion.setLevel(level);
    potion.setSplash(splash);

    potion.apply(stack);

    return this;
}
 
开发者ID:shawlaf,项目名称:Banmanager,代码行数:18,代码来源:ItemBuilder.java

示例2: parseItem

import org.bukkit.potion.Potion; //导入方法依赖的package包/类
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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:51,代码来源:GlobalItemParser.java


注:本文中的org.bukkit.potion.Potion.setSplash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。