diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index cf636ce0f6..dd59c06921 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -454,6 +454,13 @@ public abstract class Event implements Serializable { */ ITEM_SPAWN (Category.WORLD), + /** + * Called when a World's spawn is changed + * + * @see org.bukkit.event.world.SpawnChangeEvent + */ + SPAWN_CHANGE (Category.WORLD), + /** * Called when a world is saved * diff --git a/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java new file mode 100644 index 0000000000..02159d01d4 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java @@ -0,0 +1,28 @@ +package org.bukkit.event.world; + +import org.bukkit.World; +import org.bukkit.Location; + +/** + * An event that is called when a world's spawn changes. The + * world's previous spawn location is included. + * + * @author willurd + */ +public class SpawnChangeEvent extends WorldEvent { + private Location previousLocation; + + public SpawnChangeEvent(World world, Location previousLocation) { + super(Type.SPAWN_CHANGE, world); + this.previousLocation = previousLocation; + } + + /** + * Gets the previous spawn location + * + * @return Location that used to be spawn + */ + public Location getPreviousLocation() { + return previousLocation; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java b/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java index 0cdc7fcf1c..ef70af8389 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldListener.java @@ -24,6 +24,14 @@ public class WorldListener implements Listener { public void onChunkUnload(ChunkUnloadEvent event) { } + /** + * Called when a World's spawn is changed + * + * @param event Relevant event details + */ + public void onSpawnChange(SpawnChangeEvent event) { + } + /** * Called when a world is saved * diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 42d893d5a0..ceb750ad7e 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -379,6 +379,12 @@ public final class JavaPluginLoader implements PluginLoader { ((WorldListener) listener).onChunkUnload((ChunkUnloadEvent) event); } }; + case SPAWN_CHANGE: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((WorldListener) listener).onSpawnChange((SpawnChangeEvent) event); + } + }; case WORLD_SAVE: return new EventExecutor() { public void execute(Listener listener, Event event) {