Hey guys, I have spent the last few hours of my life by starting the coding of a KitPvP plugin. It took me awhile to sort out my souping issues but I have one final bug I can not squash. Whenever a player instantly eats the soup it should turn into an empty bowl, right? Well thats where my issue is. Code: @EventHandler public void onPlayerInteract(PlayerInteractEvent event1){ if (event1.getAction() == Action.RIGHT_CLICK_AIR || event1.getAction() == Action.RIGHT_CLICK_BLOCK) { Player player = event1.getPlayer(); if (player.getItemInHand().getType() == Material.MUSHROOM_SOUP); player.setHealth(player.getHealth() + Math.min(3, player.getMaxHealth()-player.getHealth())); ItemStack bowl = new ItemStack(Material.BOWL, 1); player.getInventory().setItemInHand(bowl);
How would I cancel the event? epicfacecreeper When the player drinks the soup the soup doesn't turn into a bowl, rather it keeps the soup.
Code:java @EventHandlerpublic void onPlayerInteract(PlayerInteractEvent event1){if (event1.getAction() == Action.RIGHT_CLICK_AIR || event1.getAction() == Action.RIGHT_CLICK_BLOCK) {Player player = event1.getPlayer();if (player.getItemInHand().getType() == Material.MUSHROOM_SOUP) {if (player.getHealth() == 20)return; event.setCancelled(true);player.setHealth(player.getHealth() > 14 ? 20 : player.getHealth() + 6);player.getItemInHand().setType(Material.BOWL);} That's my soup plugin, heals 3 hearts at a time.