本文整理匯總了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()));
}
}
示例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));
}
示例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);
}
}
示例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;
}
示例5: getBukkitPotionType
import org.bukkit.potion.PotionType; //導入方法依賴的package包/類
public PotionType getBukkitPotionType() {
return PotionType.valueOf(this.name());
}