mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-06 18:47:44 +01:00
Replacing the potion data avoids the NPE and appears to avoid applying the main effect as desired.
This commit is contained in:
parent
66297bd2e5
commit
03c00f258e
@ -7,6 +7,8 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.potion.PotionData;
|
||||||
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
// Workaround to remove unwanted potion effects
|
// Workaround to remove unwanted potion effects
|
||||||
public class Compat1_9 implements Listener {
|
public class Compat1_9 implements Listener {
|
||||||
@ -20,12 +22,10 @@ public class Compat1_9 implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item.getType() == Material.POTION) {
|
if (item.getType() == Material.POTION) {
|
||||||
try {
|
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
||||||
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
// Throw away former "base" effect and replace with MUNDANE.
|
||||||
// Throw away former "base" effect and replace with MUNDANE.
|
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
|
||||||
meta.setBasePotionData(new PotionData(PotionType.MUNDANE, false, false));
|
item.setItemMeta(meta);
|
||||||
item.setItemMeta(meta);
|
|
||||||
} catch (Exception exception) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user