Skip to content

Commit da282b5

Browse files
committed
improve dupe checker
1 parent bce75d4 commit da282b5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
id "net.kyori.blossom" version "1.3.0"
1010
}
1111

12-
version = "1.3.8"
12+
version = "1.3.9"
1313
group = "cc.woverflow"
1414
archivesBaseName = "CrashPatch"
1515

src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,7 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
110110
}
111111
}
112112

113-
if (modsMap.containsKey("itlt")) {
114-
tryDeleting(modsMap.get("itlt").first);
115-
}
116-
if (modsMap.containsKey("custommainmenu")) {
117-
tryDeleting(modsMap.get("custommainmenu").first);
118-
}
113+
119114
if (!dupeMap.isEmpty()) {
120115
try {
121116
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
@@ -125,7 +120,7 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
125120

126121
DesktopManager.open(modsFolder);
127122
JOptionPane.showMessageDialog(null, "Duplicate mods have been detected! These mods are...\n" +
128-
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);
123+
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);
129124
try {
130125
Class<?> exitClass = Class.forName("java.lang.Shutdown");
131126
Method exit = exitClass.getDeclaredMethod("exit", int.class);
@@ -138,6 +133,14 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
138133
super.injectIntoClassLoader(classLoader);
139134
}
140135

136+
@SafeVarargs
137+
private final <A, B> boolean containsAnyKey(HashMap<A, B> hashMap, A... any) {
138+
for (A thing : any) {
139+
if (hashMap.containsKey(thing)) return true;
140+
}
141+
return false;
142+
}
143+
141144
private String getStringOf(Collection<ArrayList<Triple<File, String, String>>> dupes) {
142145
StringBuilder builder = new StringBuilder();
143146
for (ArrayList<Triple<File, String, String>> list : dupes) {

src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object CrashPatch {
2323
const val MODID = "crashpatch"
2424
const val NAME = "CrashPatch"
2525
const val VERSION = "@VERSION@"
26-
val isSkyclient by lazy(LazyThreadSafetyMode.PUBLICATION) { File(modDir, "SKYCLIENT").exists() || ModsCheckerPlugin.modsMap.keys.any { it == "skyclientcosmetics" || it == "scc" || it == "skyclientaddons" || it == "skyblockclientupdater" } }
26+
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" } }
2727
val gameDir: File by lazy(LazyThreadSafetyMode.PUBLICATION) {
2828
try {
2929
if (Launch.minecraftHome.parentFile?.name == (if (UDesktop.isMac) "minecraft" else ".minecraft")) Launch.minecraftHome.parentFile else Launch.minecraftHome

0 commit comments

Comments
 (0)