mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 02:27:42 +01:00
Add new exit-override flag instead of fiddling with default exit flag values.
This commit is contained in:
parent
aae521b727
commit
e90a7ed075
@ -96,7 +96,7 @@ public final class DefaultFlag {
|
||||
public static final StateFlag SEND_CHAT = new StateFlag("send-chat", true);
|
||||
public static final StateFlag RECEIVE_CHAT = new StateFlag("receive-chat", true);
|
||||
public static final StateFlag ENTRY = new StateFlag("entry", true, RegionGroup.NON_MEMBERS);
|
||||
public static final StateFlag EXIT = new StateFlag("exit", false, RegionGroup.NON_MEMBERS);
|
||||
public static final StateFlag EXIT = new StateFlag("exit", true, RegionGroup.NON_MEMBERS);
|
||||
public static final StateFlag ENDERPEARL = new StateFlag("enderpearl", true);
|
||||
public static final StateFlag ENTITY_PAINTING_DESTROY = new StateFlag("entity-painting-destroy", true);
|
||||
public static final StateFlag ENTITY_ITEM_FRAME_DESTROY = new StateFlag("entity-item-frame-destroy", true);
|
||||
@ -108,6 +108,7 @@ public final class DefaultFlag {
|
||||
"" + ChatColor.RED + ChatColor.BOLD + "Hey!" + ChatColor.GRAY + " You are not permitted to enter this area.");
|
||||
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 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");
|
||||
@ -137,7 +138,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,
|
||||
DENY_MESSAGE, ENTRY_DENY_MESSAGE, EXIT_DENY_MESSAGE, EXIT_OVERRIDE,
|
||||
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,*/
|
||||
|
@ -22,6 +22,7 @@
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
@ -38,8 +39,8 @@ public ExitFlag(Session session) {
|
||||
super(session, DefaultFlag.EXIT);
|
||||
}
|
||||
|
||||
private void update(LocalPlayer localPlayer, ApplicableRegionSet set, State newState) {
|
||||
if (newState == State.DENY) {
|
||||
private void update(LocalPlayer localPlayer, ApplicableRegionSet set, boolean allowed) {
|
||||
if (!allowed) {
|
||||
storedMessage = set.queryValue(localPlayer, DefaultFlag.EXIT_DENY_MESSAGE);
|
||||
}
|
||||
}
|
||||
@ -55,7 +56,7 @@ private void sendMessage(Player player) {
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(Player player, ApplicableRegionSet set, State value) {
|
||||
update(getPlugin().wrapPlayer(player), set, value);
|
||||
update(getPlugin().wrapPlayer(player), set, StateFlag.test(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +65,20 @@ protected boolean onSetValue(Player player, Location from, Location to, Applicab
|
||||
return true;
|
||||
}
|
||||
|
||||
update(getPlugin().wrapPlayer(player), toSet, currentValue);
|
||||
boolean lastAllowed = StateFlag.test(lastValue);
|
||||
boolean allowed = StateFlag.test(currentValue);
|
||||
|
||||
LocalPlayer localPlayer = getPlugin().wrapPlayer(player);
|
||||
|
||||
if (allowed && !lastAllowed) {
|
||||
Boolean override = toSet.queryValue(localPlayer, DefaultFlag.EXIT_OVERRIDE);
|
||||
if (override == null || !override) {
|
||||
sendMessage(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
update(localPlayer, toSet, allowed);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,9 +88,14 @@ protected boolean onAbsentValue(Player player, Location from, Location to, Appli
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lastValue == State.DENY) {
|
||||
sendMessage(player);
|
||||
return false;
|
||||
boolean lastAllowed = StateFlag.test(lastValue);
|
||||
|
||||
if (!lastAllowed) {
|
||||
Boolean override = toSet.queryValue(getPlugin().wrapPlayer(player), DefaultFlag.EXIT_OVERRIDE);
|
||||
if (override == null || !override) {
|
||||
sendMessage(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user