Compare commits
3 Commits
6272e753e2
...
61aa3abdfa
Author | SHA1 | Date | |
---|---|---|---|
61aa3abdfa | |||
11e71361f7 | |||
7278a699aa |
@ -11,7 +11,6 @@
|
|||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/gson" />
|
<option value="$PROJECT_DIR$/gson" />
|
||||||
<option value="$PROJECT_DIR$/guava" />
|
<option value="$PROJECT_DIR$/guava" />
|
||||||
<option value="$PROJECT_DIR$/kommons-mc" />
|
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=3.8.0
|
projectVersion=3.9.1
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -1,72 +0,0 @@
|
|||||||
|
|
||||||
// this whole shit is required because you can't have non-mods be
|
|
||||||
// loaded on the GAME layer in Minecraft Forge, and hence,
|
|
||||||
// Kommons can not see Kotlin at runtime (because Kommons being
|
|
||||||
// loaded with system classloader, while Kotlin is loaded by
|
|
||||||
// FML classloader).
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
kotlin("jvm")
|
|
||||||
id("net.minecraftforge.gradle").version("[6.0.14,6.2)")
|
|
||||||
`maven-publish`
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
minecraft("net.minecraftforge:forge:1.20.2-48.1.0")
|
|
||||||
|
|
||||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
|
||||||
|
|
||||||
implementation(project(":")) { setTransitive(false) }
|
|
||||||
implementation(project(":gson")) { setTransitive(false) }
|
|
||||||
implementation(project(":guava")) { setTransitive(false) }
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.jar {
|
|
||||||
dependsOn(":jar")
|
|
||||||
dependsOn(":gson:jar")
|
|
||||||
dependsOn(":guava:jar")
|
|
||||||
from(zipTree(project(":").tasks.jar.get().outputs.files.asPath))
|
|
||||||
from(zipTree(project(":gson").tasks.jar.get().outputs.files.asPath))
|
|
||||||
from(zipTree(project(":guava").tasks.jar.get().outputs.files.asPath))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.sourceJar {
|
|
||||||
from(project(":").sourceSets.main.get().allSource)
|
|
||||||
from(project(":gson").sourceSets.main.get().allSource)
|
|
||||||
from(project(":guava").sourceSets.main.get().allSource)
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
mappings("official", "1.20.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
val projectVersion: String by project
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("mavenJava") {
|
|
||||||
from(components["java"])
|
|
||||||
artifact(tasks["sourceJar"])
|
|
||||||
artifactId = "kommons-mc"
|
|
||||||
|
|
||||||
pom {
|
|
||||||
dependencies {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(ProcessResources::class.java) {
|
|
||||||
val replaceProperties = mapOf("mod_version" to projectVersion)
|
|
||||||
inputs.properties(replaceProperties)
|
|
||||||
|
|
||||||
filesMatching(arrayListOf("META-INF/mods.toml")) {
|
|
||||||
expand(replaceProperties)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package ru.dbotthepony.kommons;
|
|
||||||
|
|
||||||
import kotlin.KotlinVersion;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
@Mod("kommons")
|
|
||||||
public class KommonsMod {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
private static void checkIfKotlinIsInstalled() {
|
|
||||||
if (!KotlinVersion.CURRENT.isAtLeast(1, 8, 0)) {
|
|
||||||
throw new UnsupportedClassVersionError("Installed kotlin version is " + KotlinVersion.CURRENT + ", when at least 1.9.0 is required.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public KommonsMod() {
|
|
||||||
try {
|
|
||||||
checkIfKotlinIsInstalled();
|
|
||||||
} catch (Throwable err) {
|
|
||||||
if (err instanceof NoClassDefFoundError) {
|
|
||||||
for (int i = 0; i < 16; i++)
|
|
||||||
LOGGER.fatal("Kommons requires Kotlin to be installed, get Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge");
|
|
||||||
|
|
||||||
LOGGER.fatal("Kommons requires Kotlin to be installed, get Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge", err);
|
|
||||||
throw new RuntimeException("Kommons requires Kotlin to be installed, get Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
|
||||||
LOGGER.fatal("Kommons' Kotlin version is not satisfied, get newer Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge");
|
|
||||||
|
|
||||||
LOGGER.fatal("Kommons' Kotlin version is not satisfied, get newer Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge", err);
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGGER.info("Kommons seems to be loaded");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
modLoader="javafml"
|
|
||||||
loaderVersion="[41,)"
|
|
||||||
license="2 Clause BSD"
|
|
||||||
[[mods]] #mandatory
|
|
||||||
modId="kommons"
|
|
||||||
version="${mod_version}"
|
|
||||||
displayName="Kommons"
|
|
||||||
authors="DBotThePony"
|
|
||||||
description='''Adapter "mod" to load my library "Kommons" in minecraft environment'''
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"pack": {
|
|
||||||
"description": "Kommons resources",
|
|
||||||
"pack_format": 18
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,4 +22,3 @@ plugins {
|
|||||||
rootProject.name = "kommons"
|
rootProject.name = "kommons"
|
||||||
include("guava")
|
include("guava")
|
||||||
include("gson")
|
include("gson")
|
||||||
include("kommons-mc")
|
|
||||||
|
@ -2,6 +2,7 @@ package ru.dbotthepony.kommons.collect
|
|||||||
|
|
||||||
import ru.dbotthepony.kommons.util.KOptional
|
import ru.dbotthepony.kommons.util.KOptional
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import java.util.Collections.emptyIterator
|
||||||
import java.util.NoSuchElementException
|
import java.util.NoSuchElementException
|
||||||
import java.util.function.Predicate
|
import java.util.function.Predicate
|
||||||
import java.util.stream.Collector
|
import java.util.stream.Collector
|
||||||
@ -377,24 +378,6 @@ fun <T> Iterator<T>.maybe(): T? {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
private object EmptyIterator : MutableIterator<Nothing> {
|
|
||||||
override fun hasNext(): Boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun next(): Nothing {
|
|
||||||
throw NoSuchElementException()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun remove() {
|
|
||||||
throw NoSuchElementException()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> emptyIterator(): MutableIterator<T> {
|
|
||||||
return EmptyIterator as MutableIterator<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <T> iteratorOf(value: T): Iterator<T> {
|
fun <T> iteratorOf(value: T): Iterator<T> {
|
||||||
return object : Iterator<T> {
|
return object : Iterator<T> {
|
||||||
private var next = true
|
private var next = true
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package ru.dbotthepony.kommons.test
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntComparators
|
||||||
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import ru.dbotthepony.kommons.collect.addSorted
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
object ComparatorTests {
|
||||||
|
@Test
|
||||||
|
@DisplayName("Comparator tests")
|
||||||
|
fun test() {
|
||||||
|
val sortedList = mutableListOf(1, 4, 6)
|
||||||
|
sortedList.addSorted(2, IntComparators.NATURAL_COMPARATOR)
|
||||||
|
sortedList.addSorted(3, IntComparators.NATURAL_COMPARATOR)
|
||||||
|
sortedList.addSorted(7, IntComparators.NATURAL_COMPARATOR)
|
||||||
|
sortedList.addSorted(-1, IntComparators.NATURAL_COMPARATOR)
|
||||||
|
|
||||||
|
assertEquals(mutableListOf(-1, 1, 2, 3, 4, 6, 7), sortedList)
|
||||||
|
|
||||||
|
val rand = Random()
|
||||||
|
val sorted2 = ArrayList<Int>()
|
||||||
|
|
||||||
|
for (i in 0 .. 100) {
|
||||||
|
sorted2.addSorted(rand.nextInt(-100, 100), IntComparators.NATURAL_COMPARATOR)
|
||||||
|
}
|
||||||
|
|
||||||
|
val sorted22 = ArrayList(sorted2)
|
||||||
|
sorted22.sort()
|
||||||
|
|
||||||
|
assertEquals(sorted22, sorted2)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user