mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Port flight flag
This commit is contained in:
parent
8e729f6949
commit
30d2785ef2
@ -549,6 +549,7 @@ public enum Captions implements Caption {
|
|||||||
//<editor-fold desc="Flag descriptions">
|
//<editor-fold desc="Flag descriptions">
|
||||||
FLAG_DESCRIPTION_EXPLOSION("Set to 'true' to enable explosions in the plot, and 'false' to disable them", "Flags"),
|
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_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"),
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
//<editor-fold desc="Flag category errors">
|
//<editor-fold desc="Flag category errors">
|
||||||
FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"),
|
FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"),
|
||||||
|
@ -24,7 +24,6 @@ public final class Flags {
|
|||||||
public static final GameModeFlag GUEST_GAMEMODE = new GameModeFlag("guest-gamemode");
|
public static final GameModeFlag GUEST_GAMEMODE = new GameModeFlag("guest-gamemode");
|
||||||
public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve();
|
public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve();
|
||||||
public static final BooleanFlag REDSTONE = new BooleanFlag("redstone");
|
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 NOTIFY_LEAVE = new BooleanFlag("notify-leave");
|
||||||
public static final BooleanFlag TITLES = new BooleanFlag("titles");
|
public static final BooleanFlag TITLES = new BooleanFlag("titles");
|
||||||
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags;
|
package com.github.intellectualsites.plotsquared.plot.flags;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.ExplosionFlag;
|
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 com.github.intellectualsites.plotsquared.plot.flags.implementations.MusicFlag;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||||||
// Register all default flags here
|
// Register all default flags here
|
||||||
this.addFlag(ExplosionFlag.EXPLOSION_FALSE);
|
this.addFlag(ExplosionFlag.EXPLOSION_FALSE);
|
||||||
this.addFlag(MusicFlag.MUSIC_FLAG_NONE);
|
this.addFlag(MusicFlag.MUSIC_FLAG_NONE);
|
||||||
|
this.addFlag(FlightFlag.FLIGHT_FLAG_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void addFlag(PlotFlag<?, ?> flag) {
|
@Override public void addFlag(PlotFlag<?, ?> flag) {
|
||||||
|
@ -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<FlightFlag> {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -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.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
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.flags.implementations.MusicFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
@ -94,8 +95,8 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
|
||||||
if (flyFlag.isPresent()) {
|
if (plot.getFlag(FlightFlag.class)) {
|
||||||
boolean flight = player.getFlight();
|
boolean flight = player.getFlight();
|
||||||
GameMode gamemode = player.getGameMode();
|
GameMode gamemode = player.getGameMode();
|
||||||
if (flight != (gamemode == GameModes.CREATIVE
|
if (flight != (gamemode == GameModes.CREATIVE
|
||||||
@ -103,10 +104,9 @@ public class PlotListener {
|
|||||||
player.setPersistentMeta("flight",
|
player.setPersistentMeta("flight",
|
||||||
ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
||||||
}
|
}
|
||||||
if (flyFlag.get() != player.getFlight()) {
|
player.setFlight(true);
|
||||||
player.setFlight(flyFlag.get());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<GameMode> gamemodeFlag = plot.getFlag(Flags.GAMEMODE);
|
Optional<GameMode> gamemodeFlag = plot.getFlag(Flags.GAMEMODE);
|
||||||
if (gamemodeFlag.isPresent()) {
|
if (gamemodeFlag.isPresent()) {
|
||||||
if (player.getGameMode() != gamemodeFlag.get()) {
|
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")) {
|
if (player.hasPersistentMeta("flight")) {
|
||||||
player.setFlight(
|
player.setFlight(
|
||||||
ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
ByteArrayUtilities.bytesToBoolean(player.getPersistentMeta("flight")));
|
||||||
@ -268,6 +269,7 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plot.getFlag(Flags.TIME).isPresent()) {
|
if (plot.getFlag(Flags.TIME).isPresent()) {
|
||||||
player.setTime(Long.MAX_VALUE);
|
player.setTime(Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user