Made CustomGenerators up to spec

This commit is contained in:
Eric Stokes 2011-06-26 10:45:02 -06:00
parent ca8a017d32
commit 358dab345a
3 changed files with 32 additions and 10 deletions

View File

@ -79,7 +79,7 @@ public class MVWorld {
this.setRealMobBehaviors(); this.setRealMobBehaviors();
config.setProperty("worlds." + this.name + ".environment", this.environment.toString()); config.setProperty("worlds." + this.name + ".environment", this.environment.toString());
config.setProperty("worlds." + this.name + ".generatorString",generatorString); config.setProperty("worlds." + this.name + ".generator",generatorString);
if (seed != null) { if (seed != null) {
config.setProperty("worlds." + this.name + ".seed", this.seed); config.setProperty("worlds." + this.name + ".seed", this.seed);
} }

View File

@ -86,7 +86,7 @@ public class MultiverseCore extends JavaPlugin {
// Setup the block/player/entity listener. // Setup the block/player/entity listener.
private MVPlayerListener playerListener = new MVPlayerListener(this);; private MVPlayerListener playerListener = new MVPlayerListener(this);;
@SuppressWarnings("unused")
private MVBlockListener blockListener = new MVBlockListener(this); private MVBlockListener blockListener = new MVBlockListener(this);
private MVEntityListener entityListener = new MVEntityListener(this); private MVEntityListener entityListener = new MVEntityListener(this);
private MVPluginListener pluginListener = new MVPluginListener(this); private MVPluginListener pluginListener = new MVPluginListener(this);
@ -329,10 +329,9 @@ public class MultiverseCore extends JavaPlugin {
log(Level.INFO, "Loading World & Settings - '" + worldKey + "' - " + environment); log(Level.INFO, "Loading World & Settings - '" + worldKey + "' - " + environment);
String generator = this.configWorlds.getString("worlds." + worldKey + ".generator.name"); String generatorstring = this.configWorlds.getString("worlds." + worldKey + ".generator");
String generatorID = this.configWorlds.getString("worlds." + worldKey + ".generator.id");
addWorld(worldKey, getEnvFromString(environment), seedString, generator + ":" + generatorID); addWorld(worldKey, getEnvFromString(environment), seedString, generatorstring);
// Increment the world count // Increment the world count
count++; count++;
@ -390,7 +389,7 @@ public class MultiverseCore extends JavaPlugin {
* @param environment Environment Type * @param environment Environment Type
*/ */
public boolean addWorld(String name, Environment env, String seedString, String generator) { public boolean addWorld(String name, Environment env, String seedString, String generator) {
this.debugLog(Level.CONFIG, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
Long seed = null; Long seed = null;
if (seedString != null && seedString.length() > 0) { if (seedString != null && seedString.length() > 0) {
try { try {
@ -410,6 +409,18 @@ public class MultiverseCore extends JavaPlugin {
} }
ChunkGenerator customGenerator = getChunkGenerator(generatorName, generatorID, name); ChunkGenerator customGenerator = getChunkGenerator(generatorName, generatorID, name);
if (customGenerator == null && generator != null && !generator.isEmpty()) {
if(!pluginExists(generatorName)) {
log(Level.WARNING, "Could not find plugin: " + generatorName);
} else {
log(Level.WARNING, "Found plugin: " + generatorName + ", but did not find generatorID: " + generatorID);
}
return false;
}
World world = null; World world = null;
if (seed != null) { if (seed != null) {
if (customGenerator != null) { if (customGenerator != null) {
@ -432,6 +443,10 @@ public class MultiverseCore extends JavaPlugin {
return true; return true;
} }
private boolean pluginExists(String generator) {
Plugin plugin = getServer().getPluginManager().getPlugin(generator);
return plugin != null;
}
private ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) { private ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) {
if (generator == null) { if (generator == null) {
@ -666,7 +681,7 @@ public class MultiverseCore extends JavaPlugin {
cancelQueuedCommand(sender); cancelQueuedCommand(sender);
this.queuedCommands.add(new QueuedCommand(methodName, args, paramTypes, sender, Calendar.getInstance(), this, success, fail)); this.queuedCommands.add(new QueuedCommand(methodName, args, paramTypes, sender, Calendar.getInstance(), this, success, fail));
sender.sendMessage("The command " + ChatColor.RED + commandName + ChatColor.WHITE + " has been halted due to the fact that it could break something!"); sender.sendMessage("The command " + ChatColor.RED + commandName + ChatColor.WHITE + " has been halted due to the fact that it could break something!");
sender.sendMessage("If you still wish to execute " + ChatColor.RED + commandName + ChatColor.WHITE); sender.sendMessage("If you still wish to execute " + ChatColor.RED + commandName + ChatColor.WHITE);
sender.sendMessage("please type: " + ChatColor.GREEN + "/mvconfirm"); sender.sendMessage("please type: " + ChatColor.GREEN + "/mvconfirm");
sender.sendMessage(ChatColor.GREEN + "/mvconfirm" + ChatColor.WHITE + " will only be available for 10 seconds."); sender.sendMessage(ChatColor.GREEN + "/mvconfirm" + ChatColor.WHITE + " will only be available for 10 seconds.");
} }

View File

@ -1,6 +1,7 @@
package com.onarandombox.MultiverseCore.command.commands; package com.onarandombox.MultiverseCore.command.commands;
import java.io.File; import java.io.File;
import java.util.logging.Level;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
@ -17,7 +18,7 @@ public class CreateCommand extends BaseCommand {
this.description = "Creates a new world of the specified type"; this.description = "Creates a new world of the specified type";
this.usage = "/mvcreate" + ChatColor.GREEN + " {NAME} {TYPE}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:GENID]]"; this.usage = "/mvcreate" + ChatColor.GREEN + " {NAME} {TYPE}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:GENID]]";
this.minArgs = 2; this.minArgs = 2;
this.maxArgs = 4; this.maxArgs = 6;
this.identifiers.add("mvcreate"); this.identifiers.add("mvcreate");
this.permission = "multiverse.world.create"; this.permission = "multiverse.world.create";
this.requiresOp = true; this.requiresOp = true;
@ -26,11 +27,16 @@ public class CreateCommand extends BaseCommand {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(args.length %2 != 0) {
sender.sendMessage("You must preface your SEED with -s OR your GENERATOR with -g. Type /mv for help");
return;
}
String worldName = args[0]; String worldName = args[0];
String env = args[1]; String env = args[1];
String seed = this.getFlag("-s", args); String seed = this.getFlag("-s", args);
String generator = this.getFlag("-g", args); String generator = this.getFlag("-g", args);
if (new File(worldName).exists() || this.plugin.isMVWorld(worldName)) { if (new File(worldName).exists() || this.plugin.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!"); sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport"); sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
@ -38,7 +44,7 @@ public class CreateCommand extends BaseCommand {
} }
Environment environment = this.plugin.getEnvFromString(env); Environment environment = this.plugin.getEnvFromString(env);
sender.sendMessage(ChatColor.AQUA + "Starting world creation...");
if (this.plugin.addWorld(worldName, environment, seed, generator)) { if (this.plugin.addWorld(worldName, environment, seed, generator)) {
sender.sendMessage(ChatColor.GREEN + "Complete!"); sender.sendMessage(ChatColor.GREEN + "Complete!");
} else { } else {
@ -60,7 +66,8 @@ public class CreateCommand extends BaseCommand {
try { try {
for (String s : args) { for (String s : args) {
if (s.equalsIgnoreCase(flag)) { if (s.equalsIgnoreCase(flag)) {
return args[i++]; this.plugin.debugLog(Level.CONFIG, args[i+1]);
return args[i+1];
} }
i++; i++;
} }