From ac4e51116ec0f699da6c2c3341397940fc39c248 Mon Sep 17 00:00:00 2001 From: Osiris Team Date: Wed, 26 Jan 2022 19:12:02 +0100 Subject: [PATCH] 0.7 - Added debug possibility --- pom.xml | 2 +- src/main/java/com/osiris/SPPU/Main.java | 8 +++++++- .../java/com/osiris/SPPU/plugins/TaskPluginsUpdater.java | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4f4652b..62fb58d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.osiris SPPU - 0.6 + 0.7 jar SPPU diff --git a/src/main/java/com/osiris/SPPU/Main.java b/src/main/java/com/osiris/SPPU/Main.java index cb843c7..85a2250 100644 --- a/src/main/java/com/osiris/SPPU/Main.java +++ b/src/main/java/com/osiris/SPPU/Main.java @@ -14,6 +14,7 @@ import java.io.File; import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Scanner; @@ -21,9 +22,14 @@ import static com.osiris.SPPU.utils.GD.SPPU_DIR; public class Main { + public static boolean isDEBUG; public static void main(String[] args) throws NotLoadedException, IOException, IllegalKeyException, DuplicateKeyException, DYReaderException, IllegalListException, JLineLinkException, DYWriterException, InterruptedException { - new AL().start("SPPU", false, new File(SPPU_DIR + "/logs"), false); + for (String arg : + args) { + if (arg.equals("debug")) isDEBUG = true; + } + new AL().start("SPPU", isDEBUG, new File(SPPU_DIR + "/logs"), false); CONFIG = new Config(SPPU_DIR + "/config.yml"); if (CONFIG.getFile().length() == 0) { // First run, enter setup: Scanner scanner = new Scanner(System.in); diff --git a/src/main/java/com/osiris/SPPU/plugins/TaskPluginsUpdater.java b/src/main/java/com/osiris/SPPU/plugins/TaskPluginsUpdater.java index cc56a79..5d00e38 100644 --- a/src/main/java/com/osiris/SPPU/plugins/TaskPluginsUpdater.java +++ b/src/main/java/com/osiris/SPPU/plugins/TaskPluginsUpdater.java @@ -8,6 +8,7 @@ package com.osiris.SPPU.plugins; +import com.osiris.SPPU.Main; import com.osiris.SPPU.plugins.search.SearchMaster; import com.osiris.SPPU.plugins.search.SearchResult; import com.osiris.SPPU.utils.GD; @@ -22,6 +23,7 @@ import org.jsoup.nodes.Document; import java.io.File; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; @@ -278,7 +280,9 @@ else if (code == 3) // Do premium stuff if (!updatablePremiumSpigotPlugins.isEmpty()) { setStatus("Logging in to spigotmc.org..."); - try (PlaywrightWindow window = new HBrowser().openCustomWindow().temporaryUserDataDir(true).headless(false).buildPlaywrightWindow()) { + OutputStream debugOut = null; + if (Main.isDEBUG) debugOut = System.out; + try (PlaywrightWindow window = new HBrowser().openCustomWindow().debugOutputStream(debugOut).temporaryUserDataDir(true).headless(false).buildPlaywrightWindow()) { SpigotAuthenticator spigotAuthenticator = new SpigotAuthenticator(); spigotAuthenticator.attemptLoginForWindow(window, spigotUsername.asString(), spigotPassword.asString(), spigotUsernameOld.asString(), spigotPasswordOld.asString()); // Throws exception on login fail