當前位置: 首頁>>代碼示例>>Java>>正文


Java Potion.isSplash方法代碼示例

本文整理匯總了Java中org.bukkit.potion.Potion.isSplash方法的典型用法代碼示例。如果您正苦於以下問題:Java Potion.isSplash方法的具體用法?Java Potion.isSplash怎麽用?Java Potion.isSplash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.potion.Potion的用法示例。


在下文中一共展示了Potion.isSplash方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: build

import org.bukkit.potion.Potion; //導入方法依賴的package包/類
public Potion build() {
   Potion potion = new Potion(type);
   potion.setLevel(this.level);
   if(potion.isSplash()) {
      potion.setHasExtendedDuration(this.extended);
   }
   return potion;
}
 
開發者ID:PaulBGD,項目名稱:MiniMiniGames,代碼行數:9,代碼來源:PotionBuilder.java

示例3: fromPotion

import org.bukkit.potion.Potion; //導入方法依賴的package包/類
/**
    * This parses an Potion into an instance of PotionLayer. This lets you get the potion type, if the potion is strong, if the potion is long, if the potion is lingering, and if the potion is a
    * splash potion.
    * 
    * @param item
    * @return {@link PotionLayer}. If it fails to parse, or the item argument is not a valid potion this will return null.
    * @throws Exception
    */
   @Deprecated
   private static PotionLayer fromPotion(Potion potion) throws Exception {
PotionType type = PotionType.match(potion.getType());
if (type == null) {
    throw new Exception("no enum for " + potion.getType().name());
}
return new PotionLayer(type, potion.getLevel() > 1, potion.hasExtendedDuration(), false, potion.isSplash());
   }
 
開發者ID:AlexMl,項目名稱:ZvP,代碼行數:17,代碼來源:PotionLayer.java


注:本文中的org.bukkit.potion.Potion.isSplash方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。