diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-07 18:42:37 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-07 18:42:37 +0900 |
commit | 52d0c94e43c9602b5e9ca77f8cf000d14b45e319 (patch) | |
tree | dc6d653f7c8561b528aea4ebfd2294a413281c26 /mod/src/main/java | |
parent | 980d5179fead0be5fdda90564bd1f13dee557ebe (diff) | |
download | Skyblock-Dungeons-Guide-52d0c94e43c9602b5e9ca77f8cf000d14b45e319.tar.gz Skyblock-Dungeons-Guide-52d0c94e43c9602b5e9ca77f8cf000d14b45e319.tar.bz2 Skyblock-Dungeons-Guide-52d0c94e43c9602b5e9ca77f8cf000d14b45e319.zip |
- Make Freeze detector a feature
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java')
-rwxr-xr-x | mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java | 3 | ||||
-rw-r--r-- | mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java | 2 | ||||
-rw-r--r-- | mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java (renamed from mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FreezeListener.java) | 24 |
3 files changed, 12 insertions, 17 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java index b6e92feb..3df65e42 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java @@ -34,7 +34,6 @@ import kr.syeyoung.dungeonsguide.mod.discord.DiscordIntegrationManager; import kr.syeyoung.dungeonsguide.mod.dungeon.DungeonFacade; import kr.syeyoung.dungeonsguide.mod.events.annotations.EventHandlerRegistry; import kr.syeyoung.dungeonsguide.mod.events.listener.DungeonListener; -import kr.syeyoung.dungeonsguide.mod.events.listener.FreezeListener; import kr.syeyoung.dungeonsguide.mod.events.listener.PacketInjector; import kr.syeyoung.dungeonsguide.mod.events.listener.PacketListener; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; @@ -86,7 +85,6 @@ import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class DungeonsGuide implements DGInterface { @@ -172,7 +170,6 @@ public class DungeonsGuide implements DGInterface { public void init(File f) { ProgressManager.ProgressBar progressbar = ProgressManager.push("DungeonsGuide", 4); - registerEventsForge(new FreezeListener()); progressbar.step("Creating Configuration"); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java index b30d0a67..1c0bc38e 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/FeatureRegistry.java @@ -99,7 +99,7 @@ public class FeatureRegistry { public static final FeatureHideNameTags DUNGEON_HIDENAMETAGS = register(new FeatureHideNameTags()); public static final FeaturePlayerESP DUNGEON_PLAYERESP = register(new FeaturePlayerESP()); public static final SimpleFeature DUNGEON_INTERMODCOMM = register(new SimpleFeature("Dungeon.Teammates", "Communicate With Other's Dungeons Guide", "Sends total secret in the room to others\nSo that they can use the data to calculate total secret in dungeon run\n\nThis automates player chatting action, (chatting data) Thus it might be against hypixel's rules.\nBut mods like auto-gg which also automate player action and is kinda allowed mod exist so I'm leaving this feature.\nThis option is use-at-your-risk and you'll be responsible for ban if you somehow get banned because of this feature\n(Although it is not likely to happen)\nDefaults to off", "dungeon.intermodcomm", false)); - public static final SimpleFeature FREEZE_DETECTOR = register(new SimpleFeature("Misc", "Freeze Detector", "Detect freezes, and when mc freezes for more than 5s, copy threadump and show you a popup", "misc.freezedetect", false)); + public static final FeatureDetectFreeze FREEZE_DETECTOR = register(new FeatureDetectFreeze()); public static final FeatureWarnLowHealth DUNGEON_LOWHEALTH_WARN = register(new FeatureWarnLowHealth()); public static final FeatureDungeonScore DUNGEON_SCORE = register(new FeatureDungeonScore()); public static final FeatureDungeonTombs DUNGEON_TOMBS = register(new FeatureDungeonTombs()); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FreezeListener.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java index 235b678b..14bb73b4 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FreezeListener.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java @@ -16,12 +16,12 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package kr.syeyoung.dungeonsguide.mod.events.listener; +package kr.syeyoung.dungeonsguide.mod.features.impl.advanced; import kr.syeyoung.dungeonsguide.mod.DungeonsGuide; +import kr.syeyoung.dungeonsguide.mod.events.annotations.DGEventHandler; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; +import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; import javax.swing.*; import java.awt.*; @@ -31,25 +31,23 @@ import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; import java.util.Arrays; -import java.util.Map; import java.util.stream.Collectors; -public class FreezeListener implements Runnable { - public FreezeListener() { +public class FeatureDetectFreeze extends SimpleFeature { + public FeatureDetectFreeze() { + super("Misc", "Freeze Detector", "Detect freezes, and when mc freezes for more than 3s, copy threadump and show you a popup", "misc.freezedetect", false); t.start(); } - private volatile long lastTick = Long.MAX_VALUE; - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent tickEvent) { - lastTick = System.currentTimeMillis() + 5000; + @DGEventHandler(ignoreDisabled = true, triggerOutOfSkyblock = true) + public void onTick() { + lastTick = System.currentTimeMillis() + 3000; } - Thread t = new Thread(DungeonsGuide.THREAD_GROUP,this); + private long lastTick = Long.MAX_VALUE; + private Thread t = new Thread(DungeonsGuide.THREAD_GROUP,this::run); - @Override public void run() { while(!t.isInterrupted()) { if (lastTick < System.currentTimeMillis() && FeatureRegistry.FREEZE_DETECTOR.isEnabled()) { |