Paper/patches/server/0500-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch
2021-06-14 22:49:09 -07:00

47 lines
2.7 KiB
Diff

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 bdabcdb60dbfb803ead13c42c8dd5e100b37dc00..4ae56444d258cdf44a02256315d6aae84e2f53be 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1679,12 +1679,14 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
}
// 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
BlockPos prevSpawn = this.getSharedSpawnPos();
//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 babe877022156adc224643c3d487793bfa43d5ff..b24395160c1ea84ed44a1db07b4f024a540ca80b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -386,11 +386,13 @@ public class CraftWorld 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.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);
- this.server.getPluginManager().callEvent(event);
+ // SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
+ // server.getPluginManager().callEvent(event);
+ // Paper end
return true;
} catch (Exception e) {