From d11a27dc6dab2b788cc5dbe4017e4da23baa0aaf Mon Sep 17 00:00:00 2001 From: BONNe Date: Fri, 8 Mar 2019 21:40:42 +0200 Subject: [PATCH] Fixed MILKING flag not protecting milking Mooshrooms (#602) Add extra PlayerInteractEntityEvent handling that prevents from using bowl on mooshrooms without MILKING protection flag. --- .../listeners/flags/protection/BucketListener.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BucketListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BucketListener.java index 640a6d9dd..026fb13d2 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BucketListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/BucketListener.java @@ -2,6 +2,7 @@ package world.bentobox.bentobox.listeners.flags.protection; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.entity.MushroomCow; import org.bukkit.entity.TropicalFish; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -59,4 +60,16 @@ public class BucketListener extends FlagListener { checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.FISH_SCOOPING); } } + + + /** + * Prevents collecting mushroom strew from MushroomCow if player does not have access to Milking flag. + * @param e - event + */ + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onBowlFill(final PlayerInteractEntityEvent e) { + if (e.getRightClicked() instanceof MushroomCow && e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.BOWL)) { + checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.MILKING); + } + } } \ No newline at end of file