Skip to content

Commit d4ad1ea

Browse files
committed
feat: Migrate to Paper API 1.20+
1 parent 0c07afc commit d4ad1ea

File tree

18 files changed

+111
-153
lines changed

18 files changed

+111
-153
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
## [Unreleased]
22

3+
### Paper-first
4+
5+
Keeping the plugin compatible both with Paper and Spigot consumes a lot of time.
6+
Now, Mimic is Paper-first as it is the most popular platform.
7+
This means that compatibility with Spigot is not guaranteed.
8+
9+
To reduce the maintenance burden, support for versions older than 1.20 has been dropped.
10+
Java 17 is required.
11+
312
### Added command `/mimic config`
413

514
> [!NOTE]

gradle/libs.versions.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[versions]
22

3+
paper = "1.20-R0.1-SNAPSHOT"
34
kotlin = "2.1.20"
45
kotlinx-binaryCompatibilityValidator = "0.17.0"
56
kotlinx-serialization = "1.8.1"
67
dokka = "1.9.10"
78
annotations = "26.0.2"
89

910
commandapi = "9.7.0"
10-
adventure = "4.3.1"
1111
bstats = "3.1.0"
1212

1313
skillapi = "3.102"
@@ -27,13 +27,12 @@ gradlePlugin-versions = "0.50.0"
2727

2828
[libraries]
2929

30-
spigot-api = "org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT"
30+
paperApi = { module = "io.papermc.paper:paper-api", version.ref = "paper" }
3131
serialization-hocon = { module = "org.jetbrains.kotlinx:kotlinx-serialization-hocon", version.ref = "kotlinx-serialization" }
3232
annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" }
3333

3434
commandapi = { module = "dev.jorel:commandapi-bukkit-core", version.ref = "commandapi" }
3535
commandapi-kotlin = { module = "dev.jorel:commandapi-bukkit-kotlin", version.ref = "commandapi" }
36-
adventure = { module = "net.kyori:adventure-platform-bukkit", version.ref = "adventure" }
3736
bstats = { module = "org.bstats:bstats-bukkit", version.ref = "bstats" }
3837

3938
rpgplugins-skillapi = { module = "com.sucy:SkillAPI", version.ref = "skillapi" }

mimic-bukkit-api/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ plugins {
66
description = "Abstraction API for Bukkit RPG plugins"
77

88
repositories {
9-
maven(url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots")
9+
maven("https://repo.papermc.io/repository/maven-public/")
1010
}
1111

1212
dependencies {
1313
api(projects.mimicApi)
1414
compileOnly(libs.annotations)
15-
compileOnly(libs.spigot.api) { isTransitive = false }
15+
compileOnly(libs.paperApi)
1616
}

mimic-bukkit/build.gradle.kts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ru.endlesscode.bukkitgradle.dependencies.aikar
22
import ru.endlesscode.bukkitgradle.dependencies.codemc
3+
import ru.endlesscode.bukkitgradle.dependencies.papermc
34

45
plugins {
56
commons
@@ -9,10 +10,10 @@ plugins {
910
kotlin("plugin.serialization")
1011
}
1112

12-
description = "Bukkit plugin with implementations of Mimic APIs"
13+
description = "Bukkit plugin implementing Mimic APIs"
1314

1415
bukkit {
15-
apiVersion = "1.16.5"
16+
apiVersion = "1.20"
1617

1718
plugin {
1819
name = "Mimic"
@@ -44,6 +45,7 @@ tasks.runServer {
4445
}
4546

4647
repositories {
48+
papermc()
4749
maven(url = "https://gitlab.com/endlesscodegroup/mvn-repo/raw/master/")
4850
maven(url = "https://mvn.lumine.io/repository/maven-public/") {
4951
content {
@@ -66,12 +68,11 @@ repositories {
6668
dependencies {
6769
api(projects.mimicBukkitApi)
6870

69-
compileOnly(libs.spigot.api) { isTransitive = false }
71+
compileOnly(libs.paperApi)
7072
compileOnly(libs.annotations)
7173

7274
implementation(libs.bstats)
7375
implementation(libs.serialization.hocon)
74-
implementation(libs.adventure)
7576

7677
compileOnly(libs.commandapi)
7778
compileOnly(libs.commandapi.kotlin)
@@ -80,9 +81,9 @@ dependencies {
8081
// From libs/ directory
8182
compileOnly(":CustomItemsAPI")
8283
compileOnly(":QuantumRPG:5.10.2")
83-
compileOnly(":NexEngine:2.0.3") // Do not update NexEngine. QuantumRpgWrapper cannot compile with higher version
84+
compileOnly(":NexEngine:2.0.3") // Do not update NexEngine. QuantumRpgWrapper cannot compile with a higher version
8485

85-
testImplementation(libs.spigot.api)
86+
testImplementation(libs.paperApi)
8687
testImplementation(libs.rpgplugins.skillapi)
8788
}
8889

@@ -92,6 +93,12 @@ kotlin {
9293
}
9394
}
9495

96+
tasks.test {
97+
javaLauncher = javaToolchains.launcherFor {
98+
languageVersion = JavaLanguageVersion.of(17)
99+
}
100+
}
101+
95102
tasks.shadowJar {
96103
dependencies {
97104
exclude(dependency("org.jetbrains:annotations:.*"))
@@ -101,8 +108,6 @@ tasks.shadowJar {
101108
relocate("kotlin", "$shadePackage.kotlin")
102109
relocate("org.bstats", "$shadePackage.bstats")
103110
relocate("com.typesafe.config", "$shadePackage.hocon")
104-
relocate("net.kyori.adventure", "$shadePackage.adventure")
105-
relocate("net.kyori.examination", "$shadePackage.examination")
106111

107112
exclude("META-INF/*.kotlin_module")
108113
exclude("META-INF/com.android.tools/**")

mimic-bukkit/src/main/kotlin/MimicPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import ru.endlesscode.mimic.util.checkClassesLoaded
5757
/** Main class of the plugin. */
5858
public class MimicPlugin : JavaPlugin() {
5959

60-
private val isReleased = !description.version.endsWith("-SNAPSHOT")
60+
private val isReleased = !pluginMeta.version.endsWith("-SNAPSHOT")
6161

6262
private val config: MimicConfig by lazy { MimicConfig(this) }
6363
private val mimic: Mimic by lazy { MimicImpl(servicesManager, config) }

mimic-bukkit/src/main/kotlin/ServicesRegistrationListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal class ServicesRegistrationListener(
2626
Log.w(
2727
"""
2828
Service ${serviceClass.name} with id '${service.id}' registered in deprecated way.
29-
Please ask the ${plugin.name} authors (${plugin.description.authors.joinToString()}) to migrate
29+
Please ask the ${plugin.name} authors (${plugin.pluginMeta.authors.joinToString()}) to migrate
3030
to the new service registration API introduced in Mimic v0.7:
3131
https://github.com/EndlessCodeGroup/Mimic/releases/tag/v0.7
3232
""".trimIndent()

mimic-bukkit/src/main/kotlin/command/ConfigCommand.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import dev.jorel.commandapi.kotlindsl.anyExecutor
66
import dev.jorel.commandapi.kotlindsl.multiLiteralArgument
77
import dev.jorel.commandapi.kotlindsl.stringArgument
88
import dev.jorel.commandapi.kotlindsl.subcommand
9-
import net.kyori.adventure.platform.bukkit.BukkitAudiences
109
import org.bukkit.command.CommandSender
1110
import ru.endlesscode.mimic.ExperimentalMimicApi
1211
import ru.endlesscode.mimic.Mimic
@@ -24,11 +23,10 @@ import ru.endlesscode.mimic.config.MimicConfig
2423
internal fun CommandAPICommand.configSubcommand(
2524
mimic: Mimic,
2625
config: MimicConfig,
27-
audiences: BukkitAudiences,
2826
) = subcommand("config") {
2927
val showConfig = { sender: CommandSender ->
3028
val message = buildConfigMessage(mimic, config)
31-
audiences.sender(sender).sendMessage(message)
29+
sender.sendMessage(message)
3230
}
3331

3432
withShortDescription("Show Mimic config")

mimic-bukkit/src/main/kotlin/command/MainCommand.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package ru.endlesscode.mimic.command
22

33
import dev.jorel.commandapi.executors.CommandExecutor
44
import dev.jorel.commandapi.kotlindsl.commandAPICommand
5-
import net.kyori.adventure.platform.bukkit.BukkitAudiences
65
import net.kyori.adventure.text.format.NamedTextColor
76
import ru.endlesscode.mimic.Mimic
87
import ru.endlesscode.mimic.config.MimicConfig
@@ -16,28 +15,27 @@ internal fun registerCommand(
1615
mimic: Mimic,
1716
config: MimicConfig,
1817
pluginFullName: String,
19-
audiences: BukkitAudiences,
2018
) = commandAPICommand("mimic") {
2119
withPermission("mimic.admin")
2220
withShortDescription("Show info about Mimic")
23-
executes(infoExecutor(audiences, pluginFullName))
21+
executes(infoExecutor(pluginFullName))
2422

25-
configSubcommand(mimic, config, audiences)
23+
configSubcommand(mimic, config)
2624
levelSystemSubcommand(mimic)
2725
classSystemSubcommand(mimic)
2826
inventorySubcommand(mimic)
2927
itemsSubcommand(mimic.getItemsRegistry())
3028
}
3129

32-
private fun infoExecutor(audiences: BukkitAudiences, pluginFullName: String) = CommandExecutor { sender, _ ->
30+
private fun infoExecutor(pluginFullName: String) = CommandExecutor { sender, _ ->
3331
val message = buildTextComponent {
3432
appendLine(pluginFullName, NamedTextColor.GREEN)
3533
color(NamedTextColor.GRAY)
3634
append("Use ")
3735
append(createClickableCommand())
3836
append(" to see or change configs")
3937
}
40-
audiences.sender(sender).sendMessage(message)
38+
sender.sendMessage(message)
4139
}
4240

4341
private fun createClickableCommand() = buildTextComponent {
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package ru.endlesscode.mimic.command
22

33
import dev.jorel.commandapi.CommandAPI
4-
import net.kyori.adventure.platform.bukkit.BukkitAudiences
54
import org.bukkit.plugin.java.JavaPlugin
65
import ru.endlesscode.mimic.Mimic
76
import ru.endlesscode.mimic.config.MimicConfig
@@ -10,7 +9,6 @@ import ru.endlesscode.mimic.internal.Log
109
internal class MimicCommands {
1110

1211
private var registered = false
13-
private var audiences: BukkitAudiences? = null
1412

1513
fun register(
1614
plugin: JavaPlugin,
@@ -28,22 +26,14 @@ internal class MimicCommands {
2826
}
2927

3028
registered = true
31-
audiences = BukkitAudiences.create(plugin)
32-
3329
registerCommand(
3430
mimic = mimic,
3531
config = config,
36-
pluginFullName = plugin.description.fullName,
37-
audiences = checkNotNull(audiences),
32+
pluginFullName = plugin.pluginMeta.displayName,
3833
)
3934
}
4035

4136
fun unregister() {
42-
if (registered) {
43-
CommandAPI.unregister("mimic")
44-
audiences?.close()
45-
audiences = null
46-
}
37+
if (registered) CommandAPI.unregister("mimic")
4738
}
48-
4939
}

mimic-bukkit/src/main/kotlin/impl/mimic/SafeBukkitItemsRegistry.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ private fun logImplementationError(provider: ItemsRegistryProvider, throwable: T
7171
Log.w(throwable,
7272
"Error in ItemsRegistry '${provider.registry.id}' " +
7373
"implemented via ${provider.plugin}. " +
74-
"Please, report it to ${provider.plugin.description.authors.joinToString()}.")
74+
"Please, report it to ${provider.plugin.pluginMeta.authors.joinToString()}.")
7575
}

0 commit comments

Comments
 (0)