2021-06-11 14:02:28 +02:00
|
|
|
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
|
2023-12-31 00:45:24 +01:00
|
|
|
index 9924f0ba2ac867748e49d738ac5bcef292cfc649..4e37b64f608b9a4c6d421fc685680f7bd2269bb1 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2023-12-31 00:45:24 +01:00
|
|
|
@@ -2035,9 +2035,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2023-03-04 23:42:10 +01:00
|
|
|
public void setDefaultSpawnPos(BlockPos pos, float angle) {
|
|
|
|
// Paper - configurable spawn radius
|
|
|
|
BlockPos prevSpawn = this.getSharedSpawnPos();
|
|
|
|
+ Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
//ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));
|
|
|
|
|
|
|
|
this.levelData.setSpawn(pos, angle);
|
2023-03-04 23:42:10 +01:00
|
|
|
+ new org.bukkit.event.world.SpawnChangeEvent(this.getWorld(), prevSpawnLoc).callEvent(); // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
if (this.keepSpawnInMemory) {
|
|
|
|
// if this keepSpawnInMemory is false a plugin has already removed our tickets, do not re-add
|
2022-06-11 16:58:17 +02:00
|
|
|
this.removeTicketsForSpawn(this.paperConfig().spawn.keepSpawnLoadedRange * 16, prevSpawn);
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2023-12-31 00:45:24 +01:00
|
|
|
index 8efc044e5a38766aa29cb62db553a8390de50139..52628759695a441ff21f3077cfe9f75a6e999456 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2023-12-25 23:51:56 +01:00
|
|
|
@@ -262,12 +262,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2023-03-04 23:42:10 +01:00
|
|
|
@Override
|
2021-06-11 14:02:28 +02:00
|
|
|
public boolean setSpawnLocation(int x, int y, int z, float angle) {
|
|
|
|
try {
|
2023-03-04 23:42:10 +01:00
|
|
|
- Location previousLocation = this.getSpawnLocation();
|
2023-10-27 01:34:58 +02:00
|
|
|
- this.world.levelData.setSpawn(new BlockPos(x, y, z), angle);
|
2023-03-04 23:42:10 +01:00
|
|
|
+ // Location previousLocation = this.getSpawnLocation(); // Paper - moved to nms.ServerLevel
|
2023-10-27 01:34:58 +02:00
|
|
|
+ this.world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2023-03-04 23:42:10 +01:00
|
|
|
+ // Paper start - move to nms.ServerLevel
|
2021-06-11 14:02:28 +02:00
|
|
|
// Notify anyone who's listening.
|
|
|
|
- SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
2021-06-14 12:42:08 +02:00
|
|
|
- this.server.getPluginManager().callEvent(event);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
|
|
|
+ // server.getPluginManager().callEvent(event);
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (Exception e) {
|