Merge remote-tracking branch 'other-repo/fix' into 0.5-fix
Some checks are pending
build / build (push) Waiting to run
Some checks are pending
build / build (push) Waiting to run
This commit is contained in:
commit
f040475441
2 changed files with 21 additions and 3 deletions
4
pom.xml
4
pom.xml
|
@ -2,7 +2,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>pl.minecon724</groupId>
|
<groupId>pl.minecon724</groupId>
|
||||||
<artifactId>realweather</artifactId>
|
<artifactId>realweather</artifactId>
|
||||||
<version>0.5.1-DEV</version>
|
<version>0.5.0.2</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
@ -39,4 +39,4 @@
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,14 +3,19 @@ package pl.minecon724.realweather.weather;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.WeatherType;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
import org.bukkit.event.weather.WeatherEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
|
|
||||||
import pl.minecon724.realweather.SubLogger;
|
import pl.minecon724.realweather.SubLogger;
|
||||||
|
import pl.minecon724.realweather.weather.WeatherState.ConditionSimple;
|
||||||
import pl.minecon724.realweather.weather.WeatherState.State;
|
import pl.minecon724.realweather.weather.WeatherState.State;
|
||||||
import pl.minecon724.realweather.weather.events.WeatherSyncEvent;
|
import pl.minecon724.realweather.weather.events.WeatherSyncEvent;
|
||||||
|
|
||||||
|
@ -30,6 +35,7 @@ public class WeatherChanger implements Listener {
|
||||||
|
|
||||||
if (worldNames.contains(world.getName())) {
|
if (worldNames.contains(world.getName())) {
|
||||||
worlds.add(world);
|
worlds.add(world);
|
||||||
|
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||||
subLogger.info("World %s has been registered", world.getName());
|
subLogger.info("World %s has been registered", world.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +44,7 @@ public class WeatherChanger implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldUnload(WorldUnloadEvent event) {
|
public void onWorldUnload(WorldUnloadEvent event) {
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
|
world.setGameRule(GameRule.DO_WEATHER_CYCLE, true);
|
||||||
|
|
||||||
worlds.remove(world);
|
worlds.remove(world);
|
||||||
subLogger.info("World %s unloaded", world.getName());
|
subLogger.info("World %s unloaded", world.getName());
|
||||||
|
@ -48,11 +55,22 @@ public class WeatherChanger implements Listener {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
State state = event.getState();
|
State state = event.getState();
|
||||||
|
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
subLogger.info("new weather for %s: %s %s", player.getName(), state.getCondition().name(), state.getLevel().name());
|
subLogger.info("new weather for %s: %s %s", player.getName(), state.getCondition().name(), state.getLevel().name());
|
||||||
|
|
||||||
|
player.setPlayerWeather(
|
||||||
|
state.getSimple() == ConditionSimple.CLEAR
|
||||||
|
? WeatherType.CLEAR : WeatherType.DOWNFALL
|
||||||
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
subLogger.info("new weather: %s %s", state.getCondition().name(), state.getLevel().name());
|
subLogger.info("new weather: %s %s", state.getCondition().name(), state.getLevel().name());
|
||||||
|
|
||||||
|
worlds.forEach(w -> {
|
||||||
|
w.setStorm(state.getSimple() != ConditionSimple.CLEAR);
|
||||||
|
w.setThundering(state.getSimple() == ConditionSimple.THUNDER);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue