Hello, i'm trying to find the best way to cancel a player from use Strenght 2, the method should check if it's a normal potion or a splash potion, when player tried to consume or throw the player potion then it convert into a bottle of water. So now i want know what are the best events to check it, because i tried cancelling PotionSplashEvent and don't seems to work, and when its not a splash potion i tried with PlayerItemConsumeEvent but also don't seems to work.. Some code that don't work: Code (Text): public void str (PlayerItemConsumeEvent e){ ItemStack pot = e.getItem(); if ((pot.getType() == Material.POTION) && ((pot.getDurability() == 8233))){ e.setCancelled(true); }
I think you should use these classes instead of durability. It might work a little better. I'll see if i can whip something up in a bit if you still can't figure it out. https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectTypeWrapper.html https://hub.spigotmc.org/javadocs/bukkit/index.html?org/bukkit/potion/PotionEffectTypeWrapper.html
Ups, i think i find the problem in the code that i paste up, i forgot @EventHandler. Now it's working with normal potion. So now i need help with the splash potion :l
PotionSplashEvent don't seems to work, because the event starts when the potion explodes and releases the effects. I will try with PlayerInteractEvent. If you have better suggestions i'm open to try.