Prevent chunk load respawning with SpawnReason.PLUGIN

This commit is contained in:
fullwall 2020-10-12 22:24:44 +08:00
parent 12b796afa3
commit 675eaffad5

View File

@ -415,8 +415,8 @@ public class EventListen implements Listener {
|| event.getReason() == DespawnReason.RELOAD) { || event.getReason() == DespawnReason.RELOAD) {
if (event.getNPC().getStoredLocation() != null) { if (event.getNPC().getStoredLocation() != null) {
ChunkCoord coord = new ChunkCoord(event.getNPC().getStoredLocation()); ChunkCoord coord = new ChunkCoord(event.getNPC().getStoredLocation());
Messaging.debug("Preventing further respawns of " + event.getNPC().getId() + " at [" + coord.x + "," Messaging.debug("Preventing further respawns of", event.getNPC().getId(), "at", coord,
+ coord.z + "] due to DespawnReason." + event.getReason()); "due to DespawnReason." + event.getReason());
toRespawn.remove(coord, event.getNPC()); toRespawn.remove(coord, event.getNPC());
} }
} else { } else {
@ -447,6 +447,11 @@ public class EventListen implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onNPCSpawn(NPCSpawnEvent event) { public void onNPCSpawn(NPCSpawnEvent event) {
skinUpdateTracker.onNPCSpawn(event.getNPC()); skinUpdateTracker.onNPCSpawn(event.getNPC());
Location location = event.getNPC().getStoredLocation();
if (location == null) {
location = event.getLocation();
}
toRespawn.remove(new ChunkCoord(location), event.getNPC());
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)