mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-29 14:06:30 +01:00
Added loadWorld(String name) to the WorldManager and made it accessible with a command
Added some "'" around log-messages
This commit is contained in:
parent
6e4de79bfb
commit
f69c85e6b0
@ -298,6 +298,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.commandHandler.registerCommand(new SpawnCommand(this));
|
||||
// Dangerous Commands
|
||||
this.commandHandler.registerCommand(new UnloadCommand(this));
|
||||
this.commandHandler.registerCommand(new LoadCommand(this));
|
||||
this.commandHandler.registerCommand(new RemoveCommand(this));
|
||||
this.commandHandler.registerCommand(new DeleteCommand(this));
|
||||
this.commandHandler.registerCommand(new ConfirmCommand(this));
|
||||
|
@ -51,6 +51,15 @@ public interface MVWorldManager {
|
||||
*/
|
||||
public boolean unloadWorld(String name, boolean safely);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
@ -140,12 +140,12 @@ public class WorldManager implements MVWorldManager {
|
||||
public boolean removeWorldFromConfig(String name) {
|
||||
if (this.configWorlds.getProperty("worlds." + name) != null) {
|
||||
removeWorldFromList(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.save();
|
||||
return true;
|
||||
} 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;
|
||||
}
|
||||
@ -160,7 +160,7 @@ public class WorldManager implements MVWorldManager {
|
||||
|
||||
if (this.worlds.containsKey(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.unloadWorld(name, true);
|
||||
return true;
|
||||
} else if (this.plugin.getServer().getWorld(name) != null) {
|
||||
@ -172,6 +172,31 @@ public class WorldManager implements MVWorldManager {
|
||||
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) {
|
||||
|
||||
if (this.plugin.getServer().getWorld(name) != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user