From 218a6d73f119de5300d51f9de24b73a4e18540d2 Mon Sep 17 00:00:00 2001 From: Drex Date: Mon, 19 Jun 2023 05:12:31 +0200 Subject: [PATCH] Update to 1.20 (#63) --- libs.versions.toml | 17 ++++--- .../extensions/MemberCommandsExtension.kt | 2 +- .../extensions/inline/DiscordCommandOutput.kt | 2 +- .../extensions/linking/LinkCommand.kt | 45 ++++++++++++------- .../extensions/linking/LinkingExtension.kt | 2 +- src/main/resources/fabric.mod.json | 4 +- 6 files changed, 42 insertions(+), 30 deletions(-) diff --git a/libs.versions.toml b/libs.versions.toml index 554b606..78ea79a 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -1,23 +1,22 @@ [versions] -minecraft = "1.19.3" -fabric-loader = "0.14.11" -yarn-mappings = "1.19.3+build.2" +minecraft = "1.20-rc1" +fabric-loader = "0.14.21" +yarn-mappings = "1.20-rc1+build.2" -fabric-api = "0.68.1+1.19.3" +fabric-api = "0.83.0+1.20" # Kotlin -kotlin = "1.7.22" -fabric-kotlin = "1.8.7+kotlin.1.7.22" +fabric-kotlin = "1.9.4+kotlin.1.8.21" # Discord -kord-extensions = "1.5.5-SNAPSHOT" +kord-extensions = "1.5.6" mc-discord-reserializer = "4.3.0" emoji-java = "5.1.1" adventure-gson = "4.11.0" -placeholder-api = "2.0.0-pre.2+1.19.3" +placeholder-api = "2.1.1+1.20" permission-api = "0.2-SNAPSHOT" -vanish-api = "1.3.0" +vanish-api = "1.4.0+1.19.4" konf = "1.1.2" [libraries] diff --git a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/MemberCommandsExtension.kt b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/MemberCommandsExtension.kt index 9dbdc62..715487c 100644 --- a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/MemberCommandsExtension.kt +++ b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/MemberCommandsExtension.kt @@ -45,7 +45,7 @@ class MemberCommandsExtension : Extension() { guild(config.getGuild(bot)) action { - val profile = server.userCache.findByName(arguments.player).unwrap() + val profile = server.userCache?.findByName(arguments.player)?.unwrap() if (profile == null) { respond { content = config[MemberCommandsSpec.WhiteListSpec.MessagesSpec.unknownPlayer].replace( diff --git a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/inline/DiscordCommandOutput.kt b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/inline/DiscordCommandOutput.kt index eeafb84..281b387 100644 --- a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/inline/DiscordCommandOutput.kt +++ b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/inline/DiscordCommandOutput.kt @@ -6,7 +6,7 @@ import kotlinx.coroutines.runBlocking import net.minecraft.server.command.CommandOutput import net.minecraft.text.Text -class DiscordCommandOutput(private val commandContext: EphemeralSlashCommandContext) : +class DiscordCommandOutput(private val commandContext: EphemeralSlashCommandContext) : CommandOutput { private val buffer = StringBuffer() diff --git a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkCommand.kt b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkCommand.kt index 69e7e82..0179ee9 100644 --- a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkCommand.kt +++ b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkCommand.kt @@ -63,7 +63,10 @@ class LinkCommand(private val dispatcher: Dispatcher) { if (BlockBotDiscord.linkedAccounts.remove(player.uuid)) { logInfo("Unlinked ${player.name} from $id") - context.source.sendFeedback(TextParserUtils.formatText(config[LinkingSpec.MessagesSpec.successfulUnlink]), false) + context.source.sendFeedback( + { TextParserUtils.formatText(config[LinkingSpec.MessagesSpec.successfulUnlink]) }, + false + ) if (config[LinkingSpec.requireLinking]) { context.source.playerOrThrow.networkHandler.disconnect( @@ -74,7 +77,10 @@ class LinkCommand(private val dispatcher: Dispatcher) { ) } } else { - context.source.sendFeedback(TextParserUtils.formatText(config[LinkingSpec.MessagesSpec.failedUnlink]), false) + context.source.sendFeedback( + { TextParserUtils.formatText(config[LinkingSpec.MessagesSpec.failedUnlink]) }, + false + ) } return 1 @@ -97,14 +103,17 @@ class LinkCommand(private val dispatcher: Dispatcher) { if (id != null && BlockBotDiscord.linkedAccounts.get(id) != null) { val user = kord.getUser(id) - source.sendFeedback(Text.literal(user?.tag ?: id.toString()), false) + source.sendFeedback({ Text.literal(user?.tag ?: id.toString()) }, false) for (uuid in BlockBotDiscord.linkedAccounts.get(id)!!) { - val account = source.server.userCache.getByUuid(uuid).unwrap() - source.sendFeedback(Text.literal(" - ${account?.name ?: uuid.toString()}"), false) + val account = source.server.userCache?.getByUuid(uuid)?.unwrap() + source.sendFeedback({ Text.literal(" - ${account?.name ?: uuid.toString()}") }, false) } } else { - source.sendFeedback(TextParserUtils.formatText(config[LinkingSpec.MessagesSpec.noLinkedAccounts]), false) + source.sendFeedback( + { TextParserUtils.formatText(config[LinkingSpec.MessagesSpec.noLinkedAccounts]) }, + false + ) } } @@ -117,21 +126,25 @@ class LinkCommand(private val dispatcher: Dispatcher) { if (user != null) { context.source.sendFeedback( - TextParserUtils.formatText( - config[LinkingSpec.MessagesSpec.alreadyLinked].replace( - "{user}", - user.tag + { + TextParserUtils.formatText( + config[LinkingSpec.MessagesSpec.alreadyLinked].replace( + "{user}", + user.tag + ) ) - ), false + }, false ) } else { context.source.sendFeedback( - TextParserUtils.formatText( - config[LinkingSpec.MessagesSpec.linkCode].replace( - "{code}", - player.gameProfile.linkCode + { + TextParserUtils.formatText( + config[LinkingSpec.MessagesSpec.linkCode].replace( + "{code}", + player.gameProfile.linkCode + ) ) - ), false + }, false ) player.syncDiscord() } diff --git a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkingExtension.kt b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkingExtension.kt index 2a9dff3..78348c0 100644 --- a/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkingExtension.kt +++ b/src/main/kotlin/io/github/quiltservertools/blockbotdiscord/extensions/linking/LinkingExtension.kt @@ -68,7 +68,7 @@ class LinkingExtension : Extension() { BlockBotDiscord.linkedAccounts.add(snowflake, uuid) logInfo("Linked $uuid to $snowflake") linkCodes.remove(arguments.code) - val profile = server.userCache.getByUuid(uuid).unwrap() + val profile = server.userCache?.getByUuid(uuid)?.unwrap() respond { content = config[LinkingSpec.MessagesSpec.successfulLink].replace("{player}", profile?.name ?: "Unknown") diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d0476e9..bd4d680 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,9 +26,9 @@ "blockbot-discord.mixins.json" ], "depends": { - "minecraft": ">=1.19.1", + "minecraft": ">=1.20", "blockbot-api": ">=1.0.0", - "fabric-language-kotlin": "~1.8.2+kotlin.1.7.10", + "fabric-language-kotlin": ">=1.9.4+kotlin.1.8.21", "fabric": ">=${fabricApi}", "fabricloader": ">=${fabricLoader}" }