Skip to content

Commit

Permalink
ok now its done
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed May 15, 2022
1 parent aa3c926 commit b0e7a16
Showing 1 changed file with 29 additions and 34 deletions.
63 changes: 29 additions & 34 deletions src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,8 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
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();
}
doThatPopupThing(modsFolder, "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." : ""));
}
}
}
Expand All @@ -131,27 +116,37 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {


if (!dupeMap.isEmpty()) {
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();
}
doThatPopupThing(modsFolder, "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." : ""));
}
super.injectIntoClassLoader(classLoader);
}

private static void doThatPopupThing(File modsFolder, String message) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}

JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setAlwaysOnTop(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

DesktopManager.open(modsFolder);
JOptionPane.showMessageDialog(frame, message, "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();
}
}

@SafeVarargs
private final <A, B> boolean containsAnyKey(HashMap<A, B> hashMap, A... any) {
for (A thing : any) {
Expand Down

0 comments on commit b0e7a16

Please sign in to comment.