diff --git a/build.gradle b/build.gradle index 4b755c7..828c1a7 100644 --- a/build.gradle +++ b/build.gradle @@ -16,9 +16,6 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}+build.+:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}+build.+" - // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. } diff --git a/gradle.properties b/gradle.properties index 31877ba..5927437 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,10 +8,6 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.8.2 # Mod Properties - mod_version = 1.1.1 + mod_version = 1.2 maven_group = com.halotroop archives_base_name = arrchecker - -# Dependencies - # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.5.1+build.294-1.15 diff --git a/src/main/java/com/halotroop/arrchecker/ARRChecker.java b/src/main/java/com/halotroop/arrchecker/ARRChecker.java index 23fcd17..e57e34a 100644 --- a/src/main/java/com/halotroop/arrchecker/ARRChecker.java +++ b/src/main/java/com/halotroop/arrchecker/ARRChecker.java @@ -7,76 +7,71 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.metadata.ModMetadata; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; -public class ARRChecker implements ModInitializer -{ - private static List arrMods = new ArrayList(); - - @Override - public void onInitialize() - { - arrMods.clear(); - for (ModContainer mod : FabricLoader.getInstance().getAllMods()) - { - ModMetadata modMeta = mod.getMetadata(); - // Assume all authors don't know how capitalization works, and don't use an array for the string! - String modLicense = modMeta.getLicense().toString().toLowerCase().replace('[', ' ').replace(']', ' ').trim(); - // Create a constant of the mod name and ID to be used multiple times: Don't use an array for the string! - String modNameAndID = (modMeta.getName() + " (" + modMeta.getId() + ")").replace('[', ' ').replace(']', ' ').trim(); - // Give a different warning for Minecraft itself. - if (modMeta.getId() != "minecraft") - { - if (modLicense == null || modLicense.isEmpty() || modLicense.isEmpty()) - { - // If no license is found, assume mod is not correctly licensed, and therefore, not modpack-friendly. - System.out.println(modNameAndID + " has no license! It may be ARR!"); - arrMods.add(modMeta.getId()); - } - else if (modLicense == "all rights reserved" || modLicense == "arr" || modLicense.contains("copyright")) - { - // If license is All Rights Reserved, or copyright is attributed, assume mod is not modpack-friendly. - System.out.println(modNameAndID + " is ARR. Do not use it( in a modpack)!"); - arrMods.add(modMeta.getId()); - } - else - { - String[] validLicenses = - { - "gpl", "mit", "cc0", "apache", "unlicense", "mpl", // Short form names - "gnu public license", "mozilla public license", "creative commons" // Long form (incorrect, but check anyway) - }; - Boolean modLicenseInvalid = true; - for (String validLicense : validLicenses) - { - // If a valid license is found, set invalid to false, and stop checking - if (!(modLicenseInvalid = !modLicense.contains(validLicense))) break; - } - if (modLicenseInvalid) - { - // If a valid license is not found, print crayon warning. - System.out.println(modNameAndID + " may have a crayon license! It is: " + modLicense); - // If a valid license is not found, assume mod is not modpack-friendly. - arrMods.add(modMeta.getId()); - } - } - } - } - if (!arrMods.isEmpty()) - { - String invalidMods = ""; - for (String mod : arrMods) - { - invalidMods = invalidMods - + (invalidMods.isEmpty() ? mod - : arrMods.get(arrMods.size() - 1).equals(mod) ? (" and " + mod) - : (", " + mod)); - } - if (!invalidMods.isEmpty()) System.out.println(arrMods.size() == 1 ? - "This mod" : "These mods" + " may not be suitable for a modpack:\n" + invalidMods); - } - System.out.println("Minecraft isn't a mod, but in case you didn't know, it's ARR!\n" + "Don't distribute it!"); - } +public class ARRChecker implements ModInitializer { + private static final List arrMods = new ArrayList<>(); + private static final Logger LOGGER = LogManager.getLogger("arrchecker"); - public static List getARRMods() - { return arrMods; } + @Override + public void onInitialize() { + arrMods.clear(); + for (ModContainer mod : FabricLoader.getInstance().getAllMods()) { + ModMetadata modMeta = mod.getMetadata(); + // Assume all authors don't know how capitalization works, and don't use an array for the string! + String modLicense = modMeta.getLicense().toString().toLowerCase().replace('[', ' ').replace(']', ' ').trim(); + // Create a constant of the mod name and ID to be used multiple times: Don't use an array for the string! + String modNameAndID = (modMeta.getName() + " (" + modMeta.getId() + ")").replace('[', ' ').replace(']', ' ').trim(); + // Give a different warning for Minecraft itself. + if (!modMeta.getId().equals("minecraft") && !modMeta.getId().equals("java")) { + if (modLicense.isEmpty()) { + // If no license is found, assume mod is not correctly licensed, and therefore, not modpack-friendly. + LOGGER.warn(modNameAndID + " has no license! It may be ARR!"); + arrMods.add(modMeta.getId()); + } else if (modLicense.equals("all rights reserved") || modLicense.equals("arr") || modLicense.contains("copyright")) { + // If license is All Rights Reserved, or copyright is attributed, assume mod is not modpack-friendly. + LOGGER.warn(modNameAndID + " is ARR. Do not use it in a modpack!"); + arrMods.add(modMeta.getId()); + } else { + String[] validLicenses = + { + "gpl", "mit", "cc0", "apache", "unlicense", "mpl", // Short form names + "gnu public license", "mozilla public license", "creative commons" // Long form (incorrect, but check anyway) + }; + boolean modLicenseInvalid = true; + for (String validLicense : validLicenses) { + // If a valid license is found, set invalid to false, and stop checking + if (!(modLicenseInvalid = !modLicense.contains(validLicense))) break; + } + if (modLicenseInvalid) { + // If a valid license is not found, print crayon warning. + LOGGER.warn(modNameAndID + " may have a crayon license! It is: " + modLicense); + // If a valid license is not found, assume mod is not modpack-friendly. + arrMods.add(modMeta.getId()); + } + } + } + } + if (!arrMods.isEmpty()) { + StringBuilder invalidMods = new StringBuilder(); + for (int i = 0, arrModsSize = arrMods.size(); i < arrModsSize; i++) { + String mod = arrMods.get(i); + if (invalidMods.length() > 0) { + boolean isLastElement = i == arrModsSize - 1; + invalidMods.append(isLastElement ? " and " : ", "); + } + invalidMods.append(mod); + } + if (invalidMods.length() != 0) { + LOGGER.error(arrMods.size() == 1 ? "This mod" : "These mods" + + " may not be suitable for a modpack:\n" + invalidMods); + } + } + LOGGER.warn("Minecraft isn't a mod, but in case you didn't know, it's ARR!\nDon't distribute it!"); + } + + public static List getARRMods() { + return arrMods; + } } diff --git a/src/main/resources/arrchecker.mixins.json b/src/main/resources/arrchecker.mixins.json deleted file mode 100644 index 351e221..0000000 --- a/src/main/resources/arrchecker.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "net.fabricmc.example.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - ], - "client": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2b0181f..b4f88b1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,13 +23,9 @@ "com.halotroop.arrchecker.ARRChecker" ] }, - "mixins": [ - "arrchecker.mixins.json" - ], "depends": { "fabricloader": ">=0.7.4", - "fabric": "*", "minecraft": "*" }, "suggests": {