diff --git a/src/com/onarandombox/MultiverseCore/MVWorld.java b/src/com/onarandombox/MultiverseCore/MVWorld.java index cadf4df7..742af067 100644 --- a/src/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/com/onarandombox/MultiverseCore/MVWorld.java @@ -15,7 +15,7 @@ public class MVWorld { private Configuration config; // Hold the Configuration File. public World world; // The World Instance. - public Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL + public String environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL public Long seed; public String name; // The Worlds Name, EG its folder name. @@ -44,7 +44,7 @@ public class MVWorld { this.world = world; this.name = world.getName(); - this.environment = world.getEnvironment(); + this.environment = env; this.seed = seed; initLists(); diff --git a/src/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/com/onarandombox/MultiverseCore/MultiverseCore.java index 1bac3290..f1f0e7db 100644 --- a/src/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -3,6 +3,7 @@ package com.onarandombox.MultiverseCore; import java.io.File; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -97,7 +98,7 @@ public class MultiverseCore extends JavaPlugin { public HashMap worlds = new HashMap(); // HashMap to contain all custom generators. Plugins will have to register! - public HashMap worldGenerators = new HashMap(); + private HashMap worldGenerators = new HashMap(); // HashMap to contain information relating to the Players. public HashMap playerSessions = new HashMap(); @@ -307,6 +308,7 @@ public class MultiverseCore extends JavaPlugin { commandManager.addCommand(new InfoCommand(this)); commandManager.addCommand(new ReloadCommand(this)); commandManager.addCommand(new ModifyCommand(this)); + commandManager.addCommand(new EnvironmentCommand(this)); } /** @@ -652,19 +654,22 @@ public class MultiverseCore extends JavaPlugin { try { return Environment.valueOf(env); } catch (IllegalArgumentException e) { - // Sender will be null on loadWorlds return null; - // TODO: Show the player the mvenvironments command. } } - public ChunkGenerator getChunkGenFromEnv(String env) { + private ChunkGenerator getChunkGenFromEnv(String env) { if (worldGenerators.containsKey(env)) { return worldGenerators.get(env); } return null; } - + /** + * Other plugin devs can use this to tell MultiVerse about other environment types + * @param name + * @param generator + * @return + */ public boolean registerEnvType(String name, ChunkGenerator generator) { if (this.worldGenerators.containsKey(name)) { return false; @@ -725,4 +730,12 @@ public class MultiverseCore extends JavaPlugin { queuedCommands.remove(c); } } + + public Set getWorldGenerators() { + return this.worldGenerators.keySet(); + } + + public Collection getWorlds() { + return this.worlds.values(); + } } diff --git a/src/com/onarandombox/MultiverseCore/command/commands/CreateCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/CreateCommand.java index f1ce5b1e..3844542d 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/CreateCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/CreateCommand.java @@ -3,7 +3,6 @@ package com.onarandombox.MultiverseCore.command.commands; import java.io.File; import org.bukkit.ChatColor; -import org.bukkit.World.Environment; import org.bukkit.command.CommandSender; import com.onarandombox.MultiverseCore.MultiverseCore; @@ -48,7 +47,8 @@ public class CreateCommand extends BaseCommand { } else { sender.sendMessage(ChatColor.RED + "FAILED."); if(plugin.getEnvFromString(env) == null) { - sender.sendMessage("I should show the envs I know here..."); + sender.sendMessage("That world type did not exist."); + sender.sendMessage("For a list of available world types, type: /mvenv"); } } return; diff --git a/src/com/onarandombox/MultiverseCore/command/commands/EnvironmentCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/EnvironmentCommand.java index 55c7f75a..4abcfee7 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/EnvironmentCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/EnvironmentCommand.java @@ -7,14 +7,14 @@ import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.command.BaseCommand; public class EnvironmentCommand extends BaseCommand{ - + public EnvironmentCommand(MultiverseCore plugin) { super(plugin); this.name = "List Environments"; this.description = "Lists valid known environments"; this.usage = "/mvenv"; - this.minArgs = 2; - this.maxArgs = 2; + this.minArgs = 0; + this.maxArgs = 0; this.identifiers.add("mvenv"); this.permission = "multiverse.world.list.environments"; this.requiresOp = false; @@ -22,10 +22,20 @@ public class EnvironmentCommand extends BaseCommand{ @Override public void execute(CommandSender sender, String[] args) { + this.showEnvironments(sender); + } + + public void showEnvironments(CommandSender sender) { sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:"); sender.sendMessage(ChatColor.GREEN + "NORMAL"); sender.sendMessage(ChatColor.RED + "NETHER"); sender.sendMessage(ChatColor.AQUA + "SKYLANDS"); + if(plugin.getWorldGenerators().size() > 0) { + sender.sendMessage(ChatColor.DARK_AQUA + "CUSTOM WORLD TYPES:"); + } + for(String s : plugin.getWorldGenerators()) { + sender.sendMessage(ChatColor.GOLD + s); + } } } diff --git a/src/com/onarandombox/MultiverseCore/command/commands/ImportCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/ImportCommand.java index f6a85a7f..c45238cf 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/ImportCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/ImportCommand.java @@ -3,7 +3,6 @@ package com.onarandombox.MultiverseCore.command.commands; import java.io.File; import org.bukkit.ChatColor; -import org.bukkit.World.Environment; import org.bukkit.command.CommandSender; import com.onarandombox.MultiverseCore.MultiverseCore; @@ -40,7 +39,8 @@ public class ImportCommand extends BaseCommand { return; } else if(env == null) { sender.sendMessage(ChatColor.RED + "FAILED."); - sender.sendMessage("I should show valid envs here..."); + sender.sendMessage("That world type did not exist."); + sender.sendMessage("For a list of available world types, type: /mvenv"); } else { sender.sendMessage(ChatColor.RED + "FAILED."); sender.sendMessage("That world folder does not exist..."); diff --git a/src/com/onarandombox/MultiverseCore/command/commands/ListCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/ListCommand.java index 25c20b2f..2017d04f 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/ListCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/ListCommand.java @@ -25,6 +25,7 @@ public class ListCommand extends BaseCommand { @Override public void execute(CommandSender sender, String[] args) { + //TODO: Show custom worldtypes Player p = null; if (sender instanceof Player) { p = (Player) sender; diff --git a/src/com/onarandombox/MultiverseCore/command/commands/MVPurge.java b/src/com/onarandombox/MultiverseCore/command/commands/MVPurge.java index 46d4e6df..1ae445f6 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/MVPurge.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/MVPurge.java @@ -6,7 +6,6 @@ import java.util.List; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.onarandombox.MultiverseCore.MVCommandHandler; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.utils.PurgeWorlds; diff --git a/src/com/onarandombox/MultiverseCore/command/commands/ModifyCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/ModifyCommand.java index 458530bc..4438c070 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/ModifyCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/ModifyCommand.java @@ -2,7 +2,6 @@ package com.onarandombox.MultiverseCore.command.commands; import org.bukkit.command.CommandSender; -import com.onarandombox.MultiverseCore.MVCommandHandler; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.command.BaseCommand; diff --git a/src/com/onarandombox/MultiverseCore/command/commands/WhoCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/WhoCommand.java index 0d7f6831..cbd066b0 100644 --- a/src/com/onarandombox/MultiverseCore/command/commands/WhoCommand.java +++ b/src/com/onarandombox/MultiverseCore/command/commands/WhoCommand.java @@ -9,6 +9,7 @@ import org.bukkit.World.Environment; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import com.onarandombox.MultiverseCore.MVWorld; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.command.BaseCommand; @@ -34,36 +35,42 @@ public class WhoCommand extends BaseCommand { p = (Player) sender; } - List worlds = new ArrayList(); + List worlds = new ArrayList(); if (args.length > 0) { - World world = plugin.getServer().getWorld(args[0].toString()); - if (world != null) { - worlds.add(world); + if (plugin.worlds.containsKey(args[0])) { + worlds.add(plugin.worlds.get(args[0])); } else { sender.sendMessage(ChatColor.RED + "World does not exist"); return; } } else { - worlds = plugin.getServer().getWorlds(); + worlds = new ArrayList(plugin.getWorlds()); } - for (World world : worlds) { - if (!(plugin.worlds.containsKey(world.getName()))) { + for (MVWorld world : worlds) { + if (!(plugin.worlds.containsKey(world.name))) { continue; } - if (p != null && (!plugin.ph.canEnterWorld(p, world))) { + + World w = plugin.getServer().getWorld(world.name); + if (p != null && (!plugin.ph.canEnterWorld(p, w))) { continue; } - ChatColor color = ChatColor.BLUE; - if (world.getEnvironment() == Environment.NETHER) { + + ChatColor color = ChatColor.GOLD; + Environment env = plugin.getEnvFromString(world.environment); + if(plugin.getEnvFromString(world.environment) == null) { + color = ChatColor.GOLD; + } + else if (env == Environment.NETHER) { color = ChatColor.RED; - } else if (world.getEnvironment() == Environment.NORMAL) { + } else if (env == Environment.NORMAL) { color = ChatColor.GREEN; - } else if (world.getEnvironment() == Environment.SKYLANDS) { + } else if (env == Environment.SKYLANDS) { color = ChatColor.AQUA; } - List players = world.getPlayers(); + List players = w.getPlayers(); String result = ""; if (players.size() <= 0) { @@ -73,7 +80,7 @@ public class WhoCommand extends BaseCommand { result += player.getName() + " "; } } - sender.sendMessage(color + world.getName() + ChatColor.WHITE + " - " + result); + sender.sendMessage(color + world.name + ChatColor.WHITE + " - " + result); } return; } diff --git a/src/plugin.yml b/src/plugin.yml index 7aa70fd7..002957fc 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -83,3 +83,7 @@ commands: description: Gets world info. usage: | / [world] + mvenv: + description: Tells the user all possible world types. + usage: | + /