本文整理汇总了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());
}