Checking if the Material is a potion doesn't work, and I'm unsure what else to do I also tried this Code (Java): private boolean isPotion(ItemStack item) { try { Potion.fromItemStack(item).getLevel(); } catch (IllegalArgumentException e) { return false; } return true; } EDIT: Solved using Code (Java): private boolean isPotion(ItemStack item) { try { Potion.fromItemStack(item); } catch (IllegalArgumentException e) { return false; } return true; }
Try https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html It will help you figure out what potion is being used
Doesnt help? There is a null error when I try and use Potion potion = Potion.fromItemStack(potionItem);
Try: @EventHandler(priority = EventPriority.NORMAL) public void onPotionDrink(PlayerInteractEvent event) { Player player = event.getPlayer(); if (((event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK)) && (player.getItemInHand().getType() == Material.POTION)) { int hs = p.getInventory().getHeldItemSlot(); drink(p,hs); } } public void drink(final Player player, int hs) { plg.getServer().getScheduler().scheduleSyncDelayedTask(plg, new Runnable() { public void run() { if (player.getInventory().getItem(hs).getType() == Material.GLASS_BOTTLE) { // then ... } } }, 35); }
I'm not even using an event this is irrelevant and unrelated to the question. Just so you know checking if an item is a Material.POTION doesn't work as I said. I solved it myself, thanks anyways