aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/java/kr
diff options
context:
space:
mode:
Diffstat (limited to 'mod/src/main/java/kr')
-rwxr-xr-xmod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java3
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java2
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FreezeListener.java77
3 files changed, 82 insertions, 0 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 303caea8..b6e92feb 100755
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java
@@ -34,6 +34,7 @@ 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;
@@ -171,6 +172,8 @@ public class DungeonsGuide implements DGInterface {
public void init(File f) {
ProgressManager.ProgressBar progressbar = ProgressManager.push("DungeonsGuide", 4);
+ registerEventsForge(new FreezeListener());
+
progressbar.step("Creating Configuration");
File configFile = new File(Main.getConfigDir(), "config.json");
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java
index 239ee14e..2b15c5ff 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/commands/CommandDgDebug.java
@@ -124,6 +124,8 @@ public class CommandDgDebug extends CommandBase {
}
switch (args[0].toLowerCase()) { //Case Insensitive
+ case "freeze":
+ while(true);
case "scoreboard":
scoreboardCommand();
break;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FreezeListener.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FreezeListener.java
new file mode 100644
index 00000000..4bafd78b
--- /dev/null
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/FreezeListener.java
@@ -0,0 +1,77 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.mod.events.listener;
+
+import kr.syeyoung.dungeonsguide.mod.DungeonsGuide;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+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() {
+ t.start();
+ }
+ private volatile long lastTick = Long.MAX_VALUE;
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent tickEvent) {
+ lastTick = System.currentTimeMillis() + 5000;
+
+ }
+
+
+ Thread t = new Thread(DungeonsGuide.THREAD_GROUP,this);
+
+ @Override
+ public void run() {
+ while(!t.isInterrupted()) {
+ if (lastTick < System.currentTimeMillis()) {
+
+ ThreadMXBean bean = ManagementFactory.getThreadMXBean();
+ ThreadInfo[] infos = bean.dumpAllThreads(true, true);
+ String stacktrace = Arrays.stream(infos).map(Object::toString)
+ .collect(Collectors.joining());
+ System.out.println(stacktrace);
+
+ StringSelection selection = new StringSelection(stacktrace);
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(selection, selection);
+
+ JOptionPane.showMessageDialog(null, "Your Minecraft Seems to be frozen!\nThreadump has been copied into your clipboard!", "DG Freeze Alert", JOptionPane.INFORMATION_MESSAGE);
+
+
+ }
+ try {
+ Thread.sleep(16);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ }
+}