Add exit-via-teleport flag (default allow).

This commit is contained in:
sk89q 2015-01-27 15:01:01 -08:00
parent 0f4e7b5061
commit e1843624bb
3 changed files with 18 additions and 10 deletions

View File

@ -109,6 +109,7 @@ public final class DefaultFlag {
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.");
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 FAREWELL_MESSAGE = new StringFlag("farewell");
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,
MOB_DAMAGE, MOB_SPAWNING, DENY_SPAWN, INVINCIBILITY, EXP_DROPS,
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,
EXIT, ENTRY, LIGHTNING, ENTITY_PAINTING_DESTROY, ENDERPEARL,
ENTITY_ITEM_FRAME_DESTROY, ITEM_PICKUP, ITEM_DROP, /*MAX_PLAYERS, MAX_PLAYERS_MESSAGE,*/

View File

@ -28,22 +28,27 @@
*/
public enum MoveType {
RESPAWN(false),
EMBARK(true),
MOVE(true),
TELEPORT(true),
RIDE(true),
OTHER_NON_CANCELLABLE(false),
OTHER_CANCELLABLE(true);
RESPAWN(false, true),
EMBARK(true, false),
MOVE(true, false),
TELEPORT(true, true),
RIDE(true, false),
OTHER_NON_CANCELLABLE(false, false),
OTHER_CANCELLABLE(true, false);
private final boolean cancellable;
private final boolean teleport;
MoveType(boolean cancellable) {
MoveType(boolean cancellable, boolean teleport) {
this.cancellable = cancellable;
this.teleport = teleport;
}
public boolean isCancellable() {
return cancellable;
}
public boolean isTeleport() {
return teleport;
}
}

View File

@ -34,6 +34,7 @@ public class ExitFlag extends FlagValueChangeHandler<State> {
private static final long MESSAGE_THRESHOLD = 1000 * 2;
private String storedMessage;
private boolean exitViaTeleport = false;
private long lastMessage;
public ExitFlag(Session session) {
@ -43,6 +44,7 @@ public ExitFlag(Session session) {
private void update(LocalPlayer localPlayer, ApplicableRegionSet set, boolean allowed) {
if (!allowed) {
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);
if (allowed && !lastAllowed) {
if (allowed && !lastAllowed && !(moveType.isTeleport() && exitViaTeleport)) {
Boolean override = toSet.queryValue(localPlayer, DefaultFlag.EXIT_OVERRIDE);
if (override == null || !override) {
sendMessage(player);