From da282b50274422c6f50bbd6edb7e9a011151876d Mon Sep 17 00:00:00 2001
From: Wyvest <45589059+Wyvest@users.noreply.github.com>
Date: Sun, 24 Apr 2022 19:01:07 +0700
Subject: [PATCH] improve dupe checker
---
build.gradle | 2 +-
.../crashpatch/hooks/ModsCheckerPlugin.java | 17 ++++++++++-------
.../cc/woverflow/crashpatch/CrashPatch.kt | 2 +-
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/build.gradle b/build.gradle
index b16e0aa..07e1933 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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"
diff --git a/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java b/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java
index 5636323..0e0bb89 100644
--- a/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java
+++ b/src/main/java/cc/woverflow/crashpatch/hooks/ModsCheckerPlugin.java
@@ -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());
@@ -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);
@@ -138,6 +133,14 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) {
super.injectIntoClassLoader(classLoader);
}
+ @SafeVarargs
+ private final boolean containsAnyKey(HashMap hashMap, A... any) {
+ for (A thing : any) {
+ if (hashMap.containsKey(thing)) return true;
+ }
+ return false;
+ }
+
private String getStringOf(Collection>> dupes) {
StringBuilder builder = new StringBuilder();
for (ArrayList> list : dupes) {
diff --git a/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt b/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt
index aa02547..3854254 100644
--- a/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt
+++ b/src/main/kotlin/cc/woverflow/crashpatch/CrashPatch.kt
@@ -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