fix: some debug shit about the ticker being completely frozen

This commit is contained in:
ChomeNS
2025-04-23 08:28:36 +07:00
parent 2b8185222a
commit 00e7bd59c0
3 changed files with 14 additions and 7 deletions

View File

@@ -11,16 +11,15 @@ import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.tuple.Pair;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class FilterManagerPlugin implements Listener {
private final Bot bot;
public final Map<PlayerEntry, String> list = Collections.synchronizedMap(new HashMap<>());
public final Map<PlayerEntry, String> list = new ConcurrentHashMap<>();
public FilterManagerPlugin (final Bot bot) {
this.bot = bot;

View File

@@ -3,10 +3,14 @@ package me.chayapak1.chomens_bot.plugins;
import me.chayapak1.chomens_bot.Bot;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
public class TickPlugin {
private final Bot bot;
public final AtomicLong lastTickTime = new AtomicLong();
public final AtomicLong lastSecondTickTime = new AtomicLong();
public TickPlugin (final Bot bot) {
this.bot = bot;
@@ -18,7 +22,7 @@ public class TickPlugin {
bot.listener.dispatch(listener -> {
try {
listener.onAlwaysTick();
} catch (final Exception e) {
} catch (final Throwable e) {
bot.logger.error("Caught exception in an always tick listener!");
bot.logger.error(e);
}
@@ -29,11 +33,13 @@ public class TickPlugin {
bot.listener.dispatch(listener -> {
try {
listener.onTick();
} catch (final Exception e) {
} catch (final Throwable e) {
bot.logger.error("Caught exception in a tick listener!");
bot.logger.error(e);
}
});
lastTickTime.set(System.currentTimeMillis());
}
private void tickSecond () {
@@ -42,10 +48,12 @@ public class TickPlugin {
bot.listener.dispatch(listener -> {
try {
listener.onSecondTick();
} catch (final Exception e) {
} catch (final Throwable e) {
bot.logger.error("Caught exception in a second tick listener!");
bot.logger.error(e);
}
});
lastSecondTickTime.set(System.currentTimeMillis());
}
}