mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
45 lines
2.9 KiB
Diff
45 lines
2.9 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 d9d4a8df764bce67ee13a542e0b21a5ec7fd8ca7..489db5b6cf82c518806dbabc43ec18fca7e672c4 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2014,9 +2014,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
public void setDefaultSpawnPos(BlockPos pos, float angle) {
|
|
// Paper start - Configurable Keep Spawn Loaded range per world
|
|
BlockPos prevSpawn = this.getSharedSpawnPos();
|
|
+ Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper - Call SpawnChangeEvent
|
|
//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 - Call SpawnChangeEvent
|
|
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 2d6ef62205ff5a4da72e718f9b33d955a58d805f..bbae63fb0a5f3f61c25f8348b72b1f20dcece00a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -262,12 +262,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 - Call SpawnChangeEvent; moved to nms.ServerLevel
|
|
+ this.world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos
|
|
|
|
+ // Paper start - Call SpawnChangeEvent; 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 - Call SpawnChangeEvent
|
|
|
|
return true;
|
|
} catch (Exception e) {
|