aboutsummaryrefslogtreecommitdiff
path: root/loader/src/main/java/kr
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2023-11-16 18:20:14 +0900
committerGitHub <noreply@github.com>2023-11-16 18:20:14 +0900
commit24fc59daa6da3c48544d2d8aec5606a2089f64d5 (patch)
tree61247e29be92d5489a38e4c4ec1881ee5ff15bd1 /loader/src/main/java/kr
parentde2ea64b5127570baa61ade6fd7a63416c8b7cb9 (diff)
downloadSkyblock-Dungeons-Guide-24fc59daa6da3c48544d2d8aec5606a2089f64d5.tar.gz
Skyblock-Dungeons-Guide-24fc59daa6da3c48544d2d8aec5606a2089f64d5.tar.bz2
Skyblock-Dungeons-Guide-24fc59daa6da3c48544d2d8aec5606a2089f64d5.zip
Automatically collect Dungeons Guide stack traces with user approval. (#446)
* - fix error handling, don't use throwables like amateur Signed-off-by: syeyoung <cyoung06@naver.com> * - no need for hack to stop Signed-off-by: syeyoung <cyoung06@naver.com> * - gui error handling Signed-off-by: syeyoung <cyoung06@naver.com> * - remote logging error Signed-off-by: syeyoung <cyoung06@naver.com> * - remote logging error Signed-off-by: syeyoung <cyoung06@naver.com> * - testing privacy policy Signed-off-by: syeyoung <cyoung06@naver.com> * - send traces Signed-off-by: syeyoung <cyoung06@naver.com> * - show collect diagnostic? prompt Signed-off-by: syeyoung <cyoung06@naver.com> --------- Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'loader/src/main/java/kr')
-rwxr-xr-xloader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java11
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicyLocal.java94
2 files changed, 105 insertions, 0 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 fb6acadf..6ea7bbfa 100755
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
@@ -23,6 +23,8 @@ import kr.syeyoung.dungeonsguide.launcher.branch.UpdateRetrieverUtil;
import kr.syeyoung.dungeonsguide.launcher.exceptions.*;
import kr.syeyoung.dungeonsguide.launcher.gui.screen.GuiDisplayer;
import kr.syeyoung.dungeonsguide.launcher.gui.screen.WidgetError;
+import kr.syeyoung.dungeonsguide.launcher.gui.screen.WidgetPrivacyPolicy;
+import kr.syeyoung.dungeonsguide.launcher.gui.screen.WidgetPrivacyPolicyLocal;
import kr.syeyoung.dungeonsguide.launcher.gui.screen.version.WidgetChooseVersion;
import kr.syeyoung.dungeonsguide.launcher.gui.tooltip.Notification;
import kr.syeyoung.dungeonsguide.launcher.gui.tooltip.NotificationManager;
@@ -332,6 +334,15 @@ public class Main
if (dgInterface != null) dgInterface.onResourceReload(a);
DefaultFontRenderer.DEFAULT_RENDERER.onResourceManagerReload();
});
+// UUID uid = UUID.randomUUID();
+// NotificationManager.getInstance().updateNotification(uid, new WidgetNotification(uid, 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)
+// .onClick(() -> {
+// GuiDisplayer.INSTANCE.displayGui(new GuiScreenAdapter(new GlobalHUDScale(new WidgetPrivacyPolicyLocal())));
+// })
+// .build()));
}
public static Main getMain() {
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicyLocal.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicyLocal.java
new file mode 100644
index 00000000..eb5eca2f
--- /dev/null
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/WidgetPrivacyPolicyLocal.java
@@ -0,0 +1,94 @@
+/*
+ * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
+ * Copyright (C) 2023 cyoung06 (syeyoung)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package kr.syeyoung.dungeonsguide.launcher.gui.screen;
+
+import kr.syeyoung.dungeonsguide.launcher.LetsEncrypt;
+import kr.syeyoung.dungeonsguide.launcher.LoaderMeta;
+import kr.syeyoung.dungeonsguide.launcher.Main;
+import kr.syeyoung.dungeonsguide.launcher.auth.AuthManager;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.BindableAttribute;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.Widget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.AnnotatedImportOnlyWidget;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.DomElementRegistry;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.ParsedWidgetConverter;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.Bind;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.annotations.On;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.data.ParserElement;
+import kr.syeyoung.dungeonsguide.launcher.guiv2.xml.data.W3CBackedParser;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.util.ResourceLocation;
+
+import javax.net.ssl.HttpsURLConnection;
+import java.net.URL;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class WidgetPrivacyPolicyLocal extends AnnotatedImportOnlyWidget {
+ public static final ExecutorService executor = Executors.newSingleThreadExecutor();
+ @Bind(variableName = "policy")
+ public final BindableAttribute<Widget> policy = new BindableAttribute<>(Widget.class);
+ @Bind(variableName = "policyVisibility")
+ public final BindableAttribute<String> policyVisibility = new BindableAttribute<>(String.class, "loading");
+
+ @Bind(variableName = "policyVersion")
+ public final BindableAttribute<Integer> version = new BindableAttribute<>(Integer.class, 0);
+
+ public WidgetPrivacyPolicyLocal() {
+ super(new ResourceLocation("dungeons_guide_loader:gui/privacyPolicy/privacyPolicy.gui"));
+ reload0();
+ }
+
+ @On(functionName = "accept")
+ public void accept() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ AuthManager.getInstance().acceptPrivacyPolicy(version.getValue());
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+ @On(functionName = "deny")
+ public void deny() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+
+
+ public void reload0() {
+ policyVisibility.setValue("loading");
+ executor.submit(() -> {
+ try {
+
+ try (W3CBackedParser parser = new W3CBackedParser(WidgetPrivacyPolicyLocal.class.getResourceAsStream("/privacyPolicyTest.gui"))) {
+ ParserElement element = parser.getRootNode();
+ ParsedWidgetConverter converter = DomElementRegistry.obtainConverter(element.getNodeName());
+ Widget w = converter.convert(this, element);
+ policy.setValue(w);
+ policyVisibility.setValue("loaded");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ policyVisibility.setValue("failed");
+ }
+ });
+ }
+ @On(functionName = "reload")
+ public void reload() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ reload0();
+ }
+}