geforkt von Mirrors/Paper
Added the SPAWN_CHANGE event, which occurs when a world's spawn is changed.
This event includes the world who's spawn changed and its previous spawn location. To listen for this event: PluginManager pm = getServer().getPluginManager(); YourWorldListener worldListener = new YourWorldListener(this); pm.registerEvent(Event.Type.SPAWN_CHANGE, worldListener, Priority.Normal, this); To use this event: public class YourWorldListener extends WorldListener { @Override public void onSpawnChange(SpawnChangeEvent event) { World world = event.getWorld(); Location previousLocation = event.getPreviousLocation(); } } By: William Bowers <william.bowers@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
e7f980d6e9
Commit
531a69463a
@ -454,6 +454,13 @@ public abstract class Event implements Serializable {
|
|||||||
*/
|
*/
|
||||||
ITEM_SPAWN (Category.WORLD),
|
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
|
* Called when a world is saved
|
||||||
*
|
*
|
||||||
|
28
paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java
Normale Datei
28
paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,14 @@ public class WorldListener implements Listener {
|
|||||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
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
|
* Called when a world is saved
|
||||||
*
|
*
|
||||||
|
@ -379,6 +379,12 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
((WorldListener) listener).onChunkUnload((ChunkUnloadEvent) event);
|
((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:
|
case WORLD_SAVE:
|
||||||
return new EventExecutor() {
|
return new EventExecutor() {
|
||||||
public void execute(Listener listener, Event event) {
|
public void execute(Listener listener, Event event) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren