diff --git a/Essentials/src/com/earth2me/essentials/MetaItemStack.java b/Essentials/src/com/earth2me/essentials/MetaItemStack.java index 26e5a4d1a..93fa1e046 100644 --- a/Essentials/src/com/earth2me/essentials/MetaItemStack.java +++ b/Essentials/src/com/earth2me/essentials/MetaItemStack.java @@ -7,6 +7,7 @@ import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.NumberUtil; import com.google.common.base.Joiner; import net.ess3.api.IEssentials; +import net.ess3.nms.refl.ReflUtil; import org.apache.commons.lang.ArrayUtils; import org.bukkit.Color; @@ -392,9 +393,17 @@ public class MetaItemStack { } pmeta.addCustomEffect(pEffect, true); stack.setItemMeta(pmeta); - Potion potion = Potion.fromItemStack(stack); - potion.setSplash(isSplashPotion); - potion.apply(stack); + if (ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_9_R1)) { + if (isSplashPotion && stack.getType() != Material.SPLASH_POTION) { + stack.setType(Material.SPLASH_POTION); + } else if (!isSplashPotion && stack.getType() != Material.POTION) { + stack.setType(Material.POTION); + } + } else { + Potion potion = Potion.fromItemStack(stack); + potion.setSplash(isSplashPotion); + potion.apply(stack); + } resetPotionMeta(); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpotion.java b/Essentials/src/com/earth2me/essentials/commands/Commandpotion.java index 7db58c196..61466aadc 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandpotion.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandpotion.java @@ -11,6 +11,7 @@ import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -23,6 +24,8 @@ import java.util.TreeSet; import static com.earth2me.essentials.I18n.tl; +import net.ess3.nms.refl.ReflUtil; + public class Commandpotion extends EssentialsCommand { public Commandpotion() { @@ -43,8 +46,12 @@ public class Commandpotion extends EssentialsCommand { } throw new NotEnoughArgumentsException(tl("potions", StringUtil.joinList(potionslist.toArray()))); } - - if (stack.getType() == Material.POTION) { + + boolean holdingPotion = stack.getType() == Material.POTION; + if (!holdingPotion && ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_9_R1)) { + holdingPotion = stack.getType() == Material.SPLASH_POTION || stack.getType() == Material.LINGERING_POTION; + } + if (holdingPotion) { PotionMeta pmeta = (PotionMeta) stack.getItemMeta(); if (args.length > 0) { if (args[0].equalsIgnoreCase("clear")) {