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:43:12 +01:00
parent 942d799c9c
commit 3cd9b76805
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
4 changed files with 13 additions and 6 deletions

View File

@ -265,7 +265,10 @@ public class BukkitPlayer extends PlotPlayer<Player> {
switch (weather) {
case CLEAR -> this.player.setPlayerWeather(WeatherType.CLEAR);
case RAIN -> this.player.setPlayerWeather(WeatherType.DOWNFALL);
default -> this.player.resetPlayerWeather();
case WORLD -> this.player.resetPlayerWeather();
default -> {
//do nothing as this is PlotWeather.OFF
}
}
}

View File

@ -440,8 +440,8 @@ public class PlotListener {
}
final PlotWeather plotWeather = plot.getFlag(WeatherFlag.class);
if (plotWeather != PlotWeather.CLEAR) {
player.setWeather(PlotWeather.RESET);
if (plotWeather != PlotWeather.OFF) {
player.setWeather(PlotWeather.WORLD);
}
try (final MetaDataAccess<Location> musicAccess =

View File

@ -28,5 +28,6 @@ package com.plotsquared.core.plot;
public enum PlotWeather {
RAIN,
CLEAR,
RESET
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.
@ -57,7 +58,8 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
return switch (input.toLowerCase()) {
case "rain" -> flagOf(PlotWeather.RAIN);
case "clear" -> flagOf(PlotWeather.CLEAR);
default -> flagOf(PlotWeather.RESET);
case "reset" -> flagOf(PlotWeather.WORLD);
default -> flagOf(PlotWeather.OFF);
};
}
@ -81,6 +83,7 @@ public class WeatherFlag extends PlotFlag<PlotWeather, WeatherFlag> {
return switch (value) {
case RAIN -> PLOT_WEATHER_FLAG_RAIN;
case CLEAR -> PLOT_WEATHER_FLAG_CLEAR;
case WORLD -> PLOT_WEATHER_FLAG_WORLD;
default -> PLOT_WEATHER_FLAG_OFF;
};
}