mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-09-16 01:27:12 +02:00
Moved the flag extractor to the CommandManager
This commit is contained in:
parent
f7ded5f129
commit
406e31f5c5
@ -144,6 +144,28 @@ public class CommandManager {
|
||||
return returnVal.replace("\"", "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the given flag value
|
||||
*
|
||||
* @param flag A param flag, like -s or -g
|
||||
* @param args All arguments to search through
|
||||
* @return A string or null
|
||||
*/
|
||||
public static String getFlag(String flag, String[] args) {
|
||||
int i = 0;
|
||||
try {
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase(flag)) {
|
||||
return args[i + 1];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
import com.onarandombox.MultiverseCore.command.CommandManager;
|
||||
|
||||
public class CreateCommand extends BaseCommand {
|
||||
|
||||
@ -16,7 +17,7 @@ public class CreateCommand extends BaseCommand {
|
||||
super(plugin);
|
||||
this.name = "Create World";
|
||||
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} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]]";
|
||||
this.minArgs = 2;
|
||||
this.maxArgs = 6;
|
||||
this.identifiers.add("mvcreate");
|
||||
@ -33,9 +34,8 @@ public class CreateCommand extends BaseCommand {
|
||||
}
|
||||
String worldName = args[0];
|
||||
String env = args[1];
|
||||
String seed = this.getFlag("-s", args);
|
||||
String generator = this.getFlag("-g", args);
|
||||
|
||||
String seed = CommandManager.getFlag("-s", args);
|
||||
String generator = CommandManager.getFlag("-g", args);
|
||||
|
||||
if (new File(worldName).exists() || this.plugin.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||
@ -58,26 +58,4 @@ public class CreateCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the given flag value
|
||||
*
|
||||
* @param flag A param flag, like -s or -g
|
||||
* @param args All arguments to search through
|
||||
* @return A string or null
|
||||
*/
|
||||
private String getFlag(String flag, String[] args) {
|
||||
int i = 0;
|
||||
try {
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase(flag)) {
|
||||
this.plugin.debugLog(Level.CONFIG, args[i+1]);
|
||||
return args[i+1];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user