From 0eed64970700ac64120d608ff367603eb5c59087 Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 1 Aug 2024 22:32:36 +0900 Subject: [PATCH] dont duplicate classpath --- .../impl/fabric/asm/TransformerPlugin.kt | 2 +- .../impl/forge/asm/ClassTransformer.kt | 2 +- .../platform/impl/forge/util/Classpath.kt | 26 ------------------- .../org/polyfrost/spice}/util/Classpath.kt | 10 +++++-- 4 files changed, 10 insertions(+), 30 deletions(-) delete mode 100644 versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/util/Classpath.kt rename versions/{1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric => src/main/kotlin/org/polyfrost/spice}/util/Classpath.kt (72%) diff --git a/versions/1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric/asm/TransformerPlugin.kt b/versions/1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric/asm/TransformerPlugin.kt index c1e7b92..04a3d5d 100644 --- a/versions/1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric/asm/TransformerPlugin.kt +++ b/versions/1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric/asm/TransformerPlugin.kt @@ -11,7 +11,7 @@ import org.polyfrost.spice.patcher.loadCache import org.polyfrost.spice.platform.api.IClassTransformer import org.polyfrost.spice.platform.api.Transformer import org.polyfrost.spice.platform.bootstrapTransformer -import org.polyfrost.spice.platform.impl.fabric.util.collectResources +import org.polyfrost.spice.util.collectResources import org.polyfrost.spice.util.UrlByteArrayConnection import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin import org.spongepowered.asm.mixin.extensibility.IMixinInfo diff --git a/versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/asm/ClassTransformer.kt b/versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/asm/ClassTransformer.kt index 0cee88e..4edb857 100644 --- a/versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/asm/ClassTransformer.kt +++ b/versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/asm/ClassTransformer.kt @@ -16,7 +16,7 @@ import org.polyfrost.spice.platform.api.IClassTransformer import org.polyfrost.spice.platform.api.Transformer import org.polyfrost.spice.platform.bootstrapTransformer import org.polyfrost.spice.platform.impl.forge.util.LaunchWrapperLogger -import org.polyfrost.spice.platform.impl.forge.util.collectResources +import org.polyfrost.spice.util.collectResources import org.polyfrost.spice.util.SpiceClassWriter import java.net.URL import java.util.concurrent.TimeUnit diff --git a/versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/util/Classpath.kt b/versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/util/Classpath.kt deleted file mode 100644 index f085501..0000000 --- a/versions/src/main/kotlin/org/polyfrost/spice/platform/impl/forge/util/Classpath.kt +++ /dev/null @@ -1,26 +0,0 @@ -package org.polyfrost.spice.platform.impl.forge.util - -import java.io.File -import java.net.URL -import java.util.jar.JarInputStream - -fun collectResources(urls: Array): List = - urls - .filter { it.protocol != "spice" && it.protocol != "asmgen" } - .map { - runCatching { - val file = File(it.toURI()) - - if (file.isDirectory) return@map emptyList() - } - - JarInputStream(it.openStream()) - .use { stream -> - val entries = mutableListOf() - - while (true) entries += stream.nextEntry?.name ?: break - - entries - } - } - .flatten() diff --git a/versions/1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric/util/Classpath.kt b/versions/src/main/kotlin/org/polyfrost/spice/util/Classpath.kt similarity index 72% rename from versions/1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric/util/Classpath.kt rename to versions/src/main/kotlin/org/polyfrost/spice/util/Classpath.kt index 6aa778b..5b2ed0b 100644 --- a/versions/1.8.9-fabric/src/main/kotlin/org/polyfrost/spice/platform/impl/fabric/util/Classpath.kt +++ b/versions/src/main/kotlin/org/polyfrost/spice/util/Classpath.kt @@ -1,12 +1,18 @@ -package org.polyfrost.spice.platform.impl.fabric.util +package org.polyfrost.spice.util import java.io.File import java.net.URL import java.util.jar.JarInputStream +//TODO we can probably move this to core + fun collectResources(urls: Array): List = urls - .filter { it.protocol != "spice" } + .filter { it.protocol != "spice" + //#if FORGE + && it.protocol != "asmgen" + //#endif + } .map { runCatching { val file = File(it.toURI())