mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-22 08:11:59 +01:00
Implemented WorldUnloadEvent and unloadWorld().
By: Rigby <rigby@onarandombox.com>
This commit is contained in:
parent
1dca6874d8
commit
516d253953
@ -190,6 +190,24 @@ public interface Server {
|
||||
*/
|
||||
public World createWorld(String name, World.Environment environment, long seed, ChunkGenerator generator);
|
||||
|
||||
/**
|
||||
* Unloads a world with the given name.
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @param save Whether to save the chunks before unloading.
|
||||
* @return Whether the action was Successful
|
||||
*/
|
||||
public boolean unloadWorld(String name, boolean save);
|
||||
|
||||
/**
|
||||
* Unloads the given world.
|
||||
*
|
||||
* @param world The world to unload
|
||||
* @param save Whether to save the chunks before unloading.
|
||||
* @return Whether the action was Successful
|
||||
*/
|
||||
public boolean unloadWorld(World world, boolean save);
|
||||
|
||||
/**
|
||||
* Gets the world with the given name
|
||||
*
|
||||
|
@ -479,6 +479,10 @@ public abstract class Event implements Serializable {
|
||||
* Called when a World is loaded
|
||||
*/
|
||||
WORLD_LOAD (Category.WORLD),
|
||||
/**
|
||||
* Called when a World is unloaded
|
||||
*/
|
||||
WORLD_UNLOAD (Category.WORLD),
|
||||
|
||||
/**
|
||||
* ENTITY EVENTS
|
||||
|
@ -57,6 +57,13 @@ public class WorldListener implements Listener {
|
||||
throw new AuthorNagException("onWorldLoad has been replaced with a new signature, (WorldLoadEvent)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a World is unloaded
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onWorldUnload(WorldUnloadEvent event) { }
|
||||
|
||||
// TODO: Remove after RB
|
||||
@Deprecated public void onWorldLoad(WorldEvent event) {}
|
||||
@Deprecated public void onWorldSave(WorldEvent event) {}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package org.bukkit.event.world;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
public class WorldUnloadEvent extends WorldEvent implements Cancellable {
|
||||
|
||||
private boolean isCancelled;
|
||||
|
||||
public WorldUnloadEvent(World world) {
|
||||
super(Type.WORLD_UNLOAD, world);
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.isCancelled = cancel;
|
||||
}
|
||||
}
|
@ -555,6 +555,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
}
|
||||
};
|
||||
|
||||
case WORLD_UNLOAD:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((WorldListener) listener).onWorldUnload((WorldUnloadEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
// Painting Events
|
||||
case PAINTING_PLACE:
|
||||
return new EventExecutor() {
|
||||
|
Loading…
Reference in New Issue
Block a user