mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-28 13:36:16 +01:00
Implemented unloadWorld(). Thanks Rigby!
This commit is contained in:
parent
57a1a7422c
commit
68608169cd
@ -10,6 +10,8 @@ import org.bukkit.World.Environment;
|
|||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
import org.bukkit.event.world.WorldSaveEvent;
|
||||||
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
import org.bukkit.inventory.FurnaceRecipe;
|
import org.bukkit.inventory.FurnaceRecipe;
|
||||||
import org.bukkit.inventory.Recipe;
|
import org.bukkit.inventory.Recipe;
|
||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
@ -30,6 +32,7 @@ import net.minecraft.server.ConvertProgressUpdater;
|
|||||||
import net.minecraft.server.Convertable;
|
import net.minecraft.server.Convertable;
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
import net.minecraft.server.EntityTracker;
|
import net.minecraft.server.EntityTracker;
|
||||||
|
import net.minecraft.server.IProgressUpdate;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.PropertyManager;
|
import net.minecraft.server.PropertyManager;
|
||||||
import net.minecraft.server.ServerConfigurationManager;
|
import net.minecraft.server.ServerConfigurationManager;
|
||||||
@ -423,6 +426,48 @@ public final class CraftServer implements Server {
|
|||||||
return internal.getWorld();
|
return internal.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean unloadWorld(String name, boolean save) {
|
||||||
|
return unloadWorld(getWorld(name), save);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean unloadWorld(World world, boolean save) {
|
||||||
|
if (world == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldServer handle = ((CraftWorld) world).getHandle();
|
||||||
|
|
||||||
|
if (!(console.worlds.contains(handle))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(handle.dimension > 1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handle.players.size() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldUnloadEvent e = new WorldUnloadEvent(handle.getWorld());
|
||||||
|
|
||||||
|
if (e.isCancelled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (save) {
|
||||||
|
handle.save(true, (IProgressUpdate) null);
|
||||||
|
handle.saveLevel();
|
||||||
|
WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
|
||||||
|
getPluginManager().callEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
worlds.remove(world.getName().toLowerCase());
|
||||||
|
console.worlds.remove(console.worlds.indexOf(handle));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public MinecraftServer getServer() {
|
public MinecraftServer getServer() {
|
||||||
return console;
|
return console;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user