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 f7ad419c0..3ef4bc00d 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 @@ -549,6 +549,7 @@ public enum Captions implements Caption { // FLAG_DESCRIPTION_EXPLOSION("Set to 'true' to enable explosions in the plot, and 'false' to disable them", "Flags"), 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_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 bd1f6b9a0..b2829b047 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 @@ -24,7 +24,6 @@ public final class Flags { public static final GameModeFlag GUEST_GAMEMODE = new GameModeFlag("guest-gamemode"); public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve(); public static final BooleanFlag REDSTONE = new BooleanFlag("redstone"); - public static final BooleanFlag FLY = new BooleanFlag("fly"); public static final BooleanFlag NOTIFY_LEAVE = new BooleanFlag("notify-leave"); public static final BooleanFlag TITLES = new BooleanFlag("titles"); public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter"); 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 88efccb8b..b86085f26 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,6 +1,7 @@ package com.github.intellectualsites.plotsquared.plot.flags; 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; import lombok.Getter; @@ -40,6 +41,7 @@ public final class GlobalFlagContainer extends FlagContainer { // Register all default flags here this.addFlag(ExplosionFlag.EXPLOSION_FALSE); this.addFlag(MusicFlag.MUSIC_FLAG_NONE); + this.addFlag(FlightFlag.FLIGHT_FLAG_FALSE); } @Override public void addFlag(PlotFlag flag) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/FlightFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/FlightFlag.java new file mode 100644 index 000000000..099145165 --- /dev/null +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/implementations/FlightFlag.java @@ -0,0 +1,22 @@ +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 FlightFlag extends BooleanFlag { + + public static final FlightFlag FLIGHT_FLAG_FALSE = new FlightFlag(false); + + protected FlightFlag(final boolean value) { + super(value, Captions.FLAG_DESCRIPTION_FLIGHT); + } + + @Override public String getExample() { + return "true"; + } + + @Override protected FlightFlag flagOf(@NotNull Boolean value) { + return new FlightFlag(value); + } +} 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 8ad94cfb4..0df23ec20 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.FlightFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag; import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Plot; @@ -94,8 +95,8 @@ public class PlotListener { } } } - Optional flyFlag = plot.getFlag(Flags.FLY); - if (flyFlag.isPresent()) { + + if (plot.getFlag(FlightFlag.class)) { boolean flight = player.getFlight(); GameMode gamemode = player.getGameMode(); if (flight != (gamemode == GameModes.CREATIVE @@ -103,10 +104,9 @@ public class PlotListener { player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight())); } - if (flyFlag.get() != player.getFlight()) { - player.setFlight(flyFlag.get()); - } + player.setFlight(true); } + Optional gamemodeFlag = plot.getFlag(Flags.GAMEMODE); if (gamemodeFlag.isPresent()) { if (player.getGameMode() != gamemodeFlag.get()) { @@ -254,7 +254,8 @@ public class PlotListener { } } } - if (plot.getFlag(Flags.FLY).isPresent()) { + + if (plot.getFlag(FlightFlag.class)) { if (player.hasPersistentMeta("flight")) { player.setFlight( ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight"))); @@ -268,6 +269,7 @@ public class PlotListener { } } } + if (plot.getFlag(Flags.TIME).isPresent()) { player.setTime(Long.MAX_VALUE); }