From e2700d3b283eab53bd5b132cf0d2e087b1776962 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 10 Jun 2021 11:41:55 +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 --- .../com/plotsquared/bukkit/player/BukkitPlayer.java | 6 ++++-- .../com/plotsquared/core/listener/PlotListener.java | 5 +++-- .../java/com/plotsquared/core/plot/PlotWeather.java | 5 ++++- .../core/plot/flag/implementations/WeatherFlag.java | 12 +++++++++--- 4 files changed, 20 insertions(+), 8 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 704aa0f6d..317e79ca4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -276,10 +276,12 @@ public class BukkitPlayer extends PlotPlayer { 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; } } 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 8d95121ff..b90682115 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -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"); 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 f93d7970b..2ab253e54 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotWeather.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotWeather.java @@ -26,5 +26,8 @@ package com.plotsquared.core.plot; public enum PlotWeather { - RAIN, CLEAR, RESET + RAIN, + CLEAR, + 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 5c62a2daa..897b298ac 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. @@ -60,8 +61,11 @@ public class WeatherFlag extends PlotFlag { 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 { 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 { @Override public Collection getTabCompletions() { return Arrays - .asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset"); + .asList("rain", "storm", "on", "lightning", "thunder", "clear", "off", "sun", "reset", "world"); } }