/**
* 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()));
}
}
MapInfoKitItem.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:AthenaGM
作者:
评论列表
文章目录