Paper/Spigot-Server-Patches/Add-cause-to-Weather-ThunderChangeEvents.patch
2021-05-24 09:45:23 -07:00

119 lines
6.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 2 Dec 2020 18:23:26 -0800
Subject: [PATCH] Add cause to Weather/ThunderChangeEvents
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -0,0 +0,0 @@ public class WorldServer extends World implements GeneratorAccessSeed {
this.worldDataServer.setClearWeatherTime(i);
this.worldDataServer.setWeatherDuration(j);
this.worldDataServer.setThunderDuration(j);
- this.worldDataServer.setStorm(flag);
- this.worldDataServer.setThundering(flag1);
+ this.worldDataServer.setStorm(flag, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper
+ this.worldDataServer.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper
}
public BiomeBase getBiomeBySeed(int i, int j, int k) { return a(i, j, k); } // Paper - OBFHELPER
@@ -0,0 +0,0 @@ public class WorldServer extends World implements GeneratorAccessSeed {
this.worldDataServer.setThunderDuration(j);
this.worldDataServer.setWeatherDuration(k);
this.worldDataServer.setClearWeatherTime(i);
- this.worldDataServer.setThundering(flag1);
- this.worldDataServer.setStorm(flag2);
+ this.worldDataServer.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper
+ this.worldDataServer.setStorm(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper
}
this.lastThunderLevel = this.thunderLevel;
@@ -0,0 +0,0 @@ public class WorldServer extends World implements GeneratorAccessSeed {
private void clearWeather() {
// CraftBukkit start
- this.worldDataServer.setStorm(false);
+ this.worldDataServer.setStorm(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
// Not that everyone ever manages to get the whole server to sleep at the same time....
if (!this.worldDataServer.hasStorm()) {
this.worldDataServer.setWeatherDuration(0);
}
// CraftBukkit end
- this.worldDataServer.setThundering(false);
+ this.worldDataServer.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night
// CraftBukkit start
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
// Not that everyone ever manages to get the whole server to sleep at the same time....
diff --git a/src/main/java/net/minecraft/world/level/storage/WorldDataServer.java b/src/main/java/net/minecraft/world/level/storage/WorldDataServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/storage/WorldDataServer.java
+++ b/src/main/java/net/minecraft/world/level/storage/WorldDataServer.java
@@ -0,0 +0,0 @@ public class WorldDataServer implements IWorldDataServer, SaveData {
@Override
public void setThundering(boolean flag) {
+ // Paper start
+ this.setThundering(flag, org.bukkit.event.weather.ThunderChangeEvent.Cause.UNKNOWN);
+ }
+ public void setThundering(boolean flag, org.bukkit.event.weather.ThunderChangeEvent.Cause cause) {
+ // Paper end
// CraftBukkit start
if (this.thundering == flag) {
return;
@@ -0,0 +0,0 @@ public class WorldDataServer implements IWorldDataServer, SaveData {
org.bukkit.World world = Bukkit.getWorld(getName());
if (world != null) {
- ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag);
+ ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag, cause); // Paper
Bukkit.getServer().getPluginManager().callEvent(thunder);
if (thunder.isCancelled()) {
return;
@@ -0,0 +0,0 @@ public class WorldDataServer implements IWorldDataServer, SaveData {
@Override
public void setStorm(boolean flag) {
+ // Paper start
+ this.setStorm(flag, org.bukkit.event.weather.WeatherChangeEvent.Cause.UNKNOWN);
+ }
+
+ public void setStorm(boolean flag, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) {
+ // Paper end
// CraftBukkit start
if (this.raining == flag) {
return;
@@ -0,0 +0,0 @@ public class WorldDataServer implements IWorldDataServer, SaveData {
org.bukkit.World world = Bukkit.getWorld(getName());
if (world != null) {
- WeatherChangeEvent weather = new WeatherChangeEvent(world, flag);
+ WeatherChangeEvent weather = new WeatherChangeEvent(world, flag, cause); // Paper
Bukkit.getServer().getPluginManager().callEvent(weather);
if (weather.isCancelled()) {
return;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
@Override
public void setStorm(boolean hasStorm) {
- world.worldData.setStorm(hasStorm);
+ world.worldDataServer.setStorm(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper
setWeatherDuration(0); // Reset weather duration (legacy behaviour)
setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
}
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
@Override
public void setThundering(boolean thundering) {
- world.worldDataServer.setThundering(thundering);
+ world.worldDataServer.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper
setThunderDuration(0); // Reset weather duration (legacy behaviour)
setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
}