refactor: second ticker in TickPlugin

This commit is contained in:
ChomeNS
2025-03-25 20:05:50 +07:00
parent a2b564abf5
commit 05854223b1
9 changed files with 82 additions and 46 deletions

View File

@@ -14,9 +14,8 @@ import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class CommandHandlerPlugin {
public class CommandHandlerPlugin implements TickPlugin.Listener {
public static final List<Command> commands = new ArrayList<>();
static {
@@ -61,6 +60,10 @@ public class CommandHandlerPlugin {
registerCommand(new RestartCommand());
}
public static void registerCommand (Command command) {
commands.add(command);
}
public boolean disabled = false;
private final Bot bot;
@@ -70,11 +73,12 @@ public class CommandHandlerPlugin {
public CommandHandlerPlugin (Bot bot) {
this.bot = bot;
bot.executor.scheduleAtFixedRate(() -> commandPerSecond = 0, 0, 1, TimeUnit.SECONDS);
bot.tick.addListener(this);
}
public static void registerCommand (Command command) {
commands.add(command);
@Override
public void onSecondTick () {
commandPerSecond = 0;
}
// BETTER QUALITY than the js version