mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 16:36:58 -04:00
mod loader: ignore non .class
files, verbose logging, replace "/" with File.separator
This commit is contained in:
parent
b912becb76
commit
fef3d66e17
@ -32,7 +32,7 @@ class LoadingPhaseTest {
|
|||||||
val phase = LoadingPhase(path)
|
val phase = LoadingPhase(path)
|
||||||
val rootResources = LoadingPhaseTest::class.java.classLoader.getResource("mods/")
|
val rootResources = LoadingPhaseTest::class.java.classLoader.getResource("mods/")
|
||||||
|
|
||||||
phase::class.java.getFieldOrNull("path")!!.forceSet(phase, File(rootResources.path.removeSuffix("/") + "/" + path))
|
phase::class.java.getFieldOrNull("path")!!.forceSet(phase, File(rootResources.path.removeSuffix(File.separator) + File.separator + path))
|
||||||
|
|
||||||
return phase
|
return phase
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class DirectoryAssetsManager(
|
|||||||
scanDirectory(file)
|
scanDirectory(file)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val path = file.slashPath.removePrefix(basePath).removePrefix("/").toAssetName(false, prefix) ?: continue
|
val path = file.slashPath.removePrefix(basePath).removePrefix(File.separator).toAssetName(false, prefix) ?: continue
|
||||||
assets += path
|
assets += path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import de.bixilon.minosoft.assets.resource.ResourceAssetsManager
|
|||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
|
import java.io.File
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ object ResourcesAssetsUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return when (rootResources.protocol) {
|
return when (rootResources.protocol) {
|
||||||
"file" -> DirectoryAssetsManager(rootResources.path.removeSuffix("/").removeSuffix(prefix), canUnload, prefix) // Read them directly from the folder
|
"file" -> DirectoryAssetsManager(rootResources.path.removeSuffix(File.separator).removeSuffix(prefix), canUnload, prefix) // Read them directly from the folder
|
||||||
"jar" -> {
|
"jar" -> {
|
||||||
val path: String = rootResources.path
|
val path: String = rootResources.path
|
||||||
val jarPath = path.substring(5, path.indexOf("!"))
|
val jarPath = path.substring(5, path.indexOf("!"))
|
||||||
|
@ -22,6 +22,10 @@ import de.bixilon.minosoft.data.text.formatting.TextFormattable
|
|||||||
import de.bixilon.minosoft.modding.loader.LoaderUtil
|
import de.bixilon.minosoft.modding.loader.LoaderUtil
|
||||||
import de.bixilon.minosoft.modding.loader.LoaderUtil.load
|
import de.bixilon.minosoft.modding.loader.LoaderUtil.load
|
||||||
import de.bixilon.minosoft.modding.loader.mod.MinosoftMod
|
import de.bixilon.minosoft.modding.loader.mod.MinosoftMod
|
||||||
|
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
|
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
|
||||||
@ -58,13 +62,19 @@ class DirectorySource(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun scanClasses(mod: MinosoftMod, baseDirectory: File, currentDirectory: File) {
|
fun scanClasses(mod: MinosoftMod, base: File, file: File) {
|
||||||
if (currentDirectory.isFile) {
|
if (file.isFile) {
|
||||||
mod.classLoader.load(currentDirectory.path.removePrefix(baseDirectory.path).removePrefix("/"), FileInputStream(currentDirectory).readAllBytes())
|
if (!file.name.endsWith(".class")) return
|
||||||
|
|
||||||
|
val path = file.path.removePrefix(base.path).removePrefix(File.separator)
|
||||||
|
if (RunConfiguration.VERBOSE_LOGGING) {
|
||||||
|
Log.log(LogMessageType.MOD_LOADING, LogLevels.VERBOSE) { "Injecting class $path" }
|
||||||
|
}
|
||||||
|
mod.classLoader.load(path, FileInputStream(file).readAllBytes())
|
||||||
}
|
}
|
||||||
if (currentDirectory.isDirectory) {
|
if (file.isDirectory) {
|
||||||
for (sub in currentDirectory.listFiles()!!) {
|
for (sub in file.listFiles()!!) {
|
||||||
scanClasses(mod, baseDirectory, sub)
|
scanClasses(mod, base, sub)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user