Skip to content

Commit 8b7b0f7

Browse files
committed
Updated to K2 Compiler
1 parent 7602299 commit 8b7b0f7

19 files changed

+45
-40
lines changed

build.gradle.kts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23

34
buildscript {
@@ -6,22 +7,22 @@ buildscript {
67
}
78

89
dependencies {
9-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
10+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0")
1011
}
1112
}
1213

1314
plugins {
1415
java
1516
id("java-library")
16-
id("io.github.goooler.shadow") version "8.1.7"
17+
id("com.gradleup.shadow") version "8.3.5"
1718
id("maven-publish")
1819
}
1920

2021
allprojects {
2122
apply(plugin = "kotlin")
2223
apply(plugin = "java")
2324
apply(plugin = "maven-publish")
24-
apply(plugin = "io.github.goooler.shadow")
25+
apply(plugin = "com.gradleup.shadow")
2526

2627
repositories {
2728
mavenLocal() // TODO: REMOVE
@@ -37,7 +38,7 @@ allprojects {
3738

3839
dependencies {
3940
compileOnly("org.jetbrains:annotations:23.0.0")
40-
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.9.20")
41+
compileOnly(kotlin("stdlib", version = "2.1.0"))
4142

4243
compileOnly(fileTree("lib") { include("*.jar") })
4344
}
@@ -68,8 +69,8 @@ allprojects {
6869
}
6970

7071
withType<KotlinCompile> {
71-
kotlinOptions {
72-
jvmTarget = "17"
72+
compilerOptions {
73+
jvmTarget.set(JvmTarget.JVM_17)
7374
}
7475
}
7576

core/common/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounters.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package com.willfp.libreforge.counters.bind
33
import com.willfp.eco.core.map.listMap
44
import com.willfp.libreforge.counters.Accumulator
55
import com.willfp.libreforge.counters.Counter
6+
import net.kyori.adventure.chat.ChatType.Bound
67

78
internal object BoundCounters {
89
private val bindings = listMap<Counter, BoundCounter>()
910

1011
fun bind(counter: Counter, accumulator: Accumulator) {
11-
bindings[counter] += BoundCounter(counter, accumulator)
12+
bindings[counter].add(BoundCounter(counter, accumulator))
1213
}
1314

1415
fun unbind(counter: Counter) {

core/common/src/main/kotlin/com/willfp/libreforge/effects/EffectContext.kt

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.willfp.libreforge.mutators.MutatorList
99
* EffectContext exists in order to abstract out some compile logic between
1010
* element compilation and rich chain compilation.
1111
*/
12+
@ConsistentCopyVisibility
1213
data class EffectContext internal constructor(
1314
val arguments: EffectArgumentList,
1415
val conditions: ConditionList,

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ object EffectAddHolder : Effect<HolderTemplate>("add_holder") {
4242
val duration = config.getIntFromExpression("duration", data).coerceAtLeast(1)
4343
val holder = compileData.toHolder().nest(data.holder)
4444

45-
holders[dispatcher.uuid] += holder
45+
holders[dispatcher.uuid].add(holder)
4646

4747
plugin.scheduler.runLater(duration.toLong()) {
48-
holders[dispatcher.uuid] -= holder
48+
holders[dispatcher.uuid].remove(holder)
4949
if (holders[dispatcher.uuid].isEmpty()) {
50-
holders -= dispatcher.uuid
50+
holders.remove(dispatcher.uuid)
5151
}
5252
}
5353

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ object EffectAddHolderToVictim : Effect<HolderTemplate>("add_holder_to_victim")
4444
val duration = config.getIntFromExpression("duration", data).coerceAtLeast(1)
4545
val holder = compileData.toHolder().nest(data.holder)
4646

47-
holders[player.uniqueId] += holder
47+
holders[player.uniqueId].add(holder)
4848

4949
plugin.scheduler.runLater(duration.toLong()) {
50-
holders[player.uniqueId] -= holder
50+
holders[player.uniqueId].remove(holder)
5151
if (holders[player.uniqueId].isEmpty()) {
52-
holders -= player.uniqueId
52+
holders.remove(player.uniqueId)
5353
}
5454
}
5555

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ object EffectFeatherStep : Effect<NoCompileData>("feather_step") {
2323
holder: ProvidedHolder,
2424
compileData: NoCompileData
2525
) {
26-
players[dispatcher.uuid] += identifiers.uuid
26+
players[dispatcher.uuid].add(identifiers.uuid)
2727
}
2828

2929
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {
30-
players[dispatcher.uuid] -= identifiers.uuid
30+
players[dispatcher.uuid].remove(identifiers.uuid)
3131
}
3232

3333
@EventHandler(ignoreCancelled = true)

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ object EffectFlight : Effect<NoCompileData>("flight") {
2525
) {
2626
val player = dispatcher.get<Player>() ?: return
2727

28-
players[player.uniqueId] += identifiers.uuid
28+
players[player.uniqueId].add(identifiers.uuid)
2929
player.allowFlight = players[player.uniqueId].isNotEmpty()
3030
}
3131

3232
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {
3333
val player = dispatcher.get<Player>() ?: return
3434

35-
players[player.uniqueId] -= identifiers.uuid
35+
players[player.uniqueId].remove(identifiers.uuid)
3636
player.allowFlight = players[player.uniqueId].isNotEmpty()
3737
}
3838
}

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ object EffectKeepInventory : Effect<NoCompileData>("keep_inventory") {
2121
holder: ProvidedHolder,
2222
compileData: NoCompileData
2323
) {
24-
players[dispatcher.uuid] += identifiers.uuid
24+
players[dispatcher.uuid].add(identifiers.uuid)
2525
}
2626

2727
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {
28-
players[dispatcher.uuid] -= identifiers.uuid
28+
players[dispatcher.uuid].remove(identifiers.uuid)
2929
}
3030

3131
@EventHandler(ignoreCancelled = true)

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepLevel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ object EffectKeepLevel : Effect<NoCompileData>("keep_level") {
2121
holder: ProvidedHolder,
2222
compileData: NoCompileData
2323
) {
24-
players[dispatcher.uuid] += identifiers.uuid
24+
players[dispatcher.uuid].add(identifiers.uuid)
2525
}
2626

2727
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {
28-
players[dispatcher.uuid] -= identifiers.uuid
28+
players[dispatcher.uuid].remove(identifiers.uuid)
2929
}
3030

3131
@EventHandler(ignoreCancelled = true)

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ object EffectRapidBows : Effect<NoCompileData>("rapid_bows") {
3737
holder: ProvidedHolder,
3838
compileData: NoCompileData
3939
) {
40-
modifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) {
40+
modifiers[dispatcher.uuid].add(IdentifiedModifier(identifiers.uuid) {
4141
config.getDoubleFromExpression("percent_faster", dispatcher.get())
42-
}
42+
})
4343
}
4444

4545
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ object EffectReplantCrops : Effect<NoCompileData>("replant_crops") {
3636
holder: ProvidedHolder,
3737
compileData: NoCompileData
3838
) {
39-
players[dispatcher.uuid] += ReplantConfig(
39+
players[dispatcher.uuid].add(ReplantConfig(
4040
identifiers.uuid,
4141
config.getBool("consume_seeds"),
4242
config.getBool("only_fully_grown")
43-
)
43+
))
4444
}
4545

4646
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ object EffectTelekinesis : Effect<NoCompileData>("telekinesis") {
3232
holder: ProvidedHolder,
3333
compileData: NoCompileData
3434
) {
35-
players[dispatcher.uuid] += identifiers.uuid
35+
players[dispatcher.uuid].add(identifiers.uuid)
3636
}
3737

3838
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {
39-
players[dispatcher.uuid] -= identifiers.uuid
39+
players[dispatcher.uuid].remove(identifiers.uuid)
4040
}
4141

4242
override fun postRegister() {

core/common/src/main/kotlin/com/willfp/libreforge/effects/impl/bossbar/BossBars.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object BossBars {
1313
return
1414
}
1515

16-
registry[bossBar.id] += bossBar
16+
registry[bossBar.id].add(bossBar)
1717
val player = Bukkit.getPlayer(bossBar.uuid) ?: return
1818
bossBar.bossBar.addViewer(player.asAudience())
1919
}

core/common/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ abstract class ChanceMultiplierEffect(id: String) : Effect<NoCompileData>(id) {
2929
holder: ProvidedHolder,
3030
compileData: NoCompileData
3131
) {
32-
modifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) {
32+
modifiers[dispatcher.uuid].add(IdentifiedModifier(identifiers.uuid) {
3333
config.getDoubleFromExpression("chance", dispatcher.get<Player>()!!)
34-
}
34+
})
3535
}
3636

3737
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {

core/common/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ abstract class MultiMultiplierEffect<T : Any>(id: String) : Effect<NoCompileData
3939
val elements = config.getStrings(key).mapNotNull { getElement(it) }
4040

4141
for (element in elements) {
42-
modifiers[dispatcher.uuid][element] += IdentifiedModifier(identifiers.uuid) {
42+
modifiers[dispatcher.uuid][element].add(IdentifiedModifier(identifiers.uuid) {
4343
config.getDoubleFromExpression("multiplier", dispatcher.get())
44-
}
44+
})
4545
}
4646
} else {
47-
globalModifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) {
47+
globalModifiers[dispatcher.uuid].add(IdentifiedModifier(identifiers.uuid) {
4848
config.getDoubleFromExpression("multiplier", dispatcher.get())
49-
}
49+
})
5050
}
5151
}
5252

core/common/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ abstract class MultiplierEffect(id: String) : Effect<NoCompileData>(id) {
2828
holder: ProvidedHolder,
2929
compileData: NoCompileData
3030
) {
31-
modifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) {
31+
modifiers[dispatcher.uuid].add(IdentifiedModifier(identifiers.uuid) {
3232
config.getDoubleFromExpression("multiplier", dispatcher.get<Player>()!!)
33-
}
33+
})
3434
}
3535

3636
override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) {

core/common/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class EffectGivePermission(
3838

3939
val permission = config.getString("permission")
4040

41-
permissions[dispatcher.uuid] += GivenPermission(permission, identifiers.uuid)
41+
permissions[dispatcher.uuid].add(GivenPermission(permission, identifiers.uuid))
4242
handler.playerAdd(player, permission)
4343
}
4444

core/common/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class DispatchedTriggerFactory(
3737
return null
3838
}
3939

40-
dispatcherTriggers[dispatcher.uuid] += hash
40+
dispatcherTriggers[dispatcher.uuid].add(hash)
4141
return DispatchedTrigger(dispatcher, trigger, data.copy(dispatcher = dispatcher))
4242
}
4343

core/modern/build.gradle.kts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
dependencies {
24
compileOnly(project(":core:common"))
35

@@ -10,8 +12,8 @@ tasks {
1012
}
1113

1214
compileKotlin {
13-
kotlinOptions {
14-
jvmTarget = "21"
15+
compilerOptions {
16+
jvmTarget.set(JvmTarget.JVM_21)
1517
}
1618
}
1719
}

0 commit comments

Comments
 (0)