From ed4c171f115caf39b376caf9fc91856eb16a003f Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:42:42 +0700 Subject: [PATCH] fix: make checkAllPlayers run in the ExecutorService to reduce the login lag by at least a bit --- build-number.txt | 2 +- .../me/chayapak1/chomens_bot/plugins/IPFilterPlugin.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build-number.txt b/build-number.txt index a2998a8..2d0ce9f 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -1120 \ No newline at end of file +1131 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/IPFilterPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/IPFilterPlugin.java index 8ae22c4..e5fb587 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/IPFilterPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/IPFilterPlugin.java @@ -25,7 +25,7 @@ public class IPFilterPlugin extends PlayersPlugin.Listener { bot.players.addListener(this); - bot.executor.scheduleAtFixedRate(this::checkAllPlayers, 0, 2, TimeUnit.SECONDS); + bot.executor.scheduleAtFixedRate(this::checkAllPlayers, 0, 10, TimeUnit.SECONDS); } @Override @@ -60,7 +60,9 @@ public class IPFilterPlugin extends PlayersPlugin.Listener { private void checkAllPlayers () { if (filteredIPs.isEmpty()) return; - for (PlayerEntry entry : bot.players.list) check(entry); + bot.executorService.submit(() -> { + for (PlayerEntry entry : bot.players.list) check(entry); + }); } public String remove (int index) {