mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 04:09:54 +01:00
44 lines
2.6 KiB
Diff
44 lines
2.6 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 6a30ae257158267918c7114494005be528ac05dc..ccc5e57bfaaa51b05c66349475212f2079a4428c 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1668,7 +1668,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
float f1 = this.levelData.getSpawnAngle();
|
|
|
|
if (!blockposition1.equals(pos) || f1 != angle) {
|
|
+ org.bukkit.Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper - Call SpawnChangeEvent
|
|
this.levelData.setSpawn(pos, angle);
|
|
+ new org.bukkit.event.world.SpawnChangeEvent(this.getWorld(), prevSpawnLoc).callEvent(); // Paper - Call SpawnChangeEvent
|
|
this.getServer().getPlayerList().broadcastAll(new ClientboundSetDefaultSpawnPositionPacket(pos, angle));
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index d4697f2f4c71001dba2cc3a69d54f27809766595..4d75cf0ec9e835b4274297275d52f08a6a65aeca 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -269,12 +269,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) {
|