mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-03 16:04:26 +01:00
Only check for flag changes when regions change.
This functionally reverts e5b76a5
, though individual classes can change
this behavior on an individual basis by overriding the method.
Also, make time-lock and weather-lock restore only initial values,
which should be more intuitive behavior when multiple regions overlap
with different flag values.
This commit is contained in:
parent
e091a59063
commit
91687dc204
@ -47,6 +47,10 @@ public final void initialize(LocalPlayer player, Location current, ApplicableReg
|
||||
|
||||
@Override
|
||||
public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) {
|
||||
if (entered.isEmpty() && exited.isEmpty()) {
|
||||
return true; // no changes to flags if regions didn't change
|
||||
}
|
||||
|
||||
T currentValue = toSet.queryValue(player, flag);
|
||||
boolean allowed = true;
|
||||
|
||||
|
@ -92,8 +92,7 @@ public boolean testMoveTo(LocalPlayer player, Location from, Location to, Applic
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player has moved into a new location where either
|
||||
* there are fewer regions or more regions.
|
||||
* Called when a player has moved into a new location.
|
||||
*
|
||||
* <p>This is called only if the move test
|
||||
* ({@link Session#testMoveTo(LocalPlayer, Location, MoveType)}) was successful.</p>
|
||||
|
@ -49,9 +49,6 @@ public TimeLockFlag(Session session) {
|
||||
}
|
||||
|
||||
private void updatePlayerTime(LocalPlayer player, @Nullable String value) {
|
||||
// store settings, regardless of if we change anything
|
||||
initialRelative = player.isPlayerTimeRelative();
|
||||
initialTime = player.getPlayerTimeOffset();
|
||||
if (value == null || !timePattern.matcher(value).matches()) {
|
||||
// invalid input
|
||||
return;
|
||||
@ -66,6 +63,8 @@ private void updatePlayerTime(LocalPlayer player, @Nullable String value) {
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, String value) {
|
||||
initialRelative = player.isPlayerTimeRelative();
|
||||
initialTime = player.getPlayerTimeOffset();
|
||||
updatePlayerTime(player, value);
|
||||
}
|
||||
|
||||
|
@ -45,23 +45,19 @@ public WeatherLockFlag(Session session) {
|
||||
super(session, Flags.WEATHER_LOCK);
|
||||
}
|
||||
|
||||
private void updatePlayerWeather(LocalPlayer player, @Nullable WeatherType value) {
|
||||
initialWeather = player.getPlayerWeather();
|
||||
player.setPlayerWeather(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, WeatherType value) {
|
||||
if (value == null) {
|
||||
initialWeather = null;
|
||||
return;
|
||||
}
|
||||
updatePlayerWeather(player, value);
|
||||
initialWeather = value;
|
||||
player.setPlayerWeather(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, WeatherType currentValue, WeatherType lastValue, MoveType moveType) {
|
||||
updatePlayerWeather(player, currentValue);
|
||||
player.setPlayerWeather(currentValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user