mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-26 12:35:39 +01:00
Merge WorldManager Changes to keep the API happy
This commit is contained in:
commit
f2a263f86c
@ -298,6 +298,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
this.commandHandler.registerCommand(new SpawnCommand(this));
|
this.commandHandler.registerCommand(new SpawnCommand(this));
|
||||||
// Dangerous Commands
|
// Dangerous Commands
|
||||||
this.commandHandler.registerCommand(new UnloadCommand(this));
|
this.commandHandler.registerCommand(new UnloadCommand(this));
|
||||||
|
this.commandHandler.registerCommand(new LoadCommand(this));
|
||||||
this.commandHandler.registerCommand(new RemoveCommand(this));
|
this.commandHandler.registerCommand(new RemoveCommand(this));
|
||||||
this.commandHandler.registerCommand(new DeleteCommand(this));
|
this.commandHandler.registerCommand(new DeleteCommand(this));
|
||||||
this.commandHandler.registerCommand(new ConfirmCommand(this));
|
this.commandHandler.registerCommand(new ConfirmCommand(this));
|
||||||
|
@ -50,6 +50,15 @@ public interface MVWorldManager {
|
|||||||
*/
|
*/
|
||||||
public boolean unloadWorld(String name);
|
public boolean unloadWorld(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the world. Only use this if the world has been unloaded with {@link removeWorldFromList(String)}.
|
||||||
|
*
|
||||||
|
* @param name The name of the world to load
|
||||||
|
*
|
||||||
|
* @return True if success, false if failure.
|
||||||
|
*/
|
||||||
|
public boolean loadWorld(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if a given chunk generator is valid.
|
* Test if a given chunk generator is valid.
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||||
|
* Multiverse 2 is licensed under the BSD License. *
|
||||||
|
* For more information please check the README.md file included *
|
||||||
|
* with this project. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package com.onarandombox.MultiverseCore.commands;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LoadCommand extends MultiverseCommand {
|
||||||
|
|
||||||
|
public LoadCommand(MultiverseCore plugin) {
|
||||||
|
super(plugin);
|
||||||
|
this.setName("Load World");
|
||||||
|
this.setCommandUsage("/mv load" + ChatColor.GREEN + " {WORLD}");
|
||||||
|
this.setArgRange(1, 1);
|
||||||
|
this.addKey("mvload");
|
||||||
|
this.addKey("mv load");
|
||||||
|
this.setPermission("multiverse.core.load", "Loads a world into Multiverse.", PermissionDefault.OP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
|
if (this.plugin.getMVWorldManager().loadWorld(args.get(0))) {
|
||||||
|
sender.sendMessage("World Loaded!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Error trying to load world!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -141,12 +141,12 @@ public class WorldManager implements MVWorldManager {
|
|||||||
public boolean removeWorldFromConfig(String name) {
|
public boolean removeWorldFromConfig(String name) {
|
||||||
if (this.configWorlds.getProperty("worlds." + name) != null) {
|
if (this.configWorlds.getProperty("worlds." + name) != null) {
|
||||||
unloadWorld(name);
|
unloadWorld(name);
|
||||||
this.plugin.log(Level.INFO, "World " + name + " was removed from config.yml");
|
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
|
||||||
this.configWorlds.removeProperty("worlds." + name);
|
this.configWorlds.removeProperty("worlds." + name);
|
||||||
this.configWorlds.save();
|
this.configWorlds.save();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.plugin.log(Level.INFO, "World " + name + " was already removed from config.yml");
|
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ public class WorldManager implements MVWorldManager {
|
|||||||
|
|
||||||
if (this.worlds.containsKey(name)) {
|
if (this.worlds.containsKey(name)) {
|
||||||
this.worlds.remove(name);
|
this.worlds.remove(name);
|
||||||
this.plugin.log(Level.INFO, "World " + name + " was unloaded from memory.");
|
this.plugin.log(Level.INFO, "World '" + name + "' was unloaded from memory.");
|
||||||
this.unloadWorldFromBukkit(name, true);
|
this.unloadWorldFromBukkit(name, true);
|
||||||
return true;
|
return true;
|
||||||
} else if (this.plugin.getServer().getWorld(name) != null) {
|
} else if (this.plugin.getServer().getWorld(name) != null) {
|
||||||
@ -167,6 +167,31 @@ public class WorldManager implements MVWorldManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean loadWorld(String name) {
|
||||||
|
// Check if the World is already loaded
|
||||||
|
if (this.worlds.containsKey(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grab all the Worlds from the Config.
|
||||||
|
List<String> worldKeys = this.configWorlds.getKeys("worlds");
|
||||||
|
|
||||||
|
// Check that the list is not null and that the config contains the world
|
||||||
|
if ((worldKeys != null) && (worldKeys.contains(name))) {
|
||||||
|
// Grab the initial values from the config file.
|
||||||
|
String environment = this.configWorlds.getString("worlds." + name + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||||
|
String seedString = this.configWorlds.getString("worlds." + name + ".seed", "");
|
||||||
|
String generatorString = this.configWorlds.getString("worlds." + name + ".generator");
|
||||||
|
|
||||||
|
addWorld(name, this.plugin.getEnvFromString(environment), seedString, generatorString);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean deleteWorld(String name) {
|
public Boolean deleteWorld(String name) {
|
||||||
|
|
||||||
if (this.plugin.getServer().getWorld(name) != null) {
|
if (this.plugin.getServer().getWorld(name) != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user