From aa3c92628df86c882d52049f20879f5fd4d0a810 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sun, 15 May 2022 15:45:20 +0700 Subject: [PATCH] done --- build.gradle | 2 +- .../crashpatch/hooks/ModsCheckerPlugin.java | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 6e5f9c2..4d700d0 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { id "net.kyori.blossom" version "1.3.0" } -version = "1.4.0-beta1" +version = "1.4.0" group = "cc.woverflow" archivesBaseName = "CrashPatch" diff --git a/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java b/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java index 0e0bb89..6e7dd68 100644 --- a/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java +++ b/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java @@ -98,8 +98,27 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) { Triple remove = otherIterator.next(); ++index; if (index != 1) { - tryDeleting(remove.first); - otherIterator.remove(); + if (tryDeleting(remove.first)) { + otherIterator.remove(); + } else { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + e.printStackTrace(); + } + + DesktopManager.open(modsFolder); + JOptionPane.showMessageDialog(null, "Duplicate mods have been detected! These mods are...\n" + + getStringOf(dupeMap.values()) + "\nPlease removes these mods from your mod folder, which is opened." + ((new File("./W-OVERFLOW/CrashPatch/SKYCLIENT").exists() || containsAnyKey(ModsCheckerPlugin.modsMap, "skyclientcosmetics", "scc", "skyclientaddons", "skyblockclientupdater", "skyclientupdater", "skyclientcore")) ? " GO TO https://inv.wtf/skyclient FOR MORE INFORMATION." : ""), "Duplicate Mods Detected!", JOptionPane.ERROR_MESSAGE); + try { + Class exitClass = Class.forName("java.lang.Shutdown"); + Method exit = exitClass.getDeclaredMethod("exit", int.class); + exit.setAccessible(true); + exit.invoke(null, 0); + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } } } if (next.size() <= 1) { @@ -162,14 +181,16 @@ private String substringBeforeAny(String string, String... values) { return returnString; } - private void tryDeleting(File file) { + private boolean tryDeleting(File file) { if (!file.delete()) { if (!file.delete()) { if (!file.delete()) { file.deleteOnExit(); + return false; } } } + return true; } public static class Triple {