Fixed MILKING flag not protecting milking Mooshrooms (#602)

Add extra PlayerInteractEntityEvent handling that prevents from using bowl on mooshrooms without MILKING protection flag.
This commit is contained in:
BONNe 2019-03-08 21:40:42 +02:00 committed by Florian CUNY
parent 07b4e2d30c
commit d11a27dc6d

View File

@ -2,6 +2,7 @@ package world.bentobox.bentobox.listeners.flags.protection;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.TropicalFish; import org.bukkit.entity.TropicalFish;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -59,4 +60,16 @@ public class BucketListener extends FlagListener {
checkIsland(e, e.getPlayer(), e.getRightClicked().getLocation(), Flags.FISH_SCOOPING); 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);
}
}
} }