Implement "off" to PlotWeather flag and make it default

- Players with "player weather" will no longer have their weather reset on plots that do not set the PlotWeather flag
This commit is contained in:
dordsor21 2021-06-10 11:41:55 +01:00
parent df842c355e
commit e2700d3b28
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
4 changed files with 20 additions and 8 deletions

View File

@ -276,10 +276,12 @@ public class BukkitPlayer extends PlotPlayer<Player> {
case RAIN:
this.player.setPlayerWeather(WeatherType.DOWNFALL);
break;
case RESET:
default:
case WORLD:
this.player.resetPlayerWeather();
break;
default:
//do nothing as this is PlotWeather.OFF
break;
}
}

View File

@ -362,13 +362,14 @@ public class PlotListener {
}
}
if (plot.getFlag(TimeFlag.class) != TimeFlag.TIME_DISABLED.getValue().longValue()) {
player.setTime(Long.MAX_VALUE);
}
final PlotWeather plotWeather = plot.getFlag(WeatherFlag.class);
if (plotWeather != PlotWeather.CLEAR) {
player.setWeather(PlotWeather.RESET);
if (plotWeather != PlotWeather.OFF) {
player.setWeather(PlotWeather.WORLD);
}
Location lastLoc = player.getMeta("music");

View File

@ -26,5 +26,8 @@
package com.plotsquared.core.plot;
public enum PlotWeather {
RAIN, CLEAR, RESET
RAIN,
CLEAR,
WORLD,
OFF
}

View File

@ -37,7 +37,8 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
public static final WeatherFlag PLOT_WEATHER_FLAG_RAIN = new WeatherFlag(PlotWeather.RAIN);
public static final WeatherFlag PLOT_WEATHER_FLAG_CLEAR = new WeatherFlag(PlotWeather.CLEAR);
public static final WeatherFlag PLOT_WEATHER_FLAG_OFF = new WeatherFlag(PlotWeather.RESET);
public static final WeatherFlag PLOT_WEATHER_FLAG_WORLD = new WeatherFlag(PlotWeather.WORLD);
public static final WeatherFlag PLOT_WEATHER_FLAG_OFF = new WeatherFlag(PlotWeather.OFF);
/**
* Construct a new flag instance.
@ -60,8 +61,11 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
case "off":
case "sun":
return flagOf(PlotWeather.CLEAR);
case "reset":
case "world":
return flagOf(PlotWeather.WORLD);
default:
return flagOf(PlotWeather.RESET);
return flagOf(PlotWeather.OFF);
}
}
@ -83,6 +87,8 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
return PLOT_WEATHER_FLAG_RAIN;
case CLEAR:
return PLOT_WEATHER_FLAG_CLEAR;
case WORLD:
return PLOT_WEATHER_FLAG_WORLD;
default:
return PLOT_WEATHER_FLAG_OFF;
}
@ -90,7 +96,7 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
@Override public Collection<String> getTabCompletions() {
return Arrays
.asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset");
.asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset", "world");
}
}