diff options
author | syeyoung <cyoung06@naver.com> | 2022-09-08 13:04:21 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2022-09-08 13:04:21 +0900 |
commit | c9ef55f2df21c94a96f44497ac4986d90a52dace (patch) | |
tree | 08946b690f44c12f715b82ae29dd47030bd859e1 /loader/src | |
parent | bd0576d13fb6b801ebd42532599d37d7c0d68709 (diff) | |
download | Skyblock-Dungeons-Guide-c9ef55f2df21c94a96f44497ac4986d90a52dace.tar.gz Skyblock-Dungeons-Guide-c9ef55f2df21c94a96f44497ac4986d90a52dace.tar.bz2 Skyblock-Dungeons-Guide-c9ef55f2df21c94a96f44497ac4986d90a52dace.zip |
- temp
Diffstat (limited to 'loader/src')
4 files changed, 65 insertions, 4 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 66d7e79b..7cc0f806 100755 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java @@ -28,6 +28,7 @@ import kr.syeyoung.dungeonsguide.launcher.exceptions.PrivacyPolicyRequiredExcept import kr.syeyoung.dungeonsguide.launcher.exceptions.ReferenceLeakedException; import kr.syeyoung.dungeonsguide.launcher.exceptions.TokenExpiredException; import kr.syeyoung.dungeonsguide.launcher.gui.GuiLoadingError; +import kr.syeyoung.dungeonsguide.launcher.gui.GuiPrivacyPolicy; import kr.syeyoung.dungeonsguide.launcher.loader.IDGLoader; import kr.syeyoung.dungeonsguide.launcher.loader.JarLoader; import kr.syeyoung.dungeonsguide.launcher.loader.LocalLoader; @@ -149,7 +150,7 @@ public class Main public GuiScreen obtainErrorGUI() { if (lastError instanceof PrivacyPolicyRequiredException) { - + return new GuiPrivacyPolicy(); } else if (lastError instanceof TokenExpiredException) { } else if (lastError instanceof NoSuitableLoaderFoundException) { @@ -177,7 +178,9 @@ public class Main isMcLoaded = true; } if (lastError != null && guiOpenEvent.gui instanceof GuiMainMenu) { - guiOpenEvent.gui = obtainErrorGUI(); + GuiScreen gui = obtainErrorGUI(); + if (gui != null) + guiOpenEvent.gui = gui; } } diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/authentication/Authenticator.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/authentication/Authenticator.java index d16f70ed..ac30c5e3 100755 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/authentication/Authenticator.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/authentication/Authenticator.java @@ -187,8 +187,9 @@ public class Authenticator { } private JSONObject verifyAuth(String tempToken, byte[] encryptedSecret) throws IOException { HttpURLConnection urlConnection = request("POST", "/auth/v2/authenticate"); + urlConnection.setRequestProperty("Content-Type", "application/json"); - urlConnection.getOutputStream().write(("{\"jwt\":\""+tempToken+"\",\"sharedSecret\":\""+Base64.encodeBase64URLSafeString(encryptedSecret)+"}").getBytes()); + urlConnection.getOutputStream().write(("{\"jwt\":\""+tempToken+"\",\"sharedSecret\":\""+Base64.encodeBase64String(encryptedSecret)+"\"}").getBytes()); try (InputStream is = obtainInputStream(urlConnection)) { String payload = String.join("\n", IOUtils.readLines(is)); if (urlConnection.getResponseCode() != 200) diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthServerException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthServerException.java index abe47881..be610c3f 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthServerException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthServerException.java @@ -24,7 +24,11 @@ public class AuthServerException extends RuntimeException { private JSONObject payload; public AuthServerException(JSONObject payload) { - super("Auth server threw: \n"+payload); + super(payload.getString("errorMessage")); this.payload = payload; } + + public String getQRCode() { + return payload.getString("data"); + } } diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/GuiPrivacyPolicy.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/GuiPrivacyPolicy.java new file mode 100644 index 00000000..b7d21b16 --- /dev/null +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/GuiPrivacyPolicy.java @@ -0,0 +1,53 @@ +package kr.syeyoung.dungeonsguide.launcher.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.*; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraftforge.fml.common.FMLCommonHandler; +import org.lwjgl.opengl.GL11; + +import java.io.IOException; + +public class GuiPrivacyPolicy extends GuiScreen { + @Override + public void initGui() { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + this.buttonList.add(new GuiButton(0, sr.getScaledWidth()/2+50,sr.getScaledHeight()-40, 300, 20,"Accept Privacy Policy")); + this.buttonList.add(new GuiButton(1, sr.getScaledWidth()/2-50-300,sr.getScaledHeight()-40, 300, 20,"Deny and Play Without DG")); + } + + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + if (button.id == 0) { + // accept + } else if (button.id == 1) { + Minecraft.getMinecraft().displayGuiScreen(null); + } + } + + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawBackground(0); + + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; + + fontRenderer.drawString("", (sr.getScaledWidth()-fontRenderer.getStringWidth("Please accept or deny Dungeons Guide Privacy Policy to continue"))/2,40,0xFFFF0000); + + + super.drawScreen(mouseX, mouseY, partialTicks); + } + + public static void clip(ScaledResolution resolution, int x, int y, int width, int height) { + if (width < 0 || height < 0) return; + + int scale = resolution.getScaleFactor(); + GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); + } +} |