@Override
  public void runCommand(CommandSender sender, List<String> args) {
    String worldName = args.get(0);
    File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
    String env = args.get(1);
    String seed = CommandHandler.getFlag("-s", args);
    String generator = CommandHandler.getFlag("-g", args);
    boolean useSpawnAdjust = true;
    for (String s : args) {
      if (s.equalsIgnoreCase("-n")) {
        useSpawnAdjust = false;
      }
    }
    if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
      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");
      return;
    }

    Environment environment = this.plugin.getEnvFromString(env);
    if (environment == null) {
      sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
      EnvironmentCommand.showEnvironments(sender);
      return;
    }

    Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");

    if (this.worldManager.addWorld(worldName, environment, seed, generator, useSpawnAdjust)) {
      Command.broadcastCommandMessage(sender, "Complete!");
    } else {
      Command.broadcastCommandMessage(sender, "FAILED.");
    }
  }
Beispiel #2
0
 private void registerCommands() {
   PermissionsHandler permissionsHandler = new PermissionsHandler();
   commandHandler = new CommandHandler(this, permissionsHandler);
   commandHandler.registerCommand(new DebugCommand(this));
   commandHandler.registerCommand(new LeaderCommand(this));
   commandHandler.registerCommand(new ReloadCommand(this));
   commandHandler.registerCommand(new StatsCommand(this));
   if (contract) {
     // commandHandler.registerCommand(new ContractCommand(this));
   }
 }
Beispiel #3
0
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   if (label.equalsIgnoreCase("contract")) {
     sender.sendMessage(ChatColor.RED + "Not yet implemented.");
     return false;
   }
   List<String> arguments = new ArrayList<String>(Arrays.asList(args));
   arguments.add(0, label);
   return commandHandler.locateAndRunCommand(sender, arguments);
 }