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: case RAIN:
this.player.setPlayerWeather(WeatherType.DOWNFALL); this.player.setPlayerWeather(WeatherType.DOWNFALL);
break; break;
case RESET: case WORLD:
default:
this.player.resetPlayerWeather(); this.player.resetPlayerWeather();
break; 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()) { if (plot.getFlag(TimeFlag.class) != TimeFlag.TIME_DISABLED.getValue().longValue()) {
player.setTime(Long.MAX_VALUE); player.setTime(Long.MAX_VALUE);
} }
final PlotWeather plotWeather = plot.getFlag(WeatherFlag.class); final PlotWeather plotWeather = plot.getFlag(WeatherFlag.class);
if (plotWeather != PlotWeather.CLEAR) { if (plotWeather != PlotWeather.OFF) {
player.setWeather(PlotWeather.RESET); player.setWeather(PlotWeather.WORLD);
} }
Location lastLoc = player.getMeta("music"); Location lastLoc = player.getMeta("music");

View File

@ -26,5 +26,8 @@
package com.plotsquared.core.plot; package com.plotsquared.core.plot;
public enum PlotWeather { 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_RAIN = new WeatherFlag(PlotWeather.RAIN);
public static final WeatherFlag PLOT_WEATHER_FLAG_CLEAR = new WeatherFlag(PlotWeather.CLEAR); 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. * Construct a new flag instance.
@ -60,8 +61,11 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
case "off": case "off":
case "sun": case "sun":
return flagOf(PlotWeather.CLEAR); return flagOf(PlotWeather.CLEAR);
case "reset":
case "world":
return flagOf(PlotWeather.WORLD);
default: 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; return PLOT_WEATHER_FLAG_RAIN;
case CLEAR: case CLEAR:
return PLOT_WEATHER_FLAG_CLEAR; return PLOT_WEATHER_FLAG_CLEAR;
case WORLD:
return PLOT_WEATHER_FLAG_WORLD;
default: default:
return PLOT_WEATHER_FLAG_OFF; return PLOT_WEATHER_FLAG_OFF;
} }
@ -90,7 +96,7 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
@Override public Collection<String> getTabCompletions() { @Override public Collection<String> getTabCompletions() {
return Arrays return Arrays
.asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset"); .asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset", "world");
} }
} }