From f033c34b2e2a7824df41ea750b66b21685462279 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Thu, 17 Nov 2022 15:12:50 +0900 Subject: - Add copy error - Propagate AuthServerException - Fix Loader loading old dg Signed-off-by: syeyoung --- .../dungeonsguide/launcher/auth/DgAuthUtil.java | 2 ++ .../launcher/gui/screen/GuiLoadingError.java | 19 +++++++++++++++++++ .../dungeonsguide/launcher/loader/JarLoader.java | 4 ++-- .../dungeonsguide/launcher/loader/LocalLoader.java | 4 ++-- .../dungeonsguide/launcher/loader/RemoteLoader.java | 4 ++-- 5 files changed, 27 insertions(+), 6 deletions(-) (limited to 'loader/src/main/java/kr/syeyoung/dungeonsguide') diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java index 803ac41a..033427bd 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java @@ -64,6 +64,8 @@ public class DgAuthUtil { } return (T) response.getData(); + } catch (AuthServerException e) { + throw e; } catch (Exception e) { throw new ResponseParsingException(payload, e); } finally { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiLoadingError.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiLoadingError.java index 436d5d8c..b61484f1 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiLoadingError.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiLoadingError.java @@ -18,14 +18,19 @@ package kr.syeyoung.dungeonsguide.launcher.gui.screen; +import kr.syeyoung.dungeonsguide.launcher.gui.tooltip.Notification; +import kr.syeyoung.dungeonsguide.launcher.gui.tooltip.NotificationManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; import net.minecraftforge.fml.common.FMLCommonHandler; import org.lwjgl.opengl.GL11; +import java.awt.*; +import java.awt.datatransfer.StringSelection; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.util.UUID; public class GuiLoadingError extends SpecialGuiScreen { private final String stacktrace; @@ -42,6 +47,7 @@ public class GuiLoadingError extends SpecialGuiScreen { ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); this.buttonList.add(new GuiButton(0, sr.getScaledWidth()/2-100,sr.getScaledHeight()-70 ,"Close Minecraft")); this.buttonList.add(new GuiButton(1, sr.getScaledWidth()/2-100,sr.getScaledHeight()-40 ,"Play Without DG")); + this.buttonList.add(new GuiButton(2, 0,sr.getScaledHeight()-20 ,"Copy Error into Clipboard")); } @Override @@ -51,6 +57,19 @@ public class GuiLoadingError extends SpecialGuiScreen { FMLCommonHandler.instance().exitJava(-1,true); } else if (button.id == 1) { dismiss(); + } else if (button.id == 2) { + Toolkit.getDefaultToolkit() + .getSystemClipboard() + .setContents( + new StringSelection(stacktrace), + null + ); + + NotificationManager.INSTANCE.updateNotification(UUID.randomUUID(), Notification.builder() + .title("Successfully Copied!") + .description("") + .titleColor(0xFF00FF00) + .build()); } } diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java index 2a448e97..dbb86dee 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java @@ -60,7 +60,7 @@ public class JarLoader implements IDGLoader { private final HashMap loadedResources = new HashMap(); @Override public byte[] getClassBytes(String name) throws IOException { // . separated. - return this.loadedResources.get(name.replace(".", "/")); + return this.loadedResources.get(name.replace(".", "/")+".class"); } @Override @@ -80,7 +80,7 @@ public class JarLoader implements IDGLoader { try { classLoader = new JarClassLoader(this.getClass().getClassLoader(), new ZipInputStream(JarLoader.class.getResourceAsStream("/mod.jar"))); - dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.DungeonsGuide", true).newInstance(); + dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance(); phantomReference = new PhantomReference<>(classLoader, refQueue); return dgInterface; } catch (Exception e) { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java index 267f66d8..a47b2aaf 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java @@ -47,7 +47,7 @@ public class LocalLoader implements IDGLoader { } @Override public byte[] getClassBytes(String name) throws IOException { // . separated. - InputStream in = convert("/"+name.replace(".", "/")); + InputStream in = convert("/"+name.replace(".", "/")+".class"); if (in == null) return null; return IOUtils.toByteArray(in); } @@ -67,7 +67,7 @@ public class LocalLoader implements IDGLoader { try { classLoader = new LocalClassLoader(this.getClass().getClassLoader()); - dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.DungeonsGuide", true).newInstance(); + dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance(); phantomReference = new PhantomReference<>(classLoader, refQueue); return dgInterface; } catch (Exception e) { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java index 860c5a9c..446958a0 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java @@ -67,7 +67,7 @@ public class RemoteLoader implements IDGLoader { private final HashMap loadedResources = new HashMap(); @Override public byte[] getClassBytes(String name) throws IOException { // . separated. - return this.loadedResources.get(name.replace(".", "/")); + return this.loadedResources.get(name.replace(".", "/")+".class"); } @Override @@ -109,7 +109,7 @@ public class RemoteLoader implements IDGLoader { classLoader = new JarClassLoader(this.getClass().getClassLoader(), new ZipInputStream(new ByteArrayInputStream(mod))); - dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.DungeonsGuide", true).newInstance(); + dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance(); phantomReference = new PhantomReference<>(classLoader, refQueue); return dgInterface; } catch (Exception e) { -- cgit