aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0414-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0414-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch')
-rw-r--r--patches/server/0414-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch45
1 files changed, 45 insertions, 0 deletions
diff --git a/patches/server/0414-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch b/patches/server/0414-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch
new file mode 100644
index 0000000000..9c8dcfe23c
--- /dev/null
+++ b/patches/server/0414-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch
@@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: William Blake Galbreath <[email protected]>
+Date: Sat, 22 Aug 2020 23:36:21 +0200
+Subject: [PATCH] Fix SpawnChangeEvent not firing for all use-cases
+
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
+index 9af1877321356348ad96b92ae8c5f4811bef50ac..2e42e09d3fa19e5a16374ee6ac1677dd2b2004f1 100644
+--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
+@@ -1726,9 +1726,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
+ public void setDefaultSpawnPos(BlockPos pos, float angle) {
+ // Paper start - Configurable Keep Spawn Loaded range per world
+ BlockPos prevSpawn = this.getSharedSpawnPos();
++ Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper - Call SpawnChangeEvent
+ //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));
+
+ this.levelData.setSpawn(pos, angle);
++ new org.bukkit.event.world.SpawnChangeEvent(this.getWorld(), prevSpawnLoc).callEvent(); // Paper - Call SpawnChangeEvent
+ if (this.keepSpawnInMemory) {
+ // if this keepSpawnInMemory is false a plugin has already removed our tickets, do not re-add
+ this.removeTicketsForSpawn(this.paperConfig().spawn.keepSpawnLoadedRange * 16, prevSpawn);
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+index af782882479910f13b54081df2443387135874e0..dbe1e59572ca0f98783db456bdab6ee4e79f7689 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+@@ -268,12 +268,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
+ @Override
+ public boolean setSpawnLocation(int x, int y, int z, float angle) {
+ try {
+- Location previousLocation = this.getSpawnLocation();
+- this.world.levelData.setSpawn(new BlockPos(x, y, z), angle);
++ // Location previousLocation = this.getSpawnLocation(); // Paper - Call SpawnChangeEvent; moved to nms.ServerLevel
++ this.world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos
+
++ // Paper start - Call SpawnChangeEvent; move to nms.ServerLevel
+ // Notify anyone who's listening.
+- SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
+- this.server.getPluginManager().callEvent(event);
++ // SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
++ // server.getPluginManager().callEvent(event);
++ // Paper end - Call SpawnChangeEvent
+
+ return true;
+ } catch (Exception e) {