aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0489-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch
blob: 4a7aa73b9ccf9464f0689727bdbff4d953c216ab (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
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 2182d17d463cea2ff999c5bc61eb31f4317362d8..f8a892110339ef63b5bdc31b64c4a40833685526 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1751,6 +1751,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
         //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));
 
         this.levelData.setSpawn(pos, angle);
+        new org.bukkit.event.world.SpawnChangeEvent(getWorld(), MCUtil.toLocation(this, prevSpawn)).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.keepLoadedRange, prevSpawn);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 84607e4d2b22bc0c5df762fddb556eab7c06de23..0d194f538e388560fbf946c581a5f5aea6550df7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -256,11 +256,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
     public boolean setSpawnLocation(int x, int y, int z, float angle) {
         try {
             Location previousLocation = this.getSpawnLocation();
-            world.levelData.setSpawn(new BlockPos(x, y, z), angle);
+            world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use WorldServer#setSpawn
 
+            // Paper start - move to nms.World
             // 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) {