Skip to content

Commit

Permalink
improve dupe checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Apr 24, 2022
1 parent bce75d4 commit da282b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 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.3.8"
version = "1.3.9"
group = "cc.woverflow"
archivesBaseName = "CrashPatch"

Expand Down
17 changes: 10 additions & 7 deletions src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
}
}

if (modsMap.containsKey("itlt")) {
tryDeleting(modsMap.get("itlt").first);
}
if (modsMap.containsKey("custommainmenu")) {
tryDeleting(modsMap.get("custommainmenu").first);
}

if (!dupeMap.isEmpty()) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Expand All @@ -125,7 +120,7 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {

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. Go to https://inv.wtf/skyclient for more info.", "Duplicate Mods Detected!", JOptionPane.ERROR_MESSAGE);
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);
Expand All @@ -138,6 +133,14 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
super.injectIntoClassLoader(classLoader);
}

@SafeVarargs
private final <A, B> boolean containsAnyKey(HashMap<A, B> hashMap, A... any) {
for (A thing : any) {
if (hashMap.containsKey(thing)) return true;
}
return false;
}

private String getStringOf(Collection<ArrayList<Triple<File, String, String>>> dupes) {
StringBuilder builder = new StringBuilder();
for (ArrayList<Triple<File, String, String>> list : dupes) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object CrashPatch {
const val MODID = "crashpatch"
const val NAME = "CrashPatch"
const val VERSION = "@VERSION@"
val isSkyclient by lazy(LazyThreadSafetyMode.PUBLICATION) { File(modDir, "SKYCLIENT").exists() || ModsCheckerPlugin.modsMap.keys.any { it == "skyclientcosmetics" || it == "scc" || it == "skyclientaddons" || it == "skyblockclientupdater" } }
val isSkyclient by lazy(LazyThreadSafetyMode.PUBLICATION) { File(modDir, "SKYCLIENT").exists() || ModsCheckerPlugin.modsMap.keys.any { it == "skyclientcosmetics" || it == "scc" || it == "skyclientaddons" || it == "skyblockclientupdater" || it == "skyclientupdater" || it == "skyclientcore" } }
val gameDir: File by lazy(LazyThreadSafetyMode.PUBLICATION) {
try {
if (Launch.minecraftHome.parentFile?.name == (if (UDesktop.isMac) "minecraft" else ".minecraft")) Launch.minecraftHome.parentFile else Launch.minecraftHome
Expand Down

0 comments on commit da282b5

Please sign in to comment.