@Override
 public void runCommand(ApplicationState state, String[] args) {
   Application.getLog().log("Saving log...");
   Application.getLog().save();
   Application.getLog().log("Saved log");
   Application.getLog().log("Stopping");
   System.exit(0);
 }
Exemple #2
0
  @Override
  public void runCommand(ApplicationState state, String[] args) {
    String printedOutput = "Commands: ";

    for (String entries : Application.getCommandHandler().getCommandsAlphabetized()) {
      printedOutput += entries + ", ";
    }

    Application.getLog().log(printedOutput.substring(0, printedOutput.length() - 2));
  }
 @Override
 public void runCommand(ApplicationState state, String[] args) {
   if (state.getAuthentication().isLoggedIn()) {
     try {
       if (state.getAuthentication().isPremium()) {
         state.getAuthentication().getAuthDataOutputStream().writeByte(2);
         state.getAuthentication().getAuthDataOutputStream().writeInt(Integer.parseInt(args[1]));
         Application.getLog().log("Your port was set to: " + Integer.parseInt(args[1]));
       } else {
         Application.getLog().log("You are not an alpha tester, so you can't set static ports.");
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else {
     Application.getLog().log("You are not logged in.");
   }
 }
  public void handleCommand(String command) {
    // If no command was actually entered, return.
    if (command.isEmpty()) return;

    // Split command string into words. args[0] is the commands name, all other are args.
    String[] words = command.split("\\s+");
    String commandName = words[0].toLowerCase();

    //        String[] args = Arrays.copyOfRange(words, 1, words.length);

    if (commandMap.containsKey(commandName)) {
      getCommand(commandName).runCommand(state, words);
    } else {
      Application.getLog().log("Unknown command '" + command + "'");
    }
  }