From 3cd9b7680527d9c4b0ed84b46fa98707e8c61d3b Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 10 Jun 2021 11:43:12 +0100 Subject: [PATCH] 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 --- .../java/com/plotsquared/bukkit/player/BukkitPlayer.java | 5 ++++- .../java/com/plotsquared/core/listener/PlotListener.java | 4 ++-- .../main/java/com/plotsquared/core/plot/PlotWeather.java | 3 ++- .../core/plot/flag/implementations/WeatherFlag.java | 7 +++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index b5c2b47d7..caafbea77 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -265,7 +265,10 @@ public class BukkitPlayer extends PlotPlayer { 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 + } } } diff --git a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java index 77587eb4f..19b378ce1 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -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 musicAccess = diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotWeather.java b/Core/src/main/java/com/plotsquared/core/plot/PlotWeather.java index 8066744bb..8c2763b20 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotWeather.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotWeather.java @@ -28,5 +28,6 @@ package com.plotsquared.core.plot; public enum PlotWeather { RAIN, CLEAR, - RESET + WORLD, + OFF } diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/WeatherFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/WeatherFlag.java index 404a37e15..a720c85d9 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/WeatherFlag.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/WeatherFlag.java @@ -37,7 +37,8 @@ public class WeatherFlag extends PlotFlag { 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 { 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 { 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; }; }