mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 02:55:23 +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
|
@Override
|
||||||
public boolean onCrossBoundary(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType) {
|
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);
|
T currentValue = toSet.queryValue(player, flag);
|
||||||
boolean allowed = true;
|
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
|
* Called when a player has moved into a new location.
|
||||||
* there are fewer regions or more regions.
|
|
||||||
*
|
*
|
||||||
* <p>This is called only if the move test
|
* <p>This is called only if the move test
|
||||||
* ({@link Session#testMoveTo(LocalPlayer, Location, MoveType)}) was successful.</p>
|
* ({@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) {
|
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()) {
|
if (value == null || !timePattern.matcher(value).matches()) {
|
||||||
// invalid input
|
// invalid input
|
||||||
return;
|
return;
|
||||||
@ -66,6 +63,8 @@ private void updatePlayerTime(LocalPlayer player, @Nullable String value) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, String value) {
|
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, String value) {
|
||||||
|
initialRelative = player.isPlayerTimeRelative();
|
||||||
|
initialTime = player.getPlayerTimeOffset();
|
||||||
updatePlayerTime(player, value);
|
updatePlayerTime(player, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,23 +45,19 @@ public WeatherLockFlag(Session session) {
|
|||||||
super(session, Flags.WEATHER_LOCK);
|
super(session, Flags.WEATHER_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlayerWeather(LocalPlayer player, @Nullable WeatherType value) {
|
|
||||||
initialWeather = player.getPlayerWeather();
|
|
||||||
player.setPlayerWeather(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, WeatherType value) {
|
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, WeatherType value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
initialWeather = null;
|
initialWeather = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
updatePlayerWeather(player, value);
|
initialWeather = value;
|
||||||
|
player.setPlayerWeather(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onSetValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, WeatherType currentValue, WeatherType lastValue, MoveType moveType) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user