diff options
author | thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> | 2020-01-01 12:19:48 -0800 |
---|---|---|
committer | thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> | 2020-01-01 12:19:48 -0800 |
commit | e881f3b56b904c16a488579380d5dceae828c1b2 (patch) | |
tree | cd662e20f4082c69ed69d81e1e60f83a086b18f7 | |
parent | 77979e454e8acd6dd2ab6f4fe9ee186ec644c320 (diff) | |
download | KotlinForForge-e881f3b56b904c16a488579380d5dceae828c1b2.tar.gz KotlinForForge-e881f3b56b904c16a488579380d5dceae828c1b2.tar.bz2 KotlinForForge-e881f3b56b904c16a488579380d5dceae828c1b2.zip |
Update 1.0.1
21 files changed, 113 insertions, 37 deletions
diff --git a/build.gradle b/build.gradle index 363c8c3..e8fc1ca 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ plugins { apply plugin: 'net.minecraftforge.gradle' apply plugin: 'kotlin' -version = '1.0.0' +version = '1.0.1' group = 'thedarkcolour.kotlinforforge' archivesBaseName = 'kotlinforforge' @@ -113,4 +113,8 @@ compileKotlin { freeCompilerArgs = ["-Xinline-classes"] jvmTarget = '1.8' } + // Required to run in dev environment + copy { + from "$buildDir/classes/kotlin/main" into "$buildDir/classes/java/main" + } }
\ No newline at end of file diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt index 9f81c93..eae9ef5 100644 --- a/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/AutoKotlinEventBusSubscriber.kt @@ -8,7 +8,6 @@ import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.fml.loading.moddiscovery.ModAnnotation import net.minecraftforge.forgespi.language.ModFileScanData import org.objectweb.asm.Type -import thedarkcolour.kotlinforforge.KotlinForForge.logger import thedarkcolour.kotlinforforge.forge.FORGE_BUS import thedarkcolour.kotlinforforge.forge.MOD_BUS import java.util.* diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt index f6139bc..aef44e5 100644 --- a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinForForge.kt @@ -1,13 +1,9 @@ package thedarkcolour.kotlinforforge import net.minecraftforge.fml.common.Mod -import org.apache.logging.log4j.LogManager -import org.apache.logging.log4j.Logger /** * Set 'modLoader' in mods.toml to "kotlinforforge" and loaderVersion to "[1,)". */ @Mod("kotlinforforge") -object KotlinForForge { - internal val logger: Logger = LogManager.getLogger() -}
\ No newline at end of file +object KotlinForForge
\ No newline at end of file diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt index 7d68f7e..a98fda7 100644 --- a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinLanguageProvider.kt @@ -15,7 +15,7 @@ class KotlinLanguageProvider : FMLJavaModLanguageProvider() { return Consumer { scanResult -> val target = scanResult.annotations.stream() .filter { data -> data.annotationType == MODANNOTATION } - .peek { data -> KotlinForForge.logger.debug(Logging.SCAN, "Found @Mod class ${data.classType.className} with id ${data.annotationData["value"]}") } + .peek { data -> logger.debug(Logging.SCAN, "Found @Mod class ${data.classType.className} with id ${data.annotationData["value"]}") } .map { data -> KotlinModTarget(data.classType.className, data.annotationData["value"] as String) } .collect(Collectors.toMap({ target: KotlinModTarget -> target.modId }, { it }, { a, _ -> a })) scanResult.addLanguageLoader(target) @@ -29,8 +29,8 @@ class KotlinLanguageProvider : FMLJavaModLanguageProvider() { class KotlinModTarget constructor(private val className: String, val modId: String) : IModLanguageProvider.IModLanguageLoader { override fun <T> loadMod(info: IModInfo, modClassLoader: ClassLoader, modFileScanResults: ModFileScanData): T { val ktContainer = Class.forName("thedarkcolour.kotlinforforge.KotlinModContainer", true, Thread.currentThread().contextClassLoader) - KotlinForForge.logger.debug(Logging.LOADING, "Loading KotlinModContainer from classloader ${Thread.currentThread().contextClassLoader} - got ${ktContainer.classLoader}}") - val constructor = ktContainer.getConstructor(IModInfo::class.java, String::class.java, ClassLoader::class.java, ModFileScanData::class.java)!! + logger.debug(Logging.LOADING, "Loading KotlinModContainer from classloader ${Thread.currentThread().contextClassLoader} - got ${ktContainer.classLoader}}") + val constructor = ktContainer.declaredConstructors[0]//(IModInfo::class.java, String::class.java, ClassLoader::class.java, ModFileScanData::class.java)!! return constructor.newInstance(info, className, modClassLoader, modFileScanResults) as T } } diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinModContainer.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinModContainer.kt index 3446a7a..7c8101d 100644 --- a/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinModContainer.kt +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/KotlinModContainer.kt @@ -18,8 +18,8 @@ import java.util.function.Supplier * * */ -class KotlinModContainer(info: IModInfo, className: String, loader: ClassLoader, private val scanData: ModFileScanData) : ModContainer(info) { - private val modClass: Class<*> +class KotlinModContainer(private val info: IModInfo, private val className: String, private val loader: ClassLoader, private val scanData: ModFileScanData) : ModContainer(info) { + //private val modClass: Class<*> /** Use a separate logger because KotlinForForge.logger isn't initialized yet */ private val logger = LogManager.getLogger() private lateinit var modInstance: Any @@ -27,32 +27,22 @@ class KotlinModContainer(info: IModInfo, className: String, loader: ClassLoader, init { logger.debug(Logging.LOADING, "Creating KotlinModContainer instance for {} with classLoader {} & {}", className, loader, javaClass.classLoader) - triggerMap[ModLoadingStage.CONSTRUCT] = dummy().andThen(::beforeEvent).andThen(::constructMod).andThen(::afterEvent) - triggerMap[ModLoadingStage.CREATE_REGISTRIES] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent) - triggerMap[ModLoadingStage.LOAD_REGISTRIES] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent) - triggerMap[ModLoadingStage.COMMON_SETUP] = dummy().andThen(::beforeEvent).andThen(::preInitMod).andThen(::fireEvent).andThen(::afterEvent) - triggerMap[ModLoadingStage.SIDED_SETUP] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen (::afterEvent) - triggerMap[ModLoadingStage.ENQUEUE_IMC] = dummy().andThen(::beforeEvent).andThen(::initMod).andThen(::fireEvent).andThen(::afterEvent) - triggerMap[ModLoadingStage.PROCESS_IMC] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent) - triggerMap[ModLoadingStage.COMPLETE] = dummy().andThen(::beforeEvent).andThen(::completeLoading).andThen(::fireEvent).andThen(::afterEvent) - triggerMap[ModLoadingStage.GATHERDATA] = dummy().andThen(::beforeEvent).andThen(::fireEvent).andThen(::afterEvent) + triggerMap[ModLoadingStage.CONSTRUCT] = dummy().andThen(::constructMod).andThen(::afterEvent) + triggerMap[ModLoadingStage.CREATE_REGISTRIES] = dummy().andThen(::fireEvent).andThen(::afterEvent) + triggerMap[ModLoadingStage.LOAD_REGISTRIES] = dummy().andThen(::fireEvent).andThen(::afterEvent) + triggerMap[ModLoadingStage.COMMON_SETUP] = dummy().andThen(::fireEvent).andThen(::afterEvent) + triggerMap[ModLoadingStage.SIDED_SETUP] = dummy().andThen(::fireEvent).andThen (::afterEvent) + triggerMap[ModLoadingStage.ENQUEUE_IMC] = dummy().andThen(::fireEvent).andThen(::afterEvent) + triggerMap[ModLoadingStage.PROCESS_IMC] = dummy().andThen(::fireEvent).andThen(::afterEvent) + triggerMap[ModLoadingStage.COMPLETE] = dummy().andThen(::fireEvent).andThen(::afterEvent) + triggerMap[ModLoadingStage.GATHERDATA] = dummy().andThen(::fireEvent).andThen(::afterEvent) eventBus = BusBuilder.builder().setExceptionHandler(::onEventFailed).setTrackPhases(false).build() configHandler = Optional.of(Consumer { event -> eventBus.post(event) }) val ctx = KotlinModLoadingContext(this) contextExtension = Supplier { ctx } - try { - modClass = Class.forName(className, true, loader) - logger.debug(Logging.LOADING, "Loaded kotlin modclass ${modClass.name} with ${modClass.classLoader}") - } catch (e: Throwable) { - logger.error(Logging.LOADING, "Failed to load kotlin class $className", e) - throw ModLoadingException(info, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmodclass", e) - } } - private fun completeLoading(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {} - private fun initMod(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {} private fun dummy(): Consumer<LifecycleEventProvider.LifecycleEvent> = Consumer {} - private fun beforeEvent(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {} private fun onEventFailed(iEventBus: IEventBus, event: Event, iEventListeners: Array<IEventListener>, i: Int, throwable: Throwable) { logger.error(EventBusErrorMessage(event, i, iEventListeners, throwable)) @@ -78,9 +68,16 @@ class KotlinModContainer(info: IModInfo, className: String, loader: ClassLoader, } } - private fun preInitMod(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) {} - private fun constructMod(lifecycleEvent: LifecycleEventProvider.LifecycleEvent) { + val modClass: Class<*> + try { + modClass = Class.forName(className, true, loader) + logger.debug(Logging.LOADING, "Loaded kotlin modclass ${modClass.name} with ${modClass.classLoader}") + } catch (e: Throwable) { + logger.error(Logging.LOADING, "Failed to load kotlin class $className", e) + throw ModLoadingException(info, ModLoadingStage.CONSTRUCT, "fml.modloading.failedtoloadmodclass", e) + } + try { logger.debug(Logging.LOADING, "Loading mod instance ${getModId()} of type ${modClass.name}") modInstance = modClass.kotlin.objectInstance ?: modClass.newInstance() diff --git a/src/main/kotlin/thedarkcolour/kotlinforforge/Logger.kt b/src/main/kotlin/thedarkcolour/kotlinforforge/Logger.kt new file mode 100644 index 0000000..8500863 --- /dev/null +++ b/src/main/kotlin/thedarkcolour/kotlinforforge/Logger.kt @@ -0,0 +1,5 @@ +package thedarkcolour.kotlinforforge + +import org.apache.logging.log4j.LogManager + +internal val logger = LogManager.getLogger()
\ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 0aa5be1..7f4e0be 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -33,6 +33,6 @@ Kotlin for Forge. Allows mods to use the Kotlin programming language. [[mods]] #mandatory displayName="Kotlin for Forge" # Name of mod modId="kotlinforforge" # Modid -version="1.0.0" # Version of kotlinforforge +version="1.0.1" # Version of kotlinforforge authors="TheDarkColour" # Author credits="Herobrine knows all." # Credits
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar Binary files differnew file mode 100644 index 0000000..6188572 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar.md5 b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar.md5 new file mode 100644 index 0000000..28f6ac0 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar.md5 @@ -0,0 +1 @@ +457db016e200b03b48f96c347e018581
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar.sha1 b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar.sha1 new file mode 100644 index 0000000..bc1fe35 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1-sources.jar.sha1 @@ -0,0 +1 @@ +8e79f75ebecc8162e5374708b10f9d5b1d51645a
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar Binary files differnew file mode 100644 index 0000000..4f01292 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar.md5 b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar.md5 new file mode 100644 index 0000000..e72aad8 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar.md5 @@ -0,0 +1 @@ +bb1cfad2ac5440389a0977fa7a7c3804
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar.sha1 b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar.sha1 new file mode 100644 index 0000000..3fa42e7 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.jar.sha1 @@ -0,0 +1 @@ +cfd3bc52e02ad356d63e7e178758822e01990df9
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom new file mode 100644 index 0000000..a49f9ad --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>thedarkcolour</groupId> + <artifactId>kotlinforforge</artifactId> + <version>1.0.1</version> + <dependencies> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib</artifactId> + <version>1.3.61</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-jdk7</artifactId> + <version>1.3.61</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-jdk8</artifactId> + <version>1.3.61</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-reflect</artifactId> + <version>1.3.61</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains</groupId> + <artifactId>annotations</artifactId> + <version>18.0.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlinx</groupId> + <artifactId>kotlinx-coroutines-core</artifactId> + <version>1.3.2</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlinx</groupId> + <artifactId>kotlinx-coroutines-jdk8</artifactId> + <version>1.3.2</version> + <scope>compile</scope> + </dependency> + </dependencies> +</project> diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom.md5 b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom.md5 new file mode 100644 index 0000000..aa21e77 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom.md5 @@ -0,0 +1 @@ +c71ba3d18e4841a466443210c024f8cd
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom.sha1 b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom.sha1 new file mode 100644 index 0000000..632f7c5 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/kotlinforforge-1.0.1.pom.sha1 @@ -0,0 +1 @@ +0edf44c0badeda159d3889cafe2fa63796151244
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/1.0.1/web.html b/thedarkcolour/kotlinforforge/1.0.1/web.html new file mode 100644 index 0000000..9e72ca2 --- /dev/null +++ b/thedarkcolour/kotlinforforge/1.0.1/web.html @@ -0,0 +1,15 @@ +<html> +<head><title>Index of /kotlinforforge/</title></head> +<body> +<h1>Index of /kotlinforforge/</h1><hr><pre><a href="../web.html">../</a> +<a href="kotlinforforge-1.0.1-sources.jar">kotlinforforge-1.0.1-sources.jar</a> +<a href="kotlinforforge-1.0.1-sources.jar.sha1">kotlinforforge-1.0.1-sources.jar.sha1</a> +<a href="kotlinforforge-1.0.1-sources.jar.md5">kotlinforforge-1.0.1-sources.jar.md5</a> +<a href="kotlinforforge-1.0.1.jar">kotlinforforge-1.0.1.jar</a> +<a href="kotlinforforge-1.0.1.jar.sha1">kotlinforforge-1.0.1.jar.sha1</a> +<a href="kotlinforforge-1.0.1.jar.md5">kotlinforforge-1.0.1.jar.md5</a> +<a href="kotlinforforge-1.0.1.pom">kotlinforforge-1.0.1.pom</a> +<a href="kotlinforforge-1.0.1.pom.sha1">kotlinforforge-1.0.1.pom.sha1</a> +<a href="kotlinforforge-1.0.1.pom.md5">kotlinforforge-1.0.1.pom.md5</a> +</pre><hr></body> +</html> diff --git a/thedarkcolour/kotlinforforge/maven-metadata.xml b/thedarkcolour/kotlinforforge/maven-metadata.xml index 5efbe50..b561ddd 100644 --- a/thedarkcolour/kotlinforforge/maven-metadata.xml +++ b/thedarkcolour/kotlinforforge/maven-metadata.xml @@ -3,9 +3,10 @@ <groupId>thedarkcolour</groupId> <artifactId>kotlinforforge</artifactId> <versioning> - <release>1.0.0</release> + <release>1.0.1</release> <versions> <version>1.0.0</version> + <version>1.0.1</version> </versions> </versioning> </metadata> diff --git a/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 b/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 index 6290683..6130c88 100644 --- a/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 +++ b/thedarkcolour/kotlinforforge/maven-metadata.xml.md5 @@ -1 +1 @@ -161c99cb90d13b572cf7c7df04b1812d
\ No newline at end of file +3d45a5c05f2ff300b8b07861993468b4
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 b/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 index 8bf8b5c..23c4a72 100644 --- a/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 +++ b/thedarkcolour/kotlinforforge/maven-metadata.xml.sha1 @@ -1 +1 @@ -fcb02a2a3cabeeec1b7724e9c9296dedf9174663
\ No newline at end of file +0db1ef4d548912f6d6301560ef28c786fe401f30
\ No newline at end of file diff --git a/thedarkcolour/kotlinforforge/web.html b/thedarkcolour/kotlinforforge/web.html index fa120b1..55fd39d 100644 --- a/thedarkcolour/kotlinforforge/web.html +++ b/thedarkcolour/kotlinforforge/web.html @@ -3,6 +3,7 @@ <body> <h1>Index of /kotlinforforge/</h1><hr><pre><a href="../web.html">../</a> <a href="1.0.0/web.html">1.0.0</a> +<a href="1.0.1/web.html">1.0.1</a> <a href="maven-metadata.xml">maven-metadata.xml</a> <a href="maven-metadata.xml.md5">maven-metadata.xml.md5</a> <a href="maven-metadata.xml.sha1">maven-metadata.xml.sha1</a> |