From 49f68be2cb8114c1f939b5d55fd0fa01fce28a03 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 7 Feb 2025 21:19:25 -0500 Subject: [PATCH] Closes #6790 --- core/src/mindustry/mod/Mods.java | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/core/src/mindustry/mod/Mods.java b/core/src/mindustry/mod/Mods.java index 70b83ab3c8..572f4ceee1 100644 --- a/core/src/mindustry/mod/Mods.java +++ b/core/src/mindustry/mod/Mods.java @@ -476,13 +476,7 @@ public class Mods implements Loadable{ ModMeta meta = null; try{ - Fi zip = file.isDirectory() ? file : new ZipFi(file); - - if(zip.list().length == 1 && zip.list()[0].isDirectory()){ - zip = zip.list()[0]; - } - - meta = findMeta(zip); + meta = findMeta(resolveRoot(file.isDirectory() ? file : new ZipFi(file))); }catch(Throwable ignored){ } @@ -507,7 +501,7 @@ public class Mods implements Loadable{ if(steam) mod.addSteamID(file.name()); }catch(Throwable e){ if(e instanceof ClassNotFoundException && e.getMessage().contains("mindustry.plugin.Plugin")){ - Log.info("Plugin '@' is outdated and needs to be ported to 6.0! Update its main class to inherit from 'mindustry.mod.Plugin'. See https://mindustrygame.github.io/wiki/modding/6-migrationv6/", file.name()); + Log.warn("Plugin '@' is outdated and needs to be ported to v7! Update its main class to inherit from 'mindustry.mod.Plugin'.", file.name()); }else if(steam){ Log.err("Failed to load mod workshop file @. Skipping.", file); Log.err(e); @@ -935,10 +929,10 @@ public class Mods implements Loadable{ return true; } - /** Loads a mod file+meta, but does not add it to the list. - * Note that directories can be loaded as mods. */ - private LoadedMod loadMod(Fi sourceFile) throws Exception{ - return loadMod(sourceFile, false, true); + private Fi resolveRoot(Fi fi){ + if(OS.isMac && (!(fi instanceof ZipFi))) fi.child(".DS_Store").delete(); + Fi[] files = fi.list(); + return files.length == 1 && files[0].isDirectory() ? files[0] : fi; } /** Loads a mod file+meta, but does not add it to the list. @@ -949,10 +943,7 @@ public class Mods implements Loadable{ ZipFi rootZip = null; try{ - Fi zip = sourceFile.isDirectory() ? sourceFile : (rootZip = new ZipFi(sourceFile)); - if(zip.list().length == 1 && zip.list()[0].isDirectory()){ - zip = zip.list()[0]; - } + Fi zip = resolveRoot(sourceFile.isDirectory() ? sourceFile : (rootZip = new ZipFi(sourceFile))); ModMeta meta = findMeta(zip);