From 7c8441b75d85cfcd209e3381350a231b61294346 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Thu, 17 Nov 2022 14:18:51 +0900 Subject: - Fix wrong tooltip id - Tooltip on loading failure Signed-off-by: syeyoung --- .../kr/syeyoung/dungeonsguide/launcher/Main.java | 53 ++++++++++++++++++++++ .../dungeonsguide/launcher/auth/AuthManager.java | 4 +- 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'loader/src') diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java index 6401f0fd..782c3648 100755 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java @@ -45,6 +45,7 @@ import net.minecraftforge.fml.common.ProgressManager; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import javax.swing.*; import java.io.*; import java.util.*; @@ -75,12 +76,37 @@ public class Main } private IDGLoader currentLoader; + + private UUID dgUnloaded = UUID.randomUUID(); + @EventHandler public void initEvent(FMLInitializationEvent initializationEvent) throws ClassNotFoundException, InstantiationException, IllegalAccessException { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(GuiDisplayer.INSTANCE); MinecraftForge.EVENT_BUS.register(NotificationManager.INSTANCE); + NotificationManager.INSTANCE.updateNotification(dgUnloaded, Notification.builder() + .title("Dungeons Guide Not Loaded") + .description("Click to try reloading....") + .onClick(() -> { + try { + File f = new File(configDir, "loader.cfg"); + Configuration configuration = new Configuration(f); + IDGLoader idgLoader = obtainLoader(configuration); + load(idgLoader); + } catch (NoSuitableLoaderFoundException e) { + e.printStackTrace(); + GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); + } catch (NoVersionFoundException e) { + e.printStackTrace(); + GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); + } catch (DungeonsGuideLoadingException e) { + e.printStackTrace(); + GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); + } + }) + .unremovable(true) + .build()); try { File f = new File(configDir, "loader.cfg"); @@ -111,6 +137,30 @@ public class Main currentLoader.unloadDungeonsGuide(); } currentLoader = null; + + + NotificationManager.INSTANCE.updateNotification(dgUnloaded, Notification.builder() + .title("Dungeons Guide Not Loaded") + .description("Click to try reloading....") + .onClick(() -> { + try { + File f = new File(configDir, "loader.cfg"); + Configuration configuration = new Configuration(f); + IDGLoader idgLoader = obtainLoader(configuration); + load(idgLoader); + } catch (NoSuitableLoaderFoundException e) { + e.printStackTrace(); + GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); + } catch (NoVersionFoundException e) { + e.printStackTrace(); + GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); + } catch (DungeonsGuideLoadingException e) { + e.printStackTrace(); + GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); + } + }) + .unremovable(true) + .build()); } private void load(IDGLoader newLoader) throws DungeonsGuideLoadingException { if (dgInterface != null) throw new IllegalStateException("DG is loaded"); @@ -129,6 +179,9 @@ public class Main .description("Successfully Loaded DugneonsGuide!\nLoader: "+currentLoader.loaderName()+"\nVersion: "+currentLoader.version()) .titleColor(0xFF00FF00) .build()); + + + NotificationManager.INSTANCE.removeNotification(dgUnloaded); } public void reload(IDGLoader newLoader) { try { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java index b75c5100..4db06318 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java @@ -115,7 +115,7 @@ public class AuthManager { NotificationManager.INSTANCE.removeNotification(privacyPolicyRequired); } catch (Exception e) { if (e instanceof PrivacyPolicyRequiredException) { - NotificationManager.INSTANCE.updateNotification(authenticationFailure, Notification.builder() + NotificationManager.INSTANCE.updateNotification(privacyPolicyRequired, Notification.builder() .title("Privacy Policy") .description("Please accept Dungeons Guide\nPrivacy Policy to enjoy server based\nfeatures of Dungeons Guide\n\n(Including Auto-Update/Remote-Jar)") .titleColor(0xFFFF0000) @@ -158,7 +158,7 @@ public class AuthManager { if (currentToken instanceof PrivacyPolicyRequiredToken) throw new PrivacyPolicyRequiredException(); } catch (Exception e) { if (e instanceof PrivacyPolicyRequiredException) { - NotificationManager.INSTANCE.updateNotification(authenticationFailure, Notification.builder() + NotificationManager.INSTANCE.updateNotification(privacyPolicyRequired, Notification.builder() .title("Privacy Policy") .description("Please accept Dungeons Guide\nPrivacy Policy to enjoy server based\nfeatures of Dungeons Guide\n\n(Including Auto-Update/Remote-Jar)") .titleColor(0xFFFF0000) -- cgit