Skip to content

Commit

Permalink
Kotlin for Forge 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkcolour committed Dec 19, 2020
1 parent 7653b26 commit 668b5c3
Show file tree
Hide file tree
Showing 18 changed files with 119 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To implement in an existing project, paste the following into your build.gradle:
```groovy
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20"
}
}
Expand All @@ -40,7 +40,7 @@ repositories {
dependencies {
// Use the latest version of KotlinForForge
implementation 'thedarkcolour:kotlinforforge:1.6.2'
implementation 'thedarkcolour:kotlinforforge:1.7.0'
}
compileKotlin {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'

version = "1.6.2"
version = "1.7.0"
group = 'thedarkcolour.kotlinforforge'
archivesBaseName = 'kotlinforforge'

Expand Down
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
##Kotlin for Forge 1.7.0
- Added `registerObject` function to KDeferredRegister for getting ObjectHolderDelegate instances
without needing a cast to ObjectHolderDelegate.
- Deprecated `register` in KDeferredRegister
- Fixed KReflect sometimes not showing up on the Maven.
- Updated to Kotlin 1.4.21, Updated to coroutines 1.4.2, Updated to JetBrains annotations 20.1.0

##Kotlin for Forge 1.6.2
- Fixed errors in KotlinEventBus with certain Lambda syntax

##Kotlin for Forge 1.6.1
- Removed inline modifier for functions `runForDist`, `runWhenOn`, and `callWhenOn` in Forge.kt.
- Changed the `AutoKotlinEventBusSubscriber` to not crash when loading client only subscribers with client only members.
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
kotlin.code.style=official
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
kotlin_version=1.4.10
coroutines_version = 1.3.9
annotations_version = 20.0.0
kotlin_version=1.4.21
coroutines_version = 1.4.2
annotations_version = 20.1.0
9 changes: 8 additions & 1 deletion src/main/kotlin/thedarkcolour/kotlinforforge/forge/Forge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ private class SidedDelegate<T>(private val clientValue: () -> T, private val ser
* @since 1.4.0
* [ObjectHolderDelegate] can now be used with the [KDeferredRegister].
*
* @since 1.7.0
* [ObjectHolderDelegate] now implements () -> T.
*
* @param T the type of object this delegates to
* @property registryName the registry name of the object this delegate references
* @property registry the registry the object of this delegate is in
Expand All @@ -255,7 +258,7 @@ private class SidedDelegate<T>(private val clientValue: () -> T, private val ser
public data class ObjectHolderDelegate<T : IForgeRegistryEntry<in T>>(
private val registryName: ResourceLocation,
private val registry: IForgeRegistry<*>,
) : ReadOnlyProperty<Any?, T>, Consumer<Predicate<ResourceLocation>>, Supplier<T> {
) : ReadOnlyProperty<Any?, T>, Consumer<Predicate<ResourceLocation>>, Supplier<T>, () -> T {
/**
* Should be initialized by [accept]. If you don't register
* a value for [registryName] during the appropriate registry event
Expand All @@ -275,6 +278,10 @@ public data class ObjectHolderDelegate<T : IForgeRegistryEntry<in T>>(
return value
}

override fun invoke(): T {
return value
}

/**
* Refreshes the value of this ObjectHolder.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class KDeferredRegister<V : IForgeRegistryEntry<V>>(
}
}


/**
* Adds a registry object to this deferred registry.
*
Expand All @@ -56,7 +57,7 @@ public class KDeferredRegister<V : IForgeRegistryEntry<V>>(
*
* @return A new [ObjectHolderDelegate] with the given registry name and value
*/
public fun <T : V> register(name: String, supplier: () -> T): ReadOnlyProperty<Any?, T> {
public fun <T : V> registerObject(name: String, supplier: () -> T): ObjectHolderDelegate<T> {
val key = ResourceLocation(modid, name)
val a = ObjectHolderDelegate<T>(key, registry)

Expand All @@ -65,6 +66,17 @@ public class KDeferredRegister<V : IForgeRegistryEntry<V>>(
return a
}

/**
* Older function that only returns a property delegate.
*/
@Deprecated(
message = "Use `registerObject` for ObjectHolderDelegate return type",
replaceWith = ReplaceWith("registerObject(name, supplier)")
)
public fun <T : V> register(name: String, supplier: () -> T): ReadOnlyProperty<Any?, T> {
return registerObject(name, supplier)
}

public fun getEntries(): Set<ObjectHolderDelegate<out V>> {
return entries.keys
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ce0044bc8b823ae0954bcbf4474d6faa
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20d9f97680789a1949b6620f42f3b4063eda9b2f
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ee41e56cfde6cb4366dfd308b9c9a909
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c4962f0a8a86adf71b2b51192509c4b36da4d225
53 changes: 53 additions & 0 deletions thedarkcolour/kotlinforforge/1.7.0/kotlinforforge-1.7.0.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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.7.0</version>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.4.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk7</artifactId>
<version>1.4.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.4.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.4.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.4.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-jdk8</artifactId>
<version>1.4.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16fc3646bcc58cd8b2ecd2c82a79847a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cb5ad553d46be42d6bb40a17cbc3668bf17007bf
20 changes: 20 additions & 0 deletions thedarkcolour/kotlinforforge/1.7.0/web.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html lang="HTML5">
<link rel="stylesheet" href="../../style.css">
<head><title>Index of /1.7.0/</title></head>
<body>
<h1>Index of /kotlinforforge/</h1>
<hr>
<pre><a href="../web.html">../</a>
<a href="kotlinforforge-1.7.0-sources.jar">kotlinforforge-1.7.0-sources.jar</a>
<a href="kotlinforforge-1.7.0-sources.jar.sha1">kotlinforforge-1.7.0-sources.jar.sha1</a>
<a href="kotlinforforge-1.7.0-sources.jar.md5">kotlinforforge-1.7.0-sources.jar.md5</a>
<a href="kotlinforforge-1.7.0.jar">kotlinforforge-1.7.0.jar</a>
<a href="kotlinforforge-1.7.0.jar.sha1">kotlinforforge-1.7.0.jar.sha1</a>
<a href="kotlinforforge-1.7.0.jar.md5">kotlinforforge-1.7.0.jar.md5</a>
<a href="kotlinforforge-1.7.0.pom">kotlinforforge-1.7.0.pom</a>
<a href="kotlinforforge-1.7.0.pom.sha1">kotlinforforge-1.7.0.pom.sha1</a>
<a href="kotlinforforge-1.7.0.pom.md5">kotlinforforge-1.7.0.pom.md5</a>
</pre>
<hr>
</body>
</html>
3 changes: 2 additions & 1 deletion thedarkcolour/kotlinforforge/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>thedarkcolour</groupId>
<artifactId>kotlinforforge</artifactId>
<versioning>
<release>1.6.2</release>
<release>1.7.0</release>
<versions>
<version>1.0.0</version>
<version>1.0.1</version>
Expand All @@ -19,6 +19,7 @@
<version>1.6.0</version>
<version>1.6.1</version>
<version>1.6.2</version>
<version>1.7.0</version>
</versions>
</versioning>
</metadata>
1 change: 1 addition & 0 deletions thedarkcolour/kotlinforforge/web.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ <h1>Index of /kotlinforforge/</h1>
<a href="1.6.0/web.html">1.6.0</a>
<a href="1.6.1/web.html">1.6.1</a>
<a href="1.6.2/web.html">1.6.2</a>
<a href="1.7.0/web.html">1.7.0</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>
Expand Down

0 comments on commit 668b5c3

Please sign in to comment.