From 1c0f20910cc5fd7c002746bd975237803891c023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 13 Feb 2020 13:47:09 +0100 Subject: [PATCH] Port DenyExitFlag --- .../plotsquared/plot/config/Captions.java | 1 + .../plotsquared/plot/flag/Flags.java | 1 - .../plot/flags/GlobalFlagContainer.java | 2 ++ .../flags/implementations/DenyExitFlag.java | 23 +++++++++++++++++++ .../plot/flags/implementations/MusicFlag.java | 3 +-- .../implementations/UntrustedVisitFlag.java | 2 +- .../plot/listener/PlotListener.java | 3 ++- 7 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/DenyExitFlag.java 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 7b96bc654..3b1fbc494 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 @@ -551,6 +551,7 @@ public enum Captions implements Caption { FLAG_DESCRIPTION_MUSIC("Set to a music disk ID (item name) to play the music disc inside of the plot", "Flags"), FLAG_DESCRIPTION_FLIGHT("Set to 'true' to enable flight within the plot when in survival or adventure mode", "Flags"), FLAG_DESCRIPTION_UNTRUSTED("Set to 'false' to disallow untrusted players from visiting the plot", "Flags"), + FLAG_DESCRIPTION_DENY_EXIT("Set to 'true' to disallow players from exiting the plot", "Flags"), // // FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java index d59ba25e9..ad30bd0bd 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java @@ -109,6 +109,5 @@ public final class Flags { }; public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport"); - public static final BooleanFlag DENY_EXIT = new BooleanFlag("deny-exit"); } 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 4def71bb4..2e57a9081 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 @@ -1,5 +1,6 @@ package com.github.intellectualsites.plotsquared.plot.flags; +import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag; @@ -44,6 +45,7 @@ public final class GlobalFlagContainer extends FlagContainer { this.addFlag(MusicFlag.MUSIC_FLAG_NONE); this.addFlag(FlightFlag.FLIGHT_FLAG_FALSE); this.addFlag(UntrustedVisitFlag.UNTRUSTED_VISIT_FLAG_TRUE); + this.addFlag(DenyExitFlag.DENY_EXIT_FLAG_TRUE); } @Override public void addFlag(PlotFlag flag) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/DenyExitFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/DenyExitFlag.java new file mode 100644 index 000000000..d3181c9c2 --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/DenyExitFlag.java @@ -0,0 +1,23 @@ +package com.github.intellectualsites.plotsquared.plot.flags.implementations; + +import com.github.intellectualsites.plotsquared.plot.config.Captions; +import com.github.intellectualsites.plotsquared.plot.flags.types.BooleanFlag; +import org.jetbrains.annotations.NotNull; + +public class DenyExitFlag extends BooleanFlag { + + public static final DenyExitFlag DENY_EXIT_FLAG_TRUE = new DenyExitFlag(true); + + protected DenyExitFlag(boolean value) { + super(value, Captions.FLAG_DESCRIPTION_DENY_EXIT); + } + + @Override public String getExample() { + return "true"; + } + + @Override protected DenyExitFlag flagOf(@NotNull Boolean value) { + return new DenyExitFlag(value); + } + +} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/MusicFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/MusicFlag.java index 75fc34669..07fa807b3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/MusicFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/MusicFlag.java @@ -8,8 +8,7 @@ import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import org.jetbrains.annotations.NotNull; - -public final class MusicFlag extends PlotFlag { +public class MusicFlag extends PlotFlag { public static final MusicFlag MUSIC_FLAG_NONE = new MusicFlag(ItemTypes.AIR); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/UntrustedVisitFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/UntrustedVisitFlag.java index 94ec7aabf..9d587f626 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/UntrustedVisitFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/UntrustedVisitFlag.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; public class UntrustedVisitFlag extends BooleanFlag { - public static UntrustedVisitFlag UNTRUSTED_VISIT_FLAG_TRUE = new UntrustedVisitFlag(true); + public static final UntrustedVisitFlag UNTRUSTED_VISIT_FLAG_TRUE = new UntrustedVisitFlag(true); protected UntrustedVisitFlag(boolean value) { super(value, Captions.FLAG_DESCRIPTION_UNTRUSTED); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java index 0df23ec20..e5d762e74 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java @@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.Flags; +import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.FlightFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag; import com.github.intellectualsites.plotsquared.plot.object.Location; @@ -213,7 +214,7 @@ public class PlotListener { if (pw == null) { return true; } - if (Flags.DENY_EXIT.isTrue(plot) + if (plot.getFlag(DenyExitFlag.class) && !Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_EXIT_DENIED) && !player.getMeta("kick", false)) { if (previous != null) {