2019-06-02 05:03:08 +03:00
|
|
|
package pro.gravit.launchserver.components;
|
2019-03-28 13:26:47 +03:00
|
|
|
|
2019-06-02 05:03:08 +03:00
|
|
|
import pro.gravit.launchserver.LaunchServer;
|
|
|
|
import pro.gravit.utils.command.Command;
|
2019-03-28 13:26:47 +03:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
public class CommandRemoverComponent extends Component implements AutoCloseable {
|
|
|
|
public String[] removeList = new String[]{};
|
|
|
|
public transient Map<String, Command> commandsList = new HashMap<>();
|
2019-04-03 16:27:40 +03:00
|
|
|
|
2019-03-28 13:26:47 +03:00
|
|
|
@Override
|
|
|
|
public void preInit(LaunchServer launchServer) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init(LaunchServer launchServer) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void postInit(LaunchServer launchServer) {
|
2019-04-03 16:27:40 +03:00
|
|
|
for (String cmd : removeList) {
|
2019-03-28 13:26:47 +03:00
|
|
|
Command removedCmd = launchServer.commandHandler.unregisterCommand(cmd);
|
2019-04-03 16:27:40 +03:00
|
|
|
if (removedCmd != null)
|
|
|
|
commandsList.put(cmd, removedCmd);
|
2019-03-28 13:26:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-04-20 01:14:02 +03:00
|
|
|
public void close() {
|
2019-04-03 16:27:40 +03:00
|
|
|
for (Map.Entry<String, Command> e : commandsList.entrySet()) {
|
2019-03-28 13:26:47 +03:00
|
|
|
LaunchServer.server.commandHandler.registerCommand(e.getKey(), e.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|