mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-03 01:19:42 +01:00
Add exit-via-teleport flag (default allow).
This commit is contained in:
parent
0f4e7b5061
commit
e1843624bb
@ -109,6 +109,7 @@ public final class DefaultFlag {
|
|||||||
public static final StringFlag EXIT_DENY_MESSAGE = new StringFlag("exit-deny-message",
|
public static final StringFlag EXIT_DENY_MESSAGE = new StringFlag("exit-deny-message",
|
||||||
"" + ChatColor.RED + ChatColor.BOLD + "Hey!" + ChatColor.GRAY + " You are not permitted to leave this area.");
|
"" + ChatColor.RED + ChatColor.BOLD + "Hey!" + ChatColor.GRAY + " You are not permitted to leave this area.");
|
||||||
public static final BooleanFlag EXIT_OVERRIDE = new BooleanFlag("exit-override");
|
public static final BooleanFlag EXIT_OVERRIDE = new BooleanFlag("exit-override");
|
||||||
|
public static final StateFlag EXIT_VIA_TELEPORT = new StateFlag("exit-via-teleport", true);
|
||||||
public static final StringFlag GREET_MESSAGE = new StringFlag("greeting");
|
public static final StringFlag GREET_MESSAGE = new StringFlag("greeting");
|
||||||
public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell");
|
public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell");
|
||||||
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
||||||
@ -138,7 +139,7 @@ public final class DefaultFlag {
|
|||||||
TNT, LIGHTER, RIDE, USE, INTERACT, PLACE_VEHICLE, DESTROY_VEHICLE, SLEEP,
|
TNT, LIGHTER, RIDE, USE, INTERACT, PLACE_VEHICLE, DESTROY_VEHICLE, SLEEP,
|
||||||
MOB_DAMAGE, MOB_SPAWNING, DENY_SPAWN, INVINCIBILITY, EXP_DROPS,
|
MOB_DAMAGE, MOB_SPAWNING, DENY_SPAWN, INVINCIBILITY, EXP_DROPS,
|
||||||
CREEPER_EXPLOSION, OTHER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
|
CREEPER_EXPLOSION, OTHER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
|
||||||
DENY_MESSAGE, ENTRY_DENY_MESSAGE, EXIT_DENY_MESSAGE, EXIT_OVERRIDE,
|
DENY_MESSAGE, ENTRY_DENY_MESSAGE, EXIT_DENY_MESSAGE, EXIT_OVERRIDE, EXIT_VIA_TELEPORT,
|
||||||
GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER, NOTIFY_LEAVE,
|
GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER, NOTIFY_LEAVE,
|
||||||
EXIT, ENTRY, LIGHTNING, ENTITY_PAINTING_DESTROY, ENDERPEARL,
|
EXIT, ENTRY, LIGHTNING, ENTITY_PAINTING_DESTROY, ENDERPEARL,
|
||||||
ENTITY_ITEM_FRAME_DESTROY, ITEM_PICKUP, ITEM_DROP, /*MAX_PLAYERS, MAX_PLAYERS_MESSAGE,*/
|
ENTITY_ITEM_FRAME_DESTROY, ITEM_PICKUP, ITEM_DROP, /*MAX_PLAYERS, MAX_PLAYERS_MESSAGE,*/
|
||||||
|
@ -28,22 +28,27 @@
|
|||||||
*/
|
*/
|
||||||
public enum MoveType {
|
public enum MoveType {
|
||||||
|
|
||||||
RESPAWN(false),
|
RESPAWN(false, true),
|
||||||
EMBARK(true),
|
EMBARK(true, false),
|
||||||
MOVE(true),
|
MOVE(true, false),
|
||||||
TELEPORT(true),
|
TELEPORT(true, true),
|
||||||
RIDE(true),
|
RIDE(true, false),
|
||||||
OTHER_NON_CANCELLABLE(false),
|
OTHER_NON_CANCELLABLE(false, false),
|
||||||
OTHER_CANCELLABLE(true);
|
OTHER_CANCELLABLE(true, false);
|
||||||
|
|
||||||
private final boolean cancellable;
|
private final boolean cancellable;
|
||||||
|
private final boolean teleport;
|
||||||
|
|
||||||
MoveType(boolean cancellable) {
|
MoveType(boolean cancellable, boolean teleport) {
|
||||||
this.cancellable = cancellable;
|
this.cancellable = cancellable;
|
||||||
|
this.teleport = teleport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCancellable() {
|
public boolean isCancellable() {
|
||||||
return cancellable;
|
return cancellable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTeleport() {
|
||||||
|
return teleport;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public class ExitFlag extends FlagValueChangeHandler<State> {
|
|||||||
|
|
||||||
private static final long MESSAGE_THRESHOLD = 1000 * 2;
|
private static final long MESSAGE_THRESHOLD = 1000 * 2;
|
||||||
private String storedMessage;
|
private String storedMessage;
|
||||||
|
private boolean exitViaTeleport = false;
|
||||||
private long lastMessage;
|
private long lastMessage;
|
||||||
|
|
||||||
public ExitFlag(Session session) {
|
public ExitFlag(Session session) {
|
||||||
@ -43,6 +44,7 @@ public ExitFlag(Session session) {
|
|||||||
private void update(LocalPlayer localPlayer, ApplicableRegionSet set, boolean allowed) {
|
private void update(LocalPlayer localPlayer, ApplicableRegionSet set, boolean allowed) {
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
storedMessage = set.queryValue(localPlayer, DefaultFlag.EXIT_DENY_MESSAGE);
|
storedMessage = set.queryValue(localPlayer, DefaultFlag.EXIT_DENY_MESSAGE);
|
||||||
|
exitViaTeleport = set.testState(localPlayer, DefaultFlag.EXIT_VIA_TELEPORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ protected boolean onSetValue(Player player, Location from, Location to, Applicab
|
|||||||
|
|
||||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||||
|
|
||||||
if (allowed && !lastAllowed) {
|
if (allowed && !lastAllowed && !(moveType.isTeleport() && exitViaTeleport)) {
|
||||||
Boolean override = toSet.queryValue(localPlayer, DefaultFlag.EXIT_OVERRIDE);
|
Boolean override = toSet.queryValue(localPlayer, DefaultFlag.EXIT_OVERRIDE);
|
||||||
if (override == null || !override) {
|
if (override == null || !override) {
|
||||||
sendMessage(player);
|
sendMessage(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user