diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-07 18:47:17 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-07 18:47:17 +0900 |
commit | 88f51c1dc3fa986ebd5beaf0a6a90ddfbae397ea (patch) | |
tree | 9ae4cbe97054391de0c78a7ab80c865a35cd742f | |
parent | 52d0c94e43c9602b5e9ca77f8cf000d14b45e319 (diff) | |
download | Skyblock-Dungeons-Guide-88f51c1dc3fa986ebd5beaf0a6a90ddfbae397ea.tar.gz Skyblock-Dungeons-Guide-88f51c1dc3fa986ebd5beaf0a6a90ddfbae397ea.tar.bz2 Skyblock-Dungeons-Guide-88f51c1dc3fa986ebd5beaf0a6a90ddfbae397ea.zip |
- volatile stuff
Signed-off-by: syeyoung <cyoung06@naver.com>
-rw-r--r-- | mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java index 14bb73b4..b996c86f 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/advanced/FeatureDetectFreeze.java @@ -20,8 +20,10 @@ 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.events.impl.DGTickEvent; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.mod.features.SimpleFeature; +import net.minecraftforge.fml.common.gameevent.TickEvent; import javax.swing.*; import java.awt.*; @@ -40,17 +42,24 @@ public class FeatureDetectFreeze extends SimpleFeature { } @DGEventHandler(ignoreDisabled = true, triggerOutOfSkyblock = true) - public void onTick() { + public void onTick(TickEvent.ClientTickEvent tickEvent) { lastTick = System.currentTimeMillis() + 3000; } + private volatile boolean isEnabled = false; + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + this.isEnabled = enabled; + } private long lastTick = Long.MAX_VALUE; private Thread t = new Thread(DungeonsGuide.THREAD_GROUP,this::run); public void run() { while(!t.isInterrupted()) { - if (lastTick < System.currentTimeMillis() && FeatureRegistry.FREEZE_DETECTOR.isEnabled()) { + if (lastTick < System.currentTimeMillis() && isEnabled) { ThreadMXBean bean = ManagementFactory.getThreadMXBean(); ThreadInfo[] infos = bean.dumpAllThreads(true, true); String stacktrace = Arrays.stream(infos).map(Object::toString) |