aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyeyoung <cyougn06@naver.com>2022-01-26 20:30:18 +0900
committersyeyoung <cyougn06@naver.com>2022-01-26 20:30:18 +0900
commit7ed943c6f0443d01a93c506af124bbca95107252 (patch)
tree81b4f8b1c509177b2c45be6aed99e2eb0e279d69
parent611ce01285265e2b2433b6676c678c6426e047bd (diff)
downloadSkyblock-Dungeons-Guide-7ed943c6f0443d01a93c506af124bbca95107252.tar.gz
Skyblock-Dungeons-Guide-7ed943c6f0443d01a93c506af124bbca95107252.tar.bz2
Skyblock-Dungeons-Guide-7ed943c6f0443d01a93c506af124bbca95107252.zip
- Move session check to separate thread
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java52
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java32
2 files changed, 52 insertions, 32 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
index f120f94f..ac860e78 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
@@ -19,6 +19,7 @@
package kr.syeyoung.dungeonsguide;
import com.google.common.collect.Sets;
+import com.google.gson.JsonObject;
import kr.syeyoung.dungeonsguide.chat.ChatProcessor;
import kr.syeyoung.dungeonsguide.chat.PartyManager;
import kr.syeyoung.dungeonsguide.commands.*;
@@ -40,11 +41,15 @@ import kr.syeyoung.dungeonsguide.utils.TimeScoreUtil;
import kr.syeyoung.dungeonsguide.wsresource.StaticResourceCache;
import lombok.Getter;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiErrorScreen;
+import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.launchwrapper.LaunchClassLoader;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@@ -165,6 +170,7 @@ public class DungeonsGuide implements DGInterface, CloseListener {
@Getter
private boolean firstTimeUsingDG = false;
public void pre(FMLPreInitializationEvent event) {
+ t.start();
configDir = new File(event.getModConfigurationDirectory(),"dungeonsguide");
File configFile = new File(configDir, "config.json");
if (!configFile.exists()) {
@@ -211,4 +217,50 @@ public class DungeonsGuide implements DGInterface, CloseListener {
}
}, 5L, TimeUnit.SECONDS);
}
+
+ private Thread t = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ JsonObject obj = DungeonsGuide.getDungeonsGuide().getAuthenticator().getJwtPayload(DungeonsGuide.getDungeonsGuide().getAuthenticator().getToken());
+ if (!obj.get("uuid").getAsString().equals(Minecraft.getMinecraft().getSession().getPlayerID())) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiErrorScreen) return;
+
+ final String[] a = new String[]{
+ "User has changed current Minecraft session.",
+ "Please restart mc to revalidate Dungeons Guide",
+ "Hopefully this screen will be fixed in later release"
+ };
+ final GuiScreen b = new GuiErrorScreen(null, null) {
+ @Override
+ public void drawScreen(int par1, int par2, float par3) {
+ super.drawScreen(par1, par2, par3);
+ for (int i = 0; i < a.length; ++i) {
+ drawCenteredString(fontRendererObj, a[i], width / 2, height / 3 + 12 * i, 0xFFFFFFFF);
+ }
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+ this.buttonList.clear();
+ this.buttonList.add(new GuiButton(0, width / 2 - 50, height - 50, 100, 20, "close"));
+ }
+
+ @Override
+ protected void actionPerformed(GuiButton button) throws IOException {
+ FMLCommonHandler.instance().exitJava(-1, true);
+ }
+ };
+ Minecraft.getMinecraft().displayGuiScreen(b);
+ return;
+ }
+ try {
+ Thread.sleep(100L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
index bc6380b2..2edf4d83 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
@@ -142,39 +142,7 @@ public class DungeonListener {
if (ev.phase == TickEvent.Phase.START) {
- JsonObject obj = DungeonsGuide.getDungeonsGuide().getAuthenticator().getJwtPayload(DungeonsGuide.getDungeonsGuide().getAuthenticator().getToken());
- if (!obj.get("uuid").getAsString().equals(Minecraft.getMinecraft().getSession().getProfile().getId().toString())) {
- if (Minecraft.getMinecraft().currentScreen instanceof GuiErrorScreen) return;
-
- final String[] a = new String[]{
- "User has changed current Minecraft session.",
- "Please restart mc to revalidate Dungeons Guide",
- "Hopefully this screen will be fixed in later release"
- };
- final GuiScreen b = new GuiErrorScreen(null, null) {
- @Override
- public void drawScreen(int par1, int par2, float par3) {
- super.drawScreen(par1, par2, par3);
- for (int i = 0; i < a.length; ++i) {
- drawCenteredString(fontRendererObj, a[i], width / 2, height / 3 + 12 * i, 0xFFFFFFFF);
- }
- }
-
- @Override
- public void initGui() {
- super.initGui();
- this.buttonList.clear();
- this.buttonList.add(new GuiButton(0, width / 2 - 50, height - 50, 100,20, "close"));
- }
- @Override
- protected void actionPerformed(GuiButton button) throws IOException {
- FMLCommonHandler.instance().exitJava(-1,true);
- }
- };
- Minecraft.getMinecraft().displayGuiScreen(b);
- return;
- }