Added StopCommand
This commit is contained in:
@@ -10,14 +10,16 @@ import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.ProtocolValues;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.webserver.commands.StopCommand;
|
||||
|
||||
import javax.annotation.processing.Generated;
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
private static final CommandPermission PERMISSION_ALL = new CommandPermission("all", 1);
|
||||
private static final CommandExecutor commandExecutor = new CommandExecutor("DNS", PERMISSION_ALL) {};
|
||||
public static final CommandPermission PERMISSION_ALL = new CommandPermission("all", 1);
|
||||
private static final CommandExecutor commandExecutor = new CommandExecutor("WebServer", PERMISSION_ALL) {};
|
||||
|
||||
@Getter
|
||||
private static CommandManager commandManager;
|
||||
|
||||
@Getter
|
||||
@@ -68,11 +70,13 @@ public class Main {
|
||||
protocolBridge.getProtocolServer().getNetwork().start();
|
||||
|
||||
commandManager = new CommandManager(values.eventManager);
|
||||
commandManager.registerCommand(StopCommand.class);
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
while (true) {
|
||||
System.out.print(commandExecutor.getName() + "> ");
|
||||
String line = scanner.nextLine();
|
||||
System.out.println(commandExecutor.getName() + "> ");
|
||||
commandManager.execute(commandExecutor, line);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.openautonomousconnection.webserver.commands;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.command.Command;
|
||||
import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor;
|
||||
import org.openautonomousconnection.webserver.Main;
|
||||
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class StopCommand extends Command {
|
||||
|
||||
public StopCommand() throws InstanceAlreadyExistsException {
|
||||
super(Main.getCommandManager(), "stop", "Stop the Server", "stop", Collections.singletonList(Main.PERMISSION_ALL), new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandExecutor commandExecutor, String s, String[] strings) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user