mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
Fix splash potion support for /potion
. Resolves #1166
This commit is contained in:
parent
50e2d27d5b
commit
b6aea0a5f8
2 changed files with 21 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")) {
|
||||
|
|
Loading…
Reference in a new issue