Adds Chiseled Bookshelf protection #2136

This commit is contained in:
tastybento 2023-07-01 10:04:05 -07:00
parent f23ebec34e
commit 7b8e18afff
3 changed files with 26 additions and 13 deletions

View File

@ -99,7 +99,7 @@ public class BlockInteractionListener extends FlagListener
this.checkIsland(e, player, loc, Flags.FLOWER_POT);
return;
}
if (block.getState() instanceof BrushableBlock bb && BlockInteractionListener.holds(player, Material.BRUSH)) {
// Protect this using break blocks flag for now. Maybe in the future it can have its own flag.
this.checkIsland(e, player, loc, Flags.BREAK_BLOCKS);
@ -171,14 +171,12 @@ public class BlockInteractionListener extends FlagListener
case DISPENSER -> this.checkIsland(e, player, loc, Flags.DISPENSER);
case DROPPER -> this.checkIsland(e, player, loc, Flags.DROPPER);
case HOPPER, HOPPER_MINECART -> this.checkIsland(e, player, loc, Flags.HOPPER);
case BLAST_FURNACE, CAMPFIRE, FURNACE_MINECART, FURNACE, SMOKER ->
this.checkIsland(e, player, loc, Flags.FURNACE);
case BLAST_FURNACE, CAMPFIRE, FURNACE_MINECART, FURNACE, SMOKER -> this.checkIsland(e, player, loc, Flags.FURNACE);
case ENCHANTING_TABLE -> this.checkIsland(e, player, loc, Flags.ENCHANTING);
case ENDER_CHEST -> this.checkIsland(e, player, loc, Flags.ENDER_CHEST);
case JUKEBOX -> this.checkIsland(e, player, loc, Flags.JUKEBOX);
case NOTE_BLOCK -> this.checkIsland(e, player, loc, Flags.NOTE_BLOCK);
case CRAFTING_TABLE, CARTOGRAPHY_TABLE, GRINDSTONE, STONECUTTER, LOOM ->
this.checkIsland(e, player, loc, Flags.CRAFTING);
case CRAFTING_TABLE, CARTOGRAPHY_TABLE, GRINDSTONE, STONECUTTER, LOOM -> this.checkIsland(e, player, loc, Flags.CRAFTING);
case LEVER -> this.checkIsland(e, player, loc, Flags.LEVER);
case REDSTONE_WIRE, REPEATER, COMPARATOR, DAYLIGHT_DETECTOR -> this.checkIsland(e, player, loc, Flags.REDSTONE);
case DRAGON_EGG -> this.checkIsland(e, player, loc, Flags.DRAGON_EGG);
@ -186,6 +184,7 @@ public class BlockInteractionListener extends FlagListener
case GLOW_ITEM_FRAME, ITEM_FRAME -> this.checkIsland(e, player, loc, Flags.ITEM_FRAME);
case SWEET_BERRY_BUSH, CAVE_VINES -> this.checkIsland(e, player, loc, Flags.BREAK_BLOCKS);
case CAKE -> this.checkIsland(e, player, loc, Flags.CAKE);
case CHISELED_BOOKSHELF -> this.checkIsland(e, player, loc, Flags.BOOKSHELF);
case LAVA_CAULDRON ->
{
if (BlockInteractionListener.holds(player, Material.BUCKET))

View File

@ -9,6 +9,7 @@ import org.bukkit.Material;
import com.google.common.base.Enums;
import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.flags.Flag.Mode;
import world.bentobox.bentobox.api.flags.Flag.Type;
import world.bentobox.bentobox.api.flags.clicklisteners.CycleClick;
import world.bentobox.bentobox.listeners.flags.clicklisteners.CommandRankClickListener;
@ -158,11 +159,18 @@ public final class Flags {
* @since 1.10.0
* @see LecternListener
*/
public static final Flag LECTERN = new Flag.Builder("LECTERN", Material.LECTERN).listener(new LecternListener()).build();
public static final Flag LECTERN = new Flag.Builder("LECTERN", Material.LECTERN).mode(Mode.ADVANCED).listener(new LecternListener()).build();
/**
* Prevents players from placing a book in a bookshelf or taking the book from it.
* @since 1.24.0
* @see BlockInteractionListener
*/
public static final Flag BOOKSHELF = new Flag.Builder("BOOKSHELF", Material.CHISELED_BOOKSHELF).mode(Mode.ADVANCED).build();
// Entity interactions
public static final Flag ARMOR_STAND = new Flag.Builder("ARMOR_STAND", Material.ARMOR_STAND).listener(new EntityInteractListener()).mode(Flag.Mode.ADVANCED).build();
public static final Flag RIDING = new Flag.Builder("RIDING", Material.GOLDEN_HORSE_ARMOR).build();
public static final Flag ARMOR_STAND = new Flag.Builder("ARMOR_STAND", Material.ARMOR_STAND).listener(new EntityInteractListener()).mode(Mode.ADVANCED).build();
public static final Flag RIDING = new Flag.Builder("RIDING", Material.GOLDEN_HORSE_ARMOR).mode(Mode.ADVANCED).build();
/**
* Prevents players from issuing any kind of interactions with Minecarts (entering, placing and opening if chest).
* @since 1.3.0
@ -188,7 +196,7 @@ public final class Flags {
// Buckets. All bucket use is covered by one listener
public static final Flag BUCKET = new Flag.Builder("BUCKET", Material.BUCKET).listener(new BucketListener()).mode(Flag.Mode.BASIC).build();
public static final Flag COLLECT_LAVA = new Flag.Builder("COLLECT_LAVA", Material.LAVA_BUCKET).build();
public static final Flag COLLECT_LAVA = new Flag.Builder("COLLECT_LAVA", Material.LAVA_BUCKET).mode(Mode.ADVANCED).build();
public static final Flag COLLECT_WATER = new Flag.Builder("COLLECT_WATER", Material.WATER_BUCKET).mode(Flag.Mode.ADVANCED).build();
/**
* @since 1.21
@ -215,7 +223,7 @@ public final class Flags {
* Prevents players from throwing eggs.
* @see EggListener
*/
public static final Flag EGGS = new Flag.Builder("EGGS", Material.EGG).listener(new EggListener()).build();
public static final Flag EGGS = new Flag.Builder("EGGS", Material.EGG).mode(Mode.ADVANCED).listener(new EggListener()).build();
/**
* Prevents players from throwing potions / experience bottles.
* @since 1.1
@ -259,7 +267,7 @@ public final class Flags {
* Prevents players from extinguishing fires.
* @see FireListener
*/
public static final Flag FIRE_EXTINGUISH = new Flag.Builder("FIRE_EXTINGUISH", Material.POTION).build();
public static final Flag FIRE_EXTINGUISH = new Flag.Builder("FIRE_EXTINGUISH", Material.POTION).mode(Mode.ADVANCED).build();
// Inventories
public static final Flag MOUNT_INVENTORY = new Flag.Builder("MOUNT_INVENTORY", Material.IRON_HORSE_ARMOR).listener(new InventoryListener()).mode(Flag.Mode.ADVANCED).build();
@ -277,12 +285,12 @@ public final class Flags {
* Prevents players from going through the Nether Portal.
* @see PortalListener
*/
public static final Flag NETHER_PORTAL = new Flag.Builder("NETHER_PORTAL", Material.NETHERRACK).listener(new PortalListener()).build();
public static final Flag NETHER_PORTAL = new Flag.Builder("NETHER_PORTAL", Material.NETHERRACK).mode(Mode.ADVANCED).listener(new PortalListener()).build();
/**
* Prevents players from going through the End Portal.
* @see PortalListener
*/
public static final Flag END_PORTAL = new Flag.Builder("END_PORTAL", Material.END_PORTAL_FRAME).build();
public static final Flag END_PORTAL = new Flag.Builder("END_PORTAL", Material.END_PORTAL_FRAME).mode(Mode.ADVANCED).build();
// Shearing
public static final Flag SHEARING = new Flag.Builder("SHEARING", Material.SHEARS).listener(new ShearingListener()).mode(Flag.Mode.ADVANCED).build();

View File

@ -776,6 +776,12 @@ protection:
Toggle placing, breaking and
entering into boats.
hint: "No boat interaction allowed"
BOOKSHELF:
name: "Bookshelves"
description: |-
&a Allow to place books
&a or to take books.
hint: "cannot place a book or take a book."
BREAK_BLOCKS:
description: "Toggle breaking"
name: "Break blocks"