still wip modularisation, game somehow boots

This commit is contained in:
minjaesong
2018-06-21 17:33:22 +09:00
parent f0a6f8b9c2
commit a6ea2b4e18
266 changed files with 2409 additions and 1122 deletions

View File

@@ -8,6 +8,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.itemproperties.ItemID
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.EntryPoint
import net.torvald.terrarum.utils.JsonFetcher
import org.apache.commons.csv.CSVFormat
import org.apache.commons.csv.CSVParser
@@ -34,9 +35,6 @@ import javax.script.Invocable
*/
object ModMgr {
val groovyEngine = ScriptEngineManager().getEngineByExtension("groovy")!!
val groovyInvocable = groovyEngine as Invocable
val metaFilename = "metadata.properties"
val defaultConfigFilename = "default.json"
@@ -104,11 +102,11 @@ object ModMgr {
// run entry script in entry point
if (entryPoint.isNotBlank()) {
val extension = entryPoint.split('.').last()
val engine = ScriptEngineManager().getEngineByExtension(extension)!!
val invocable = engine as Invocable
engine.eval(FileReader(getFile(moduleName, entryPoint)))
invocable.invokeFunction("invoke", moduleName)
val newClass = Class.forName(entryPoint)
val newClassConstructor = newClass.getConstructor(/* no args defined */)
val newClassInstance = newClassConstructor.newInstance(/* no args defined */)
(newClassInstance as ModuleEntryPoint).invoke()
}