aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0447-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch
blob: ce6d8e5e504d41cbca1e12cbca80be438d56382f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
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 0ff614ea19ff5420c506fe402caf230b1e0a3a36..e6694cb87031cb273ba53ac991d4c79b1f5c1ced 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1996,9 +1996,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
     public void setDefaultSpawnPos(BlockPos pos, float angle) {
         // Paper - configurable spawn radius
         BlockPos prevSpawn = this.getSharedSpawnPos();
+        Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper
         //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
         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 6af214882a4208864b1e80231023b9a0644041fb..56710af63bf432ab38c3a39ad3b734371bb429d7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -260,12 +260,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 - moved to nms.ServerLevel
+            this.world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos
 
+            // Paper start - 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
 
             return true;
         } catch (Exception e) {