mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-08 00:11:29 +01:00
Only store existing per-player time/weather in handlers.
Fixes WORLDGUARD-4124. This will fix various issues with logging in to regions with these flags set and then moving out of them, or when moving between two adjacent regions with the flags set and then moving out.
This commit is contained in:
parent
120d2e223d
commit
96d15d6dbf
@ -120,7 +120,8 @@ public void setExhaustion(float exhaustion) {
|
||||
|
||||
@Override
|
||||
public WeatherType getPlayerWeather() {
|
||||
return null;
|
||||
org.bukkit.WeatherType playerWeather = getPlayer().getPlayerWeather();
|
||||
return playerWeather == null ? null : playerWeather == org.bukkit.WeatherType.CLEAR ? WeatherTypes.CLEAR : WeatherTypes.RAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +39,7 @@ public TimeLockFlag create(Session session) {
|
||||
}
|
||||
}
|
||||
|
||||
private Long initialTime;
|
||||
private long initialTime;
|
||||
private boolean initialRelative;
|
||||
|
||||
private static Pattern timePattern = Pattern.compile("([+\\-])?\\d+");
|
||||
@ -54,10 +54,7 @@ private void updatePlayerTime(LocalPlayer player, @Nullable String value) {
|
||||
return;
|
||||
}
|
||||
boolean relative = value.startsWith("+") || value.startsWith("-");
|
||||
Long time = Long.valueOf(value);
|
||||
// if (!relative && (time < 0L || time > 24000L)) { // invalid time, reset to 0
|
||||
// time = 0L;
|
||||
// }
|
||||
long time = Long.parseLong(value);
|
||||
player.setPlayerTime(time, relative);
|
||||
}
|
||||
|
||||
@ -70,15 +67,20 @@ protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, Strin
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, String currentValue, String lastValue, MoveType moveType) {
|
||||
if (lastValue == null) {
|
||||
initialRelative = player.isPlayerTimeRelative();
|
||||
initialTime = player.getPlayerTimeOffset();
|
||||
}
|
||||
updatePlayerTime(player, currentValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onAbsentValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, String lastValue, MoveType moveType) {
|
||||
// in the case that time = 0 and relative = true, this is the same as resetPlayerTime
|
||||
player.setPlayerTime(initialTime, initialRelative);
|
||||
initialRelative = true;
|
||||
initialTime = 0L;
|
||||
initialRelative = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -45,16 +45,17 @@ public WeatherLockFlag(Session session) {
|
||||
|
||||
@Override
|
||||
protected void onInitialValue(LocalPlayer player, ApplicableRegionSet set, WeatherType value) {
|
||||
if (value == null) {
|
||||
initialWeather = null;
|
||||
return;
|
||||
}
|
||||
initialWeather = value;
|
||||
initialWeather = player.getPlayerWeather();
|
||||
if (value != null) {
|
||||
player.setPlayerWeather(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSetValue(LocalPlayer player, Location from, Location to, ApplicableRegionSet toSet, WeatherType currentValue, WeatherType lastValue, MoveType moveType) {
|
||||
if (lastValue == null) {
|
||||
initialWeather = player.getPlayerWeather();
|
||||
}
|
||||
player.setPlayerWeather(currentValue);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user