mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-08 09:27:38 +01:00
Use BlockInteractionListener to protect Hives and Bee Nests
This commit is contained in:
parent
770d8b0bef
commit
b27d0bbca4
@ -131,9 +131,11 @@ public class BlockInteractionListener extends FlagListener {
|
||||
case CAULDRON:
|
||||
checkIsland(e, player, loc, Flags.BREWING);
|
||||
break;
|
||||
case BARREL:
|
||||
case BEEHIVE:
|
||||
case BEE_NEST:
|
||||
checkIsland(e, player, loc, Flags.HIVE);
|
||||
break;
|
||||
case BARREL:
|
||||
case CHEST:
|
||||
case CHEST_MINECART:
|
||||
case TRAPPED_CHEST:
|
||||
|
@ -1,26 +0,0 @@
|
||||
package world.bentobox.bentobox.listeners.flags.protection;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerHarvestBlockEvent;
|
||||
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
/**
|
||||
* Handles harvesting
|
||||
* @author tastybento
|
||||
* @since 1.16.0
|
||||
*/
|
||||
public class HarvestListener extends FlagListener {
|
||||
|
||||
/**
|
||||
* Handle visitor harvesting, e.g. honey
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public boolean onHarvest(PlayerHarvestBlockEvent e) {
|
||||
return checkIsland(e, e.getPlayer(), e.getHarvestedBlock().getLocation(), Flags.HARVEST);
|
||||
}
|
||||
}
|
@ -23,7 +23,6 @@ import world.bentobox.bentobox.listeners.flags.protection.ElytraListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.EntityInteractListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.ExperiencePickupListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.FireListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.HarvestListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.HurtingListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.InventoryListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.ItemDropPickUpListener;
|
||||
@ -129,6 +128,8 @@ public final class Flags {
|
||||
public static final Flag SPAWN_EGGS = new Flag.Builder("SPAWN_EGGS", Material.COW_SPAWN_EGG).build();
|
||||
public static final Flag ITEM_FRAME = new Flag.Builder("ITEM_FRAME", Material.ITEM_FRAME).mode(Flag.Mode.ADVANCED).build();
|
||||
public static final Flag CAKE = new Flag.Builder("CAKE", Material.CAKE).build();
|
||||
public static final Flag HIVE = new Flag.Builder("HIVE", Material.HONEY_BOTTLE).type(Type.PROTECTION).build();
|
||||
|
||||
/**
|
||||
* Prevents players from interacting with the Dragon Egg.
|
||||
* @since 1.3.1
|
||||
@ -525,12 +526,6 @@ public final class Flags {
|
||||
*/
|
||||
public static final Flag PETS_STAY_AT_HOME = new Flag.Builder("PETS_STAY_AT_HOME", Material.TROPICAL_FISH).listener(new PetTeleportListener()).type(Type.WORLD_SETTING).defaultSetting(true).build();
|
||||
|
||||
/**
|
||||
* Protects against harvesting, e.g. honey
|
||||
* @since 1.16.0
|
||||
* @see HarvestListener
|
||||
*/
|
||||
public static final Flag HARVEST = new Flag.Builder("HARVEST", Material.HONEY_BOTTLE).listener(new HarvestListener()).type(Type.PROTECTION).build();
|
||||
/**
|
||||
* Provides a list of all the Flag instances contained in this class using reflection.
|
||||
* Deprecated Flags are ignored.
|
||||
|
@ -952,11 +952,10 @@ protection:
|
||||
&a outside protected
|
||||
&a island space
|
||||
name: "&e Limit mobs to island"
|
||||
HARVEST:
|
||||
HIVE:
|
||||
description: |-
|
||||
&a Toggle harvesting, e.g.
|
||||
&a honey harvesting
|
||||
name: "Harvesting"
|
||||
&a Toggle hive harvesting.
|
||||
name: "Hive harvesting"
|
||||
hint: "Harvesting disabled"
|
||||
HURT_ANIMALS:
|
||||
description: "Toggle hurting"
|
||||
|
@ -112,6 +112,8 @@ public class BlockInteractionListenerTest extends AbstractCommonSetup {
|
||||
clickedBlocks.put(Material.ITEM_FRAME, Flags.ITEM_FRAME);
|
||||
clickedBlocks.put(Material.SWEET_BERRY_BUSH, Flags.BREAK_BLOCKS);
|
||||
clickedBlocks.put(Material.CAKE, Flags.CAKE);
|
||||
clickedBlocks.put(Material.BEEHIVE, Flags.HIVE);
|
||||
clickedBlocks.put(Material.BEE_NEST, Flags.HIVE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class FlagsManagerTest {
|
||||
/**
|
||||
* Update this value if the number of registered listeners changes
|
||||
*/
|
||||
private static final int NUMBER_OF_LISTENERS = 50;
|
||||
private static final int NUMBER_OF_LISTENERS = 49;
|
||||
@Mock
|
||||
private BentoBox plugin;
|
||||
@Mock
|
||||
|
Loading…
Reference in New Issue
Block a user