Paper/patches/server/0508-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch

47 lines
2.7 KiB
Diff
Raw Normal View History

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
index 225823ef8bb4171f770f90f083689850aa6a171e..8221b271aa18252b9883fbaf3982b467406ec56b 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
@@ -1681,12 +1681,14 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
2021-06-11 14:02:28 +02:00
}
// Paper end
+ public final void setSpawn(BlockPos blockposition, float f) { this.setDefaultSpawnPos(blockposition, f); } // Paper - OBFHELPER
public void setDefaultSpawnPos(BlockPos pos, float angle) {
// Paper - configurable spawn radius
2021-06-14 12:42:08 +02:00
BlockPos prevSpawn = this.getSharedSpawnPos();
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);
+ 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
2021-06-15 04:59:31 +02:00
index babe877022156adc224643c3d487793bfa43d5ff..b24395160c1ea84ed44a1db07b4f024a540ca80b 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
2021-06-14 12:42:08 +02:00
@@ -386,11 +386,13 @@ public class CraftWorld implements World {
2021-06-11 14:02:28 +02:00
public boolean setSpawnLocation(int x, int y, int z, float angle) {
try {
2021-06-14 12:42:08 +02:00
Location previousLocation = this.getSpawnLocation();
2021-06-11 14:02:28 +02:00
- world.levelData.setSpawn(new BlockPos(x, y, z), angle);
+ world.setSpawn(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);
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) {