Implemented WorldUnloadEvent and unloadWorld().

By: Rigby <rigby@onarandombox.com>
This commit is contained in:
Bukkit/Spigot 2011-06-04 06:46:21 +01:00
parent 1dca6874d8
commit 516d253953
5 changed files with 57 additions and 0 deletions

View File

@ -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
*

View File

@ -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

View File

@ -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) {}

View File

@ -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;
}
}

View File

@ -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() {