diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index f207619ee..dd0232558 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -31,6 +31,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscB import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscInteractFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MycelGrowFlag; +import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlayerInteractFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PveFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PvpFlag; @@ -2919,7 +2920,7 @@ import java.util.regex.Pattern; return; } } else if (!plot.isAdded(pp.getUUID())) { - Set place = plot.getFlag(Flags.PLACE, null); + List place = plot.getFlag(PlaceFlag.class); if (place != null) { Block block = event.getBlock(); if (place.contains(BukkitAdapter.asBlockType(block.getType()))) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index 4e157554a..eaa40af5c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -609,6 +609,7 @@ public enum Captions implements Caption { FLAG_DESCRIPTION_NOTIFY_ENTER("Set to `true` to notify the plot owners when someone enters the plot.", "Flags"), FLAG_DESCRIPTION_NOTIFY_LEAVE("Set to `true` to notify the plot owners when someone leaves the plot.", "Flags"), FLAG_DESCRIPTION_NO_WORLDEDIT("Set to `true` to disable WorldEdit usage within the plot.", "Flags"), + FLAG_DESCRIPTION_PLACE("Define a list of materials players should be able to place in the plot.", "Flags"), FLAG_DESCRIPTION_PLAYER_INTERACT("Set to `true` to allow guests to interact with players in the plot.", "Flags"), FLAG_DESCRIPTION_PRICE("Set a price for a plot. Must be a positive decimal number.", "Flags"), FLAG_DESCRIPTION_PVE("Set to `true` to enable PVE inside the plot.", "Flags"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java index cdb69826f..74b7cbd4b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/GlobalFlagContainer.java @@ -48,6 +48,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Mycel import com.github.intellectualsites.plotsquared.plot.flags.implementations.NoWorldeditFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.NotifyEnterFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.NotifyLeaveFlag; +import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlayerInteractFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlotWeatherFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag; @@ -161,6 +162,7 @@ public final class GlobalFlagContainer extends FlagContainer { // Block type list flags this.addFlag(BreakFlag.BREAK_NONE); + this.addFlag(PlaceFlag.PLACE_NONE); // Misc diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/PlaceFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/PlaceFlag.java new file mode 100644 index 000000000..1778fcbdb --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/PlaceFlag.java @@ -0,0 +1,21 @@ +package com.github.intellectualsites.plotsquared.plot.flags.implementations; + +import com.github.intellectualsites.plotsquared.plot.config.Captions; +import com.github.intellectualsites.plotsquared.plot.flags.types.BlockTypeListFlag; +import com.sk89q.worldedit.world.block.BlockType; +import org.jetbrains.annotations.NotNull; + +import java.util.Collections; +import java.util.List; + +public class PlaceFlag extends BlockTypeListFlag { + public static final PlaceFlag PLACE_NONE = new PlaceFlag(Collections.emptyList()); + + protected PlaceFlag(List blockTypeList) { + super(blockTypeList, Captions.FLAG_DESCRIPTION_PLACE); + } + + @Override protected PlaceFlag flagOf(@NotNull List value) { + return new PlaceFlag(value); + } +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java index 1b4f1e7f3..28e0fc3c3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java @@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DeviceInteractFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscPlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag; +import com.github.intellectualsites.plotsquared.plot.flags.implementations.PlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.VehiclePlaceFlag; import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType; import com.github.intellectualsites.plotsquared.plot.object.Location; @@ -183,13 +184,10 @@ public abstract class EventUtil { if (plot.getFlag(MobPlaceFlag.class)) { return true; } - Optional> flagValue = plot.getFlag(Flags.PLACE); - Set value = flagValue.orElse(null); - if (value == null || !value.contains(BlockTypes.AIR) && !value - .contains(blockType)) { - if (Permissions.hasPermission(player, - Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), - false)) { + List place = plot.getFlag(PlaceFlag.class); + if (!place.contains(BlockTypes.AIR) && !place.contains(blockType)) { + if (Permissions + .hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false)) { return true; } return !(!notifyPerms || MainUtil @@ -213,13 +211,10 @@ public abstract class EventUtil { if (plot.getFlag(MiscPlaceFlag.class)) { return true; } - Optional> flag = plot.getFlag(Flags.PLACE); - Set value = flag.orElse(null); - if (value == null || !value.contains(BlockTypes.AIR) && !value - .contains(blockType)) { - if (Permissions.hasPermission(player, - Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), - false)) { + List place = plot.getFlag(PlaceFlag.class); + if (!place.contains(BlockTypes.AIR) && !place.contains(blockType)) { + if (Permissions + .hasPermission(player, Captions.PERMISSION_ADMIN_INTERACT_OTHER.getTranslated(), false)) { return true; } return !(!notifyPerms || MainUtil