Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed May 15, 2022
1 parent 4d42917 commit aa3c926
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
27 changes: 24 additions & 3 deletions src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,27 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
Triple<File, String, String> 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) {
Expand Down Expand Up @@ -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<A, B, C> {
Expand Down

0 comments on commit aa3c926

Please sign in to comment.