Fixed Spacing, fixed Modify commands

This commit is contained in:
Eric Stokes 2011-07-09 08:33:18 -06:00
parent fc9aa456da
commit 2985167936
24 changed files with 147 additions and 332 deletions

View File

@ -165,25 +165,25 @@ public class MultiverseCore extends JavaPlugin {
} }
/** /**
* Register Multiverse-Core commands to DThielke's Command Manager. * Register Multiverse-Core commands to Command Manager.
*/ */
private void registerCommands() { private void registerCommands() {
// Page 1 // Page 1
// this.commandManager.addCommand(new HelpCommand(this)); this.commandManager.addCommand(new HelpCommand(this));
// this.commandManager.addCommand(new CoordCommand(this)); this.commandManager.addCommand(new CoordCommand(this));
// this.commandManager.addCommand(new TeleportCommand(this)); this.commandManager.addCommand(new TeleportCommand(this));
// this.commandManager.addCommand(new ListCommand(this)); this.commandManager.addCommand(new ListCommand(this));
// this.commandManager.addCommand(new WhoCommand(this)); this.commandManager.addCommand(new WhoCommand(this));
// this.commandManager.addCommand(new SetSpawnCommand(this)); this.commandManager.addCommand(new SetSpawnCommand(this));
// this.commandManager.addCommand(new CreateCommand(this)); this.commandManager.addCommand(new CreateCommand(this));
// this.commandManager.addCommand(new ImportCommand(this)); this.commandManager.addCommand(new ImportCommand(this));
// this.commandManager.addCommand(new SpawnCommand(this)); this.commandManager.addCommand(new SpawnCommand(this));
// this.commandManager.addCommand(new RemoveCommand(this)); this.commandManager.addCommand(new RemoveCommand(this));
// this.commandManager.addCommand(new DeleteCommand(this)); this.commandManager.addCommand(new DeleteCommand(this));
// this.commandManager.addCommand(new UnloadCommand(this)); this.commandManager.addCommand(new UnloadCommand(this));
// this.commandManager.addCommand(new ConfirmCommand(this)); this.commandManager.addCommand(new ConfirmCommand(this));
// this.commandManager.addCommand(new InfoCommand(this)); this.commandManager.addCommand(new InfoCommand(this));
// this.commandManager.addCommand(new ReloadCommand(this)); this.commandManager.addCommand(new ReloadCommand(this));
this.commandManager.addCommand(new ModifyAddCommand(this)); this.commandManager.addCommand(new ModifyAddCommand(this));
this.commandManager.addCommand(new ModifySetCommand(this)); this.commandManager.addCommand(new ModifySetCommand(this));
@ -463,13 +463,9 @@ public class MultiverseCore extends JavaPlugin {
sender.sendMessage("This plugin is Disabled!"); sender.sendMessage("This plugin is Disabled!");
return true; return true;
} }
System.out.print("Command executed!");
System.out.print(command.getName());
System.out.print(Arrays.toString(args));
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args)); ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
allArgs.add(0, command.getName()); allArgs.add(0, command.getName());
return this.commandManager.dispatch(sender, allArgs); return this.commandManager.dispatch(sender, allArgs);
// return this.commandManager.dispatch(sender, command, commandLabel, args);
} }
/** /**

View File

@ -1,7 +1,6 @@
package com.onarandombox.MultiverseCore.command; package com.onarandombox.MultiverseCore.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -29,22 +28,6 @@ public abstract class BaseCommand {
public abstract void execute(CommandSender sender, String[] args); public abstract void execute(CommandSender sender, String[] args);
@Deprecated
public boolean validate(String name, String[] parsedArgs, StringBuilder identifier) {
String match = this.matchIdentifier(name, parsedArgs);
if (match != null) {
identifier = identifier.append(match);
if (parsedArgs == null) {
parsedArgs = new String[0];
}
int l = parsedArgs.length;
if (l >= this.minArgs && (this.maxArgs == -1 || l <= this.maxArgs)) {
return true;
}
}
return false;
}
public boolean validate(ArrayList<String> args) { public boolean validate(ArrayList<String> args) {
int argsLength = args.size(); int argsLength = args.size();
if ((argsLength == -1 || argsLength >= this.minArgs) && (this.maxArgs == -1 || argsLength <= this.maxArgs)) { if ((argsLength == -1 || argsLength >= this.minArgs) && (this.maxArgs == -1 || argsLength <= this.maxArgs)) {
@ -53,29 +36,8 @@ public abstract class BaseCommand {
return false; return false;
} }
@Deprecated
public String matchIdentifier(String input, String[] args) {
String argsString = this.getArgsString(args);
String lower = input.toLowerCase() + argsString;
int index = -1;
int n = this.identifiers.size();
for (int i = 0; i < n; i++) {
String identifier = this.identifiers.get(i).toLowerCase();
if (index == -1 && lower.matches(identifier + "(\\s+.*|\\s*)")) {
index = i;
}
}
if (index != -1) {
return this.identifiers.get(index);
} else {
return null;
}
}
public String getIdentifier(ArrayList<String> allArgs) { public String getIdentifier(ArrayList<String> allArgs) {
// Combines our args to a space seperated string // Combines our args to a space separated string
String argsString = this.getArgsString(allArgs); String argsString = this.getArgsString(allArgs);
for (String s : this.identifiers) { for (String s : this.identifiers) {
@ -96,36 +58,6 @@ public abstract class BaseCommand {
return allArgs; return allArgs;
} }
protected String[] removeRedundantArgs(String[] args, String command) {
System.out.print("Attempting to remove redundant args:");
System.out.print(Arrays.toString(args));
System.out.print(command);
String[] cmdSplit = command.split(" ");
// Start at cmdSplit[1], because 0 is the command name
int match = 0;
int i = 0;
while (i + 1 < cmdSplit.length && i < args.length && cmdSplit[i + 1].equalsIgnoreCase(args[i])) {
System.out.print("Found a match!");
match = i + 1;
i++;
}
ArrayList<String> newArgs = new ArrayList<String>();
for (int j = match; j < args.length; j++) {
newArgs.add(args[j]);
}
String[] mynewArr = {};
return newArgs.toArray(mynewArr);
}
@Deprecated
private String getArgsString(String[] args) {
String returnString = "";
for (String s : args) {
returnString += " " + s;
}
return returnString;
}
private String getArgsString(ArrayList<String> args) { private String getArgsString(ArrayList<String> args) {
String returnString = ""; String returnString = "";
for (String s : args) { for (String s : args) {

View File

@ -9,14 +9,11 @@
package com.onarandombox.MultiverseCore.command; package com.onarandombox.MultiverseCore.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
@ -68,53 +65,6 @@ public class CommandManager {
sender.sendMessage(ChatColor.AQUA + "Usage: " + ChatColor.WHITE + foundCommand.getUsage()); sender.sendMessage(ChatColor.AQUA + "Usage: " + ChatColor.WHITE + foundCommand.getUsage());
} }
} }
@Deprecated
public boolean dispatch(CommandSender sender, Command command, String label, String[] args) {
BaseCommand match = null;
String[] trimmedArgs = null;
StringBuilder identifier = new StringBuilder();
String[] finalArgs = null;
for (BaseCommand cmd : this.commands) {
StringBuilder tmpIdentifier = new StringBuilder();
String[] tmpArgs = parseAllQuotedStrings(args);
System.out.print("Before Args");
System.out.print(Arrays.toString(tmpArgs));
if (match == null) {
match = cmd.matchIdentifier(label, tmpArgs) == null ? null : cmd;
// If we have a valid match, then we want to remove any extraneous words.
// For example: /mvmodiy add is the name of a command, we want the command
// to never see the "add"
if (match != null) {
finalArgs = cmd.removeRedundantArgs(tmpArgs, cmd.matchIdentifier(label, tmpArgs));
}
}
System.out.print("After Args");
System.out.print(Arrays.toString(tmpArgs));
if (match != null && cmd.validate(label, tmpArgs, tmpIdentifier) && tmpIdentifier.length() > identifier.length()) {
identifier = tmpIdentifier;
trimmedArgs = tmpArgs;
}
}
if (match != null) {
if (this.plugin.ph.hasPermission(sender, match.getPermission(), match.isOpRequired())) {
if (finalArgs != null) {
match.execute(sender, finalArgs);
} else {
sender.sendMessage(ChatColor.AQUA + "Command: " + ChatColor.WHITE + match.getName());
sender.sendMessage(ChatColor.AQUA + "Description: " + ChatColor.WHITE + match.getDescription());
sender.sendMessage(ChatColor.AQUA + "Usage: " + ChatColor.WHITE + match.getUsage());
}
} else {
sender.sendMessage("You do not have permission to use this command. (" + match.getPermission() + ")");
}
}
return true;
}
public void addCommand(BaseCommand command) { public void addCommand(BaseCommand command) {
this.commands.add(command); this.commands.add(command);
@ -139,63 +89,6 @@ public class CommandManager {
return playerCommands; return playerCommands;
} }
/**
* Combines all quoted strings
*
* @param args
* @return
*/
@Deprecated
private String[] parseAllQuotedStrings(String[] args) {
// TODO: Allow '
ArrayList<String> newArgs = new ArrayList<String>();
// Iterate through all command params:
// we could have: "Fish dog" the man bear pig "lives today" and maybe "even tomorrow" or "the" next day
int start = -1;
for (int i = 0; i < args.length; i++) {
// If we aren't looking for an end quote, and the first part of a string is a quote
if (start == -1 && args[i].substring(0, 1).equals("\"")) {
start = i;
}
// Have to keep this seperate for one word quoted strings like: "fish"
if (start != -1 && args[i].substring(args[i].length() - 1, args[i].length()).equals("\"")) {
// Now we've found the second part of a string, let's parse the quoted one out
// Make sure it's i+1, we still want I included
newArgs.add(parseQuotedString(args, start, i + 1));
// Reset the start to look for more!
start = -1;
} else if (start == -1) {
// This is a word that is NOT enclosed in any quotes, so just add it
newArgs.add(args[i]);
}
}
// If the string was ended but had an open quote...
if (start != -1) {
// ... then we want to close that quote and make that one arg.
newArgs.add(parseQuotedString(args, start, args.length));
}
return newArgs.toArray(new String[newArgs.size()]);
}
/**
* Takes a string array and returns a combined string, excluding the stop position, including the start
*
* @param args
* @param start
* @param stop
* @return
*/
@Deprecated
private String parseQuotedString(String[] args, int start, int stop) {
String returnVal = args[start];
for (int i = start + 1; i < stop; i++) {
returnVal += " " + args[i];
}
return returnVal.replace("\"", "");
}
/** /**
* Combines all quoted strings * Combines all quoted strings
* *

View File

@ -6,7 +6,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class ConfirmCommand extends BaseCommand { public class ConfirmCommand extends BaseCommand {
public ConfirmCommand(MultiverseCore plugin) { public ConfirmCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Confirms a command that could destroy life, the universe and everything."; this.name = "Confirms a command that could destroy life, the universe and everything.";
@ -19,10 +19,10 @@ public class ConfirmCommand extends BaseCommand {
// Any command that is dangerous should require op // Any command that is dangerous should require op
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
this.plugin.getCommandManager().confirmQueuedCommand(sender); this.plugin.getCommandManager().confirmQueuedCommand(sender);
} }
} }

View File

@ -27,7 +27,7 @@ public class CoordCommand extends BaseCommand {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
// Check if the command was sent from a Player. // Check if the command was sent from a Player.
if (sender instanceof Player) { if (sender instanceof Player) {
Player p = (Player) sender; Player p = (Player) sender;
p.sendMessage(ChatColor.RED + "World: " + ChatColor.WHITE + p.getWorld().getName()); p.sendMessage(ChatColor.RED + "World: " + ChatColor.WHITE + p.getWorld().getName());
p.sendMessage(ChatColor.RED + "World Scale: " + ChatColor.WHITE + this.plugin.getMVWorld(p.getWorld().getName()).getScaling()); p.sendMessage(ChatColor.RED + "World Scale: " + ChatColor.WHITE + this.plugin.getMVWorld(p.getWorld().getName()).getScaling());
p.sendMessage(ChatColor.RED + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation())); p.sendMessage(ChatColor.RED + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation()));

View File

@ -11,7 +11,7 @@ import com.onarandombox.MultiverseCore.command.BaseCommand;
import com.onarandombox.MultiverseCore.command.CommandManager; import com.onarandombox.MultiverseCore.command.CommandManager;
public class CreateCommand extends BaseCommand { public class CreateCommand extends BaseCommand {
public CreateCommand(MultiverseCore plugin) { public CreateCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Create World"; this.name = "Create World";
@ -22,9 +22,8 @@ public class CreateCommand extends BaseCommand {
this.identifiers.add("mvcreate"); this.identifiers.add("mvcreate");
this.permission = "multiverse.world.create"; this.permission = "multiverse.world.create";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if (args.length % 2 != 0) { if (args.length % 2 != 0) {
@ -35,13 +34,13 @@ public class CreateCommand extends BaseCommand {
String env = args[1]; String env = args[1];
String seed = CommandManager.getFlag("-s", args); String seed = CommandManager.getFlag("-s", args);
String generator = CommandManager.getFlag("-g", args); String generator = CommandManager.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");
return; return;
} }
Environment environment = this.plugin.getEnvFromString(env); Environment environment = this.plugin.getEnvFromString(env);
if (environment == null) { if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment."); sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
@ -56,5 +55,4 @@ public class CreateCommand extends BaseCommand {
} }
return; return;
} }
} }

View File

@ -7,7 +7,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class DeleteCommand extends BaseCommand { public class DeleteCommand extends BaseCommand {
public DeleteCommand(MultiverseCore plugin) { public DeleteCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Delete World"; this.name = "Delete World";
@ -19,11 +19,10 @@ public class DeleteCommand extends BaseCommand {
this.permission = "multiverse.world.delete"; this.permission = "multiverse.world.delete";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
Class<?> paramTypes[] = {String.class}; Class<?> paramTypes[] = { String.class };
this.plugin.getCommandManager().queueCommand(sender, "mvdelete", "deleteWorld", args, paramTypes, "World Deleted!", "World was not deleted!"); this.plugin.getCommandManager().queueCommand(sender, "mvdelete", "deleteWorld", args, paramTypes, "World Deleted!", "World was not deleted!");
} }
} }

View File

@ -6,8 +6,8 @@ import org.bukkit.command.CommandSender;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class EnvironmentCommand extends BaseCommand{ public class EnvironmentCommand extends BaseCommand {
public EnvironmentCommand(MultiverseCore plugin) { public EnvironmentCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "List Environments"; this.name = "List Environments";
@ -24,12 +24,11 @@ public class EnvironmentCommand extends BaseCommand{
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
EnvironmentCommand.showEnvironments(sender); EnvironmentCommand.showEnvironments(sender);
} }
public static void showEnvironments(CommandSender sender) { public static void showEnvironments(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:"); sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
sender.sendMessage(ChatColor.GREEN + "NORMAL"); sender.sendMessage(ChatColor.GREEN + "NORMAL");
sender.sendMessage(ChatColor.RED + "NETHER"); sender.sendMessage(ChatColor.RED + "NETHER");
sender.sendMessage(ChatColor.AQUA + "SKYLANDS"); sender.sendMessage(ChatColor.AQUA + "SKYLANDS");
} }
} }

View File

@ -5,7 +5,8 @@
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to
* Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. * Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
**/ **/
// Technically this is already a derivative work even by changing the package name. DThielke voiced it OK to modify, but we really should
// get this license changed...
package com.onarandombox.MultiverseCore.command.commands; package com.onarandombox.MultiverseCore.command.commands;
import java.util.List; import java.util.List;
@ -61,7 +62,7 @@ public class HelpCommand extends BaseCommand {
} }
for (int c = start; c < end; c++) { for (int c = start; c < end; c++) {
BaseCommand cmd = commands.get(c); BaseCommand cmd = commands.get(c);
sender.sendMessage(ChatColor.AQUA + " " + cmd.getUsage()); sender.sendMessage(ChatColor.AQUA + " " + cmd.getUsage());
} }

View File

@ -30,26 +30,26 @@ public class ImportCommand extends BaseCommand {
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!"); sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
return; return;
} }
String generator = null; String generator = null;
if(args.length == 3) { if (args.length == 3) {
generator = args[2]; generator = args[2];
} }
String env = args[1]; String env = args[1];
Environment environment = this.plugin.getEnvFromString(env); Environment environment = this.plugin.getEnvFromString(env);
if(environment == null) { if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment."); sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender); EnvironmentCommand.showEnvironments(sender);
return; return;
} }
if (new File(worldName).exists() && env != null) { if (new File(worldName).exists() && env != null) {
sender.sendMessage(ChatColor.AQUA + "Starting world import..."); sender.sendMessage(ChatColor.AQUA + "Starting world import...");
this.plugin.addWorld(worldName, environment, null, generator); this.plugin.addWorld(worldName, environment, null, generator);
sender.sendMessage(ChatColor.GREEN + "Complete!"); sender.sendMessage(ChatColor.GREEN + "Complete!");
return; return;
} else if(env == null) { } else if (env == null) {
sender.sendMessage(ChatColor.RED + "FAILED."); sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world type did not exist."); sender.sendMessage("That world type did not exist.");
sender.sendMessage("For a list of available world types, type: /mvenv"); sender.sendMessage("For a list of available world types, type: /mvenv");
@ -58,5 +58,4 @@ public class ImportCommand extends BaseCommand {
sender.sendMessage("That world folder does not exist..."); sender.sendMessage("That world folder does not exist...");
} }
} }
} }

View File

@ -11,7 +11,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class InfoCommand extends BaseCommand { public class InfoCommand extends BaseCommand {
public InfoCommand(MultiverseCore plugin) { public InfoCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "World Information"; this.name = "World Information";
@ -23,7 +23,7 @@ public class InfoCommand extends BaseCommand {
this.permission = "multiverse.world.info"; this.permission = "multiverse.world.info";
this.requiresOp = false; this.requiresOp = false;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
// Check if the command was sent from a Player. // Check if the command was sent from a Player.
@ -42,22 +42,22 @@ public class InfoCommand extends BaseCommand {
} }
} }
} }
private String[] buildEntireCommand(MVWorld world) { private String[] buildEntireCommand(MVWorld world) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
ArrayList<String[]> pagedInfo = new ArrayList<String[]>(); ArrayList<String[]> pagedInfo = new ArrayList<String[]>();
String[] aPage = new String[5]; String[] aPage = new String[5];
// World Name: 1 // World Name: 1
aPage[0] = "World: " + world.getName(); aPage[0] = "World: " + world.getName();
// World Scale: 1 // World Scale: 1
aPage[1] = "World Scale: " + world.getScaling(); aPage[1] = "World Scale: " + world.getScaling();
// PVP: 1 // PVP: 1
aPage[2] = "PVP: " + world.getPvp(); aPage[2] = "PVP: " + world.getPvp();
aPage[3] = "Animals: " + world.allowAnimalSpawning(); aPage[3] = "Animals: " + world.allowAnimalSpawning();
aPage[4] = "Monsters: " + world.allowMonsterSpawning(); aPage[4] = "Monsters: " + world.allowMonsterSpawning();
// This feature is not mission critical and I am spending too much time on it... // This feature is not mission critical and I am spending too much time on it...
// Stopping work on it for now --FF 20110623 // Stopping work on it for now --FF 20110623
// // Animal Spawning: X // // Animal Spawning: X
@ -99,7 +99,7 @@ public class InfoCommand extends BaseCommand {
// } // }
return aPage; return aPage;
} }
private ChatColor getChatColor(boolean positive) { private ChatColor getChatColor(boolean positive) {
return positive ? ChatColor.GREEN : ChatColor.RED; return positive ? ChatColor.GREEN : ChatColor.RED;
} }

View File

@ -10,7 +10,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class ListCommand extends BaseCommand { public class ListCommand extends BaseCommand {
public ListCommand(MultiverseCore plugin) { public ListCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "World Listing"; this.name = "World Listing";
@ -22,21 +22,21 @@ public class ListCommand extends BaseCommand {
this.permission = "multiverse.world.list"; this.permission = "multiverse.world.list";
this.requiresOp = false; this.requiresOp = false;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
Player p = null; Player p = null;
if (sender instanceof Player) { if (sender instanceof Player) {
p = (Player) sender; p = (Player) sender;
} }
String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n"; String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
for (MVWorld world : this.plugin.getMVWorlds()) { for (MVWorld world : this.plugin.getMVWorlds()) {
if (p != null && (!this.plugin.ph.canEnterWorld(p, world.getCBWorld()))) { if (p != null && (!this.plugin.ph.canEnterWorld(p, world.getCBWorld()))) {
continue; continue;
} }
ChatColor color = ChatColor.GOLD; ChatColor color = ChatColor.GOLD;
Environment env = world.getEnvironment(); Environment env = world.getEnvironment();
if (env == Environment.NETHER) { if (env == Environment.NETHER) {
@ -47,11 +47,11 @@ public class ListCommand extends BaseCommand {
color = ChatColor.AQUA; color = ChatColor.AQUA;
} }
String worldName = world.getName(); String worldName = world.getName();
if(world.getAlias() != null && world.getAlias().length() > 0) { if (world.getAlias() != null && world.getAlias().length() > 0) {
worldName = world.getAliasColor() + world.getAlias() + ChatColor.WHITE; worldName = world.getAliasColor() + world.getAlias() + ChatColor.WHITE;
} }
output += ChatColor.WHITE + worldName + " - " + color + world.getEnvironment() + " \n"; output += ChatColor.WHITE + worldName + " - " + color + world.getEnvironment() + " \n";
} }
String[] response = output.split("\n"); String[] response = output.split("\n");
for (String msg : response) { for (String msg : response) {

View File

@ -34,7 +34,7 @@ public class ModifyAddCommand extends BaseCommand {
} }
if (args.length == 2 && p == null) { if (args.length == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the command line, WORLD is required."); sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.description); sender.sendMessage(this.description);
sender.sendMessage(this.usage); sender.sendMessage(this.usage);
sender.sendMessage("Nothing changed."); sender.sendMessage("Nothing changed.");

View File

@ -9,48 +9,50 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class ModifyClearCommand extends BaseCommand { public class ModifyClearCommand extends BaseCommand {
public ModifyClearCommand(MultiverseCore plugin) { public ModifyClearCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Modify a World (Clear a property)"; this.name = "Modify a World (Clear a property)";
this.description = "Removes all values from a property. This will work on properties that contain lists"; this.description = "Removes all values from a property. This will work on properties that contain lists";
this.usage = "/mvmodify" + ChatColor.GREEN + " CLEAR {PROPERTY}" + ChatColor.GOLD + " [WORLD] "; this.usage = "/mvmodify" + ChatColor.GREEN + " CLEAR {PROPERTY}" + ChatColor.GOLD + " [WORLD] ";
this.minArgs = 2; this.minArgs = 1;
this.maxArgs = 3; this.maxArgs = 2;
this.identifiers.add("mvmodify clear"); this.identifiers.add("mvmodify clear");
this.identifiers.add("mvmclear");
this.identifiers.add("mvmc");
this.permission = "multiverse.world.modify"; this.permission = "multiverse.world.modify";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
// We NEED a world from the command line // We NEED a world from the command line
Player p = null; Player p = null;
if (!(sender instanceof Player)) { if (sender instanceof Player) {
p = (Player) sender; p = (Player) sender;
} }
if (args.length == 2 && p == null) { if (args.length == 1 && p == null) {
sender.sendMessage("From the command line, WORLD is required."); sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.description); sender.sendMessage(this.description);
sender.sendMessage(this.usage); sender.sendMessage(this.usage);
sender.sendMessage("Nothing changed."); sender.sendMessage("Nothing changed.");
return; return;
} }
MVWorld world; MVWorld world;
String property = args[1]; String property = args[0];
if (args.length == 2) { if (args.length == 1) {
world = this.plugin.getMVWorld(p.getWorld().getName()); world = this.plugin.getMVWorld(p.getWorld().getName());
} else { } else {
world = this.plugin.getMVWorld(args[2]); world = this.plugin.getMVWorld(args[1]);
} }
if (world == null) { if (world == null) {
sender.sendMessage("That world does not exist!"); sender.sendMessage("That world does not exist!");
return; return;
} }
if (!ModifyCommand.validateAction(Action.Clear, property)) { if (!ModifyCommand.validateAction(Action.Clear, property)) {
sender.sendMessage("Sorry, you can't use CLEAR with " + property); sender.sendMessage("Sorry, you can't use CLEAR with " + property);
sender.sendMessage("Please visit our wiki for more information: URLGOESHERE FERNFERRET DON'T FORGET IT!"); sender.sendMessage("Please visit our wiki for more information: URLGOESHERE FERNFERRET DON'T FORGET IT!");
@ -62,5 +64,5 @@ public class ModifyClearCommand extends BaseCommand {
sender.sendMessage(property + " was NOT cleared."); sender.sendMessage(property + " was NOT cleared.");
} }
} }
} }

View File

@ -19,31 +19,29 @@ enum SetProperties {
} }
public class ModifyCommand extends BaseCommand { public class ModifyCommand extends BaseCommand {
public ModifyCommand(MultiverseCore plugin) { public ModifyCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Modify a World"; this.name = "Modify a World";
this.description = "MVModify requires an extra parameter: SET,ADD,REMOVE or CLEAR. See below for usage."; this.description = "MVModify requires an extra parameter: SET,ADD,REMOVE or CLEAR. See below for usage.";
this.usage = "/mvmodify" + ChatColor.GREEN + " {SET|ADD|REMOVE|CLEAR} ..."; this.usage = "/mvmodify" + ChatColor.GREEN + " {SET|ADD|REMOVE|CLEAR} ...";
this.minArgs = 0; // Make it so they can NEVER execute this one
this.minArgs = 1;
this.maxArgs = 0; this.maxArgs = 0;
this.identifiers.add("mvmodify"); this.identifiers.add("mvmodify");
this.permission = "multiverse.world.modify"; this.permission = "multiverse.world.modify";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
sender.sendMessage(this.name);
sender.sendMessage(this.description);
sender.sendMessage(this.usage);
// This is just a place holder. The real commands are in: // This is just a place holder. The real commands are in:
// ModifyAddCommand // ModifyAddCommand
// ModifyRemoveCommand // ModifyRemoveCommand
// ModifySetCommand // ModifySetCommand
// ModifyClearCommand // ModifyClearCommand
} }
protected static boolean validateAction(Action action, String property) { protected static boolean validateAction(Action action, String property) {
if (action == Action.Set) { if (action == Action.Set) {
try { try {
@ -60,6 +58,6 @@ public class ModifyCommand extends BaseCommand {
return false; return false;
} }
} }
} }
} }

View File

@ -9,51 +9,53 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class ModifyRemoveCommand extends BaseCommand { public class ModifyRemoveCommand extends BaseCommand {
public ModifyRemoveCommand(MultiverseCore plugin) { public ModifyRemoveCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Modify a World"; this.name = "Modify a World";
this.description = "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used"; this.description = "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used";
this.usage = "/mvmodify" + ChatColor.GREEN + "REMOVE {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD] "; this.usage = "/mvmodify" + ChatColor.GREEN + "REMOVE {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]";
this.minArgs = 3; this.minArgs = 2;
this.maxArgs = 4; this.maxArgs = 3;
this.identifiers.add("mvmodify remove"); this.identifiers.add("mvmodify remove");
this.identifiers.add("mvmodify r"); this.identifiers.add("mvmodify r");
this.identifiers.add("mvmremove");
this.identifiers.add("mvmr");
this.permission = "multiverse.world.modify"; this.permission = "multiverse.world.modify";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
// We NEED a world from the command line // We NEED a world from the command line
Player p = null; Player p = null;
if (!(sender instanceof Player)) { if (sender instanceof Player) {
p = (Player) sender; p = (Player) sender;
} }
if (args.length == 3 && p == null) { if (args.length == 2 && p == null) {
sender.sendMessage("From the command line, WORLD is required."); sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.description); sender.sendMessage(this.description);
sender.sendMessage(this.usage); sender.sendMessage(this.usage);
sender.sendMessage("Nothing changed."); sender.sendMessage("Nothing changed.");
return; return;
} }
MVWorld world; MVWorld world;
String value = args[1]; String value = args[0];
String property = args[2]; String property = args[1];
if (args.length == 3) { if (args.length == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName()); world = this.plugin.getMVWorld(p.getWorld().getName());
} else { } else {
world = this.plugin.getMVWorld(args[3]); world = this.plugin.getMVWorld(args[2]);
} }
if (world == null) { if (world == null) {
sender.sendMessage("That world does not exist!"); sender.sendMessage("That world does not exist!");
return; return;
} }
if (!ModifyCommand.validateAction(Action.Remove, property)) { if (!ModifyCommand.validateAction(Action.Remove, property)) {
sender.sendMessage("Sorry, you can't REMOVE anything from" + property); sender.sendMessage("Sorry, you can't REMOVE anything from" + property);
sender.sendMessage("Please visit our wiki for more information: URLGOESHERE FERNFERRET DON'T FORGET IT!"); sender.sendMessage("Please visit our wiki for more information: URLGOESHERE FERNFERRET DON'T FORGET IT!");
@ -65,5 +67,5 @@ public class ModifyRemoveCommand extends BaseCommand {
sender.sendMessage(value + " could not be removed from " + property); sender.sendMessage(value + " could not be removed from " + property);
} }
} }
} }

View File

@ -9,50 +9,50 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class ModifySetCommand extends BaseCommand { public class ModifySetCommand extends BaseCommand {
public ModifySetCommand(MultiverseCore plugin) { public ModifySetCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Modify a World (Set a value)"; this.name = "Modify a World (Set a value)";
this.description = "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used"; this.description = "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used";
this.usage = "/mvmodify" + ChatColor.GREEN + " SET {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD] "; this.usage = "/mvmodify" + ChatColor.GREEN + " SET {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]";
this.minArgs = 3; this.minArgs = 2;
this.maxArgs = 4; this.maxArgs = 3;
this.identifiers.add("mvmodify set"); this.identifiers.add("mvmodify set");
this.permission = "multiverse.world.modify"; this.permission = "multiverse.world.modify";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
// We NEED a world from the command line // We NEED a world from the command line
Player p = null; Player p = null;
if (!(sender instanceof Player)) { if (sender instanceof Player) {
p = (Player) sender; p = (Player) sender;
} }
if (args.length == 3 && p == null) { if (args.length == 2 && p == null) {
sender.sendMessage("From the command line, WORLD is required."); sender.sendMessage("From the command line, WORLD is required.");
sender.sendMessage(this.description); sender.sendMessage(this.description);
sender.sendMessage(this.usage); sender.sendMessage(this.usage);
sender.sendMessage("Nothing changed."); sender.sendMessage("Nothing changed.");
return; return;
} }
MVWorld world; MVWorld world;
String value = args[1]; String value = args[1];
String property = args[2]; String property = args[0];
if (args.length == 3) { if (args.length == 2) {
world = this.plugin.getMVWorld(p.getWorld().getName()); world = this.plugin.getMVWorld(p.getWorld().getName());
} else { } else {
world = this.plugin.getMVWorld(args[3]); world = this.plugin.getMVWorld(args[2]);
} }
if (world == null) { if (world == null) {
sender.sendMessage("That world does not exist!"); sender.sendMessage("That world does not exist!");
return; return;
} }
if (!ModifyCommand.validateAction(Action.Set, property)) { if (!ModifyCommand.validateAction(Action.Set, property)) {
sender.sendMessage("Sorry, you can't SET " + property); sender.sendMessage("Sorry, you can't SET " + property);
sender.sendMessage("Please visit our wiki for more information: URLGOESHERE FERNFERRET DON'T FORGET IT!"); sender.sendMessage("Please visit our wiki for more information: URLGOESHERE FERNFERRET DON'T FORGET IT!");
@ -64,5 +64,5 @@ public class ModifySetCommand extends BaseCommand {
sender.sendMessage("There was an error setting " + property); sender.sendMessage("There was an error setting " + property);
} }
} }
} }

View File

@ -29,7 +29,7 @@ public class PurgeCommand extends BaseCommand {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
Player p = null; Player p = null;
if(sender instanceof Player) { if (sender instanceof Player) {
p = (Player) sender; p = (Player) sender;
} }
if (args.length == 1 && p == null) { if (args.length == 1 && p == null) {
@ -39,24 +39,24 @@ public class PurgeCommand extends BaseCommand {
} }
String worldName = null; String worldName = null;
String deathName = null; String deathName = null;
if(args.length == 1) { if (args.length == 1) {
worldName = p.getWorld().getName(); worldName = p.getWorld().getName();
deathName = args[0]; deathName = args[0];
} else { } else {
worldName = args[0]; worldName = args[0];
deathName = args[1]; deathName = args[1];
} }
if(!this.plugin.isMVWorld(worldName)) { if (!this.plugin.isMVWorld(worldName)) {
sender.sendMessage("Multiverse doesn't know about " + worldName); sender.sendMessage("Multiverse doesn't know about " + worldName);
sender.sendMessage("... so It cannot be purged"); sender.sendMessage("... so It cannot be purged");
return; return;
} }
MVWorld world = this.plugin.getMVWorld(worldName); MVWorld world = this.plugin.getMVWorld(worldName);
PurgeWorlds purger = this.plugin.getWorldPurger(); PurgeWorlds purger = this.plugin.getWorldPurger();
ArrayList<String> thingsToKill = new ArrayList<String>(); ArrayList<String> thingsToKill = new ArrayList<String>();
if(deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) { if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase()); thingsToKill.add(deathName.toUpperCase());
} else { } else {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(",")); Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));

View File

@ -7,7 +7,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class RemoveCommand extends BaseCommand { public class RemoveCommand extends BaseCommand {
public RemoveCommand(MultiverseCore plugin) { public RemoveCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Remove World"; this.name = "Remove World";
@ -19,7 +19,7 @@ public class RemoveCommand extends BaseCommand {
this.permission = "multiverse.world.remove"; this.permission = "multiverse.world.remove";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if (this.plugin.removeWorld(args[0])) { if (this.plugin.removeWorld(args[0])) {

View File

@ -9,7 +9,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class SetSpawnCommand extends BaseCommand { public class SetSpawnCommand extends BaseCommand {
public SetSpawnCommand(MultiverseCore plugin) { public SetSpawnCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Set World Spawn"; this.name = "Set World Spawn";
@ -21,7 +21,7 @@ public class SetSpawnCommand extends BaseCommand {
this.permission = "multiverse.world.spawn.set"; this.permission = "multiverse.world.spawn.set";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if (sender instanceof Player) { if (sender instanceof Player) {
@ -35,5 +35,4 @@ public class SetSpawnCommand extends BaseCommand {
} }
return; return;
} }
} }

View File

@ -8,7 +8,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class SpawnCommand extends BaseCommand { public class SpawnCommand extends BaseCommand {
public SpawnCommand(MultiverseCore plugin) { public SpawnCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Spawn"; this.name = "Spawn";
@ -20,7 +20,7 @@ public class SpawnCommand extends BaseCommand {
this.permission = "multiverse.world.spawn.self"; this.permission = "multiverse.world.spawn.self";
this.requiresOp = false; this.requiresOp = false;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
Player commandSender = null; Player commandSender = null;
@ -29,7 +29,7 @@ public class SpawnCommand extends BaseCommand {
} }
// If a persons name was passed in, you must be A. the console, or B have permissions // If a persons name was passed in, you must be A. the console, or B have permissions
if (args.length == 1) { if (args.length == 1) {
if(commandSender != null && !this.plugin.ph.hasPermission(commandSender, "multiverse.world.spawn.other", true)) { if (commandSender != null && !this.plugin.ph.hasPermission(commandSender, "multiverse.world.spawn.other", true)) {
sender.sendMessage("You don't have permission to teleport another player to spawn."); sender.sendMessage("You don't have permission to teleport another player to spawn.");
return; return;
} }

View File

@ -13,7 +13,7 @@ import com.onarandombox.utils.DestinationType;
public class TeleportCommand extends BaseCommand { public class TeleportCommand extends BaseCommand {
private MVTeleport playerTeleporter; private MVTeleport playerTeleporter;
public TeleportCommand(MultiverseCore plugin) { public TeleportCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Teleport"; this.name = "Teleport";
@ -26,7 +26,7 @@ public class TeleportCommand extends BaseCommand {
this.permission = "multiverse.world.tp.self"; this.permission = "multiverse.world.tp.self";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
// Check if the command was sent from a Player. // Check if the command was sent from a Player.
@ -35,9 +35,9 @@ public class TeleportCommand extends BaseCommand {
if (sender instanceof Player) { if (sender instanceof Player) {
teleporter = (Player) sender; teleporter = (Player) sender;
} }
String worldName; String worldName;
if (args.length == 2) { if (args.length == 2) {
if (teleporter != null && !this.plugin.ph.hasPermission(sender, "multiverse.world.tp.other", true)) { if (teleporter != null && !this.plugin.ph.hasPermission(sender, "multiverse.world.tp.other", true)) {
sender.sendMessage("You don't have permission to teleport another player."); sender.sendMessage("You don't have permission to teleport another player.");
@ -49,10 +49,10 @@ public class TeleportCommand extends BaseCommand {
return; return;
} }
worldName = args[1]; worldName = args[1];
} else { } else {
worldName = args[0]; worldName = args[0];
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage("You can only teleport other players from the command line."); sender.sendMessage("You can only teleport other players from the command line.");
return; return;
@ -60,13 +60,13 @@ public class TeleportCommand extends BaseCommand {
teleporter = (Player) sender; teleporter = (Player) sender;
teleportee = (Player) sender; teleportee = (Player) sender;
} }
Destination d = Destination.parseDestination(worldName, this.plugin); Destination d = Destination.parseDestination(worldName, this.plugin);
if (!(d.getType() == DestinationType.World)) { if (!(d.getType() == DestinationType.World)) {
sender.sendMessage("Multiverse does not know about this world: " + worldName); sender.sendMessage("Multiverse does not know about this world: " + worldName);
return; return;
} }
if (teleporter != null && !this.plugin.ph.canEnterWorld(teleporter, this.plugin.getServer().getWorld(d.getName()))) { if (teleporter != null && !this.plugin.ph.canEnterWorld(teleporter, this.plugin.getServer().getWorld(d.getName()))) {
if (teleportee.equals(teleporter)) { if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there..."); teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
@ -85,5 +85,4 @@ public class TeleportCommand extends BaseCommand {
Location l = this.playerTeleporter.getSafeDestination(this.plugin.getServer().getWorld(d.getName()).getSpawnLocation()); Location l = this.playerTeleporter.getSafeDestination(this.plugin.getServer().getWorld(d.getName()).getSpawnLocation());
teleportee.teleport(l); teleportee.teleport(l);
} }
} }

View File

@ -7,7 +7,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class UnloadCommand extends BaseCommand { public class UnloadCommand extends BaseCommand {
public UnloadCommand(MultiverseCore plugin) { public UnloadCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Unload World"; this.name = "Unload World";
@ -19,7 +19,7 @@ public class UnloadCommand extends BaseCommand {
this.permission = "multiverse.world.unload"; this.permission = "multiverse.world.unload";
this.requiresOp = true; this.requiresOp = true;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if (this.plugin.unloadWorld(args[0])) { if (this.plugin.unloadWorld(args[0])) {
@ -28,5 +28,4 @@ public class UnloadCommand extends BaseCommand {
sender.sendMessage("Error trying to unload world!"); sender.sendMessage("Error trying to unload world!");
} }
} }
} }

View File

@ -14,7 +14,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
public class WhoCommand extends BaseCommand { public class WhoCommand extends BaseCommand {
public WhoCommand(MultiverseCore plugin) { public WhoCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Who"; this.name = "Who";
@ -26,7 +26,7 @@ public class WhoCommand extends BaseCommand {
this.permission = "multiverse.world.list.who"; this.permission = "multiverse.world.list.who";
this.requiresOp = false; this.requiresOp = false;
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
// If this command was sent from a Player then we need to check Permissions // If this command was sent from a Player then we need to check Permissions
@ -34,9 +34,9 @@ public class WhoCommand extends BaseCommand {
if (sender instanceof Player) { if (sender instanceof Player) {
p = (Player) sender; p = (Player) sender;
} }
List<MVWorld> worlds = new ArrayList<MVWorld>(); List<MVWorld> worlds = new ArrayList<MVWorld>();
if (args.length > 0) { if (args.length > 0) {
if (this.plugin.isMVWorld(args[0])) { if (this.plugin.isMVWorld(args[0])) {
worlds.add(this.plugin.getMVWorld(args[0])); worlds.add(this.plugin.getMVWorld(args[0]));
@ -47,17 +47,17 @@ public class WhoCommand extends BaseCommand {
} else { } else {
worlds = new ArrayList<MVWorld>(this.plugin.getMVWorlds()); worlds = new ArrayList<MVWorld>(this.plugin.getMVWorlds());
} }
for (MVWorld world : worlds) { for (MVWorld world : worlds) {
if (!(this.plugin.isMVWorld(world.getName()))) { if (!(this.plugin.isMVWorld(world.getName()))) {
continue; continue;
} }
World w = this.plugin.getServer().getWorld(world.getName()); World w = this.plugin.getServer().getWorld(world.getName());
if (p != null && (!this.plugin.ph.canEnterWorld(p, w))) { if (p != null && (!this.plugin.ph.canEnterWorld(p, w))) {
continue; continue;
} }
ChatColor color = ChatColor.GOLD; ChatColor color = ChatColor.GOLD;
Environment env = world.getEnvironment(); Environment env = world.getEnvironment();
if (env == Environment.NETHER) { if (env == Environment.NETHER) {
@ -68,7 +68,7 @@ public class WhoCommand extends BaseCommand {
color = ChatColor.AQUA; color = ChatColor.AQUA;
} }
List<Player> players = w.getPlayers(); List<Player> players = w.getPlayers();
String result = ""; String result = "";
if (players.size() <= 0) { if (players.size() <= 0) {
result = "Empty"; result = "Empty";
@ -78,14 +78,13 @@ public class WhoCommand extends BaseCommand {
} }
} }
String worldName = world.getName(); String worldName = world.getName();
if(world.getAlias() != null && world.getAlias().length() > 0) { if (world.getAlias() != null && world.getAlias().length() > 0) {
worldName = world.getAlias(); worldName = world.getAlias();
color = world.getAliasColor(); color = world.getAliasColor();
} }
sender.sendMessage(color + worldName + ChatColor.WHITE + " - " + result); sender.sendMessage(color + worldName + ChatColor.WHITE + " - " + result);
} }
return; return;
} }
} }