mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-03-14 15:49:10 +01:00
Adds protection for berries #2272
This commit is contained in:
parent
ce4d8a377e
commit
2d44c5dbca
src/main/java/world/bentobox/bentobox
@ -4,6 +4,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.CaveVinesPlant;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
@ -20,6 +21,7 @@ import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
@ -76,14 +78,27 @@ public class BreakBlocksListener extends FlagListener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent e)
|
||||
{
|
||||
// Only handle hitting things
|
||||
if (!e.getAction().equals(Action.LEFT_CLICK_BLOCK) || e.getClickedBlock() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
Location l = e.getClickedBlock().getLocation();
|
||||
Material m = e.getClickedBlock().getType();
|
||||
BentoBox.getInstance().logDebug(m);
|
||||
// Check for berry picking
|
||||
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && (e.getClickedBlock().getType() == Material.CAVE_VINES || e.getClickedBlock().getType() == Material.CAVE_VINES_PLANT)) {
|
||||
if (!((CaveVinesPlant) e.getClickedBlock().getBlockData()).isBerries()) {
|
||||
return;
|
||||
}
|
||||
this.checkIsland(e, p, l, Flags.HARVEST);
|
||||
return;
|
||||
}
|
||||
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getClickedBlock().getType() == Material.SWEET_BERRY_BUSH) {
|
||||
this.checkIsland(e, p, l, Flags.HARVEST);
|
||||
return;
|
||||
}
|
||||
// Only handle hitting things
|
||||
if (!(e.getAction() == Action.LEFT_CLICK_BLOCK) || e.getClickedBlock() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (m)
|
||||
{
|
||||
case CAKE -> this.checkIsland(e, p, l, Flags.BREAK_BLOCKS);
|
||||
|
@ -15,6 +15,7 @@ import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
|
||||
/**
|
||||
* Listener for {@link Flags#CROP_TRAMPLE, Flags#PRESSURE_PLATE, Flags#TURTLE_EGGS, Flags#BUTTON}
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
|
@ -666,6 +666,7 @@ public final class Flags {
|
||||
/**
|
||||
* Harvest Setting
|
||||
* Controls who gets to harvest any crop related contents. e.g. Wheat, Sugar Cane, melon blocks, not stems, pumpkin blocks, etc.
|
||||
* Listener is {@link BreakBlocksListener}
|
||||
* @since 1.23.0
|
||||
*/
|
||||
public static final Flag HARVEST = new Flag.Builder("HARVEST", Material.PUMPKIN).mode(Flag.Mode.BASIC).type(Type.PROTECTION).build();
|
||||
|
Loading…
Reference in New Issue
Block a user