diff options
author | syeyoung <cyoung06@naver.com> | 2022-11-17 14:18:51 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2022-11-17 14:18:51 +0900 |
commit | 7c8441b75d85cfcd209e3381350a231b61294346 (patch) | |
tree | fd3c43fdcf9d4e651e730c86fdd7cb4f9e2be72c /loader/src | |
parent | 573e44eda970c4fb08b3e213d27845529efba2f1 (diff) | |
download | Skyblock-Dungeons-Guide-7c8441b75d85cfcd209e3381350a231b61294346.tar.gz Skyblock-Dungeons-Guide-7c8441b75d85cfcd209e3381350a231b61294346.tar.bz2 Skyblock-Dungeons-Guide-7c8441b75d85cfcd209e3381350a231b61294346.zip |
- Fix wrong tooltip id
- Tooltip on loading failure
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'loader/src')
-rwxr-xr-x | loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java | 53 | ||||
-rw-r--r-- | loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java | 4 |
2 files changed, 55 insertions, 2 deletions
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) |