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


Java PotionType.valueOf方法代碼示例

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


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

示例1: addPotion

import org.bukkit.potion.PotionType; //導入方法依賴的package包/類
/**
 * 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()));
    }
}
 
開發者ID:redwallhp,項目名稱:AthenaGM,代碼行數:25,代碼來源:MapInfoKitItem.java

示例2: read

import org.bukkit.potion.PotionType; //導入方法依賴的package包/類
@Override
public void read(DataInputStream input) throws IOException {
    PotionType type = PotionType.valueOf(input.readUTF());
    boolean extended = input.readBoolean();
    boolean upgraded = input.readBoolean();
    
    setValue(new PotionData(type, extended, upgraded));
}
 
開發者ID:OrigamiDream,項目名稱:Leveled-Storage,代碼行數:9,代碼來源:PotionDataStorage.java

示例3: setType

import org.bukkit.potion.PotionType; //導入方法依賴的package包/類
public void setType(String type) throws InstructionParseException {
	typeE = Existence.REQUIRED;
	try {
		this.type = PotionType.valueOf(type.toUpperCase());
	} catch (IllegalArgumentException e) {
		throw new InstructionParseException("No such potion type: " + type);
	}
}
 
開發者ID:Co0sh,項目名稱:BetonQuest,代碼行數:9,代碼來源:PotionHandler.java

示例4: build

import org.bukkit.potion.PotionType; //導入方法依賴的package包/類
@Override
public ItemStack build(ItemStack stack) {
  if(valid) {
    PotionMeta meta = (PotionMeta)stack.getItemMeta();
    if(color != null) meta.setColor(color);
    customEffects.forEach((effect)->meta.addCustomEffect(effect, true));
    PotionData data = new PotionData(PotionType.valueOf(type), extended, upgraded);
    meta.setBasePotionData(data);
    stack.setItemMeta(meta);
  }
  return stack;
}
 
開發者ID:TheNewEconomy,項目名稱:TNE-Bukkit,代碼行數:13,代碼來源:SerialPotionData.java

示例5: getBukkitPotionType

import org.bukkit.potion.PotionType; //導入方法依賴的package包/類
public PotionType getBukkitPotionType() {
    return PotionType.valueOf(this.name());
}
 
開發者ID:AlexMl,項目名稱:ZvP,代碼行數:4,代碼來源:KEssentialsKit.java


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