From 96a7c9fe5cdee7ea73b7ace589d1e752c3eb141e Mon Sep 17 00:00:00 2001 From: Boy Date: Sun, 27 Oct 2024 14:20:28 +0100 Subject: [PATCH] feat: bump ido & geary --- build.gradle.kts | 16 ++++----- gradle.properties | 2 +- gradle/libs.versions.toml | 5 ++- .../com/mineinabyss/packy/PackyCommands.kt | 12 ++++--- .../com/mineinabyss/packy/PackyPlugin.kt | 15 +++++--- .../packy/listener/PlayerListener.kt | 25 ++++++++----- .../packy/listener/TemplateLoadTriggers.kt | 36 ++----------------- 7 files changed, 46 insertions(+), 65 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 686878d..a33ee03 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,7 +37,6 @@ dependencies { // Geary platform compileOnly(packyLibs.geary.papermc) compileOnly(packyLibs.guiy) - compileOnly(packyLibs.betterhud) compileOnly(idofrontLibs.minecraft.plugin.modelengine) compileOnly(idofrontLibs.minecraft.plugin.oraxen) @@ -49,10 +48,12 @@ dependencies { implementation("com.squareup.okhttp3:okhttp:4.12.0") } -tasks.withType { +kotlin { compilerOptions { - freeCompilerArgs = listOf( - "-Xcontext-receivers", + freeCompilerArgs.addAll( + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + "-opt-in=kotlin.ExperimentalUnsignedTypes", + "-Xcontext-receivers" ) } } @@ -64,7 +65,7 @@ paper { val version: String by project this.version = version authors = listOf("boy0000") - apiVersion = "1.20" + apiVersion = "1.21" serverDependencies { register("Geary") { @@ -94,10 +95,5 @@ paper { load = PaperPluginDescription.RelativeLoadOrder.BEFORE joinClasspath = true } - register("BetterHud") { - required = false - load = PaperPluginDescription.RelativeLoadOrder.BEFORE - joinClasspath = true - } } } diff --git a/gradle.properties b/gradle.properties index dc08b9f..5b29ade 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss version=0.7 -idofrontVersion=0.24.23 +idofrontVersion=0.25.17-dev.2 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5c826fc..c6b7e30 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,7 @@ [versions] -gearyPaper = "0.30.11" -guiy="0.12.1" +gearyPaper = "0.31.0-dev.2" +guiy="0.12.4" [libraries] geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" } guiy = { module = "com.mineinabyss:guiy-compose", version.ref = "guiy" } -betterhud = "com.github.toxicity188:BetterHud:1.0" diff --git a/src/main/kotlin/com/mineinabyss/packy/PackyCommands.kt b/src/main/kotlin/com/mineinabyss/packy/PackyCommands.kt index cb759f2..84e37f7 100644 --- a/src/main/kotlin/com/mineinabyss/packy/PackyCommands.kt +++ b/src/main/kotlin/com/mineinabyss/packy/PackyCommands.kt @@ -3,6 +3,7 @@ package com.mineinabyss.packy import com.github.shynixn.mccoroutine.bukkit.launch import com.mineinabyss.guiy.inventory.guiy import com.mineinabyss.idofront.commands.brigadier.commands +import com.mineinabyss.idofront.commands.brigadier.executes import com.mineinabyss.idofront.messaging.error import com.mineinabyss.idofront.messaging.info import com.mineinabyss.idofront.messaging.success @@ -32,24 +33,26 @@ object PackyCommands { } } "menu" { + requiresPermission("") playerExecutes { guiy { PackyMainMenu(player) } } } "send" { + requiresPermission("") playerExecutes { packy.plugin.launch { PackyServer.sendPack(player) sender.success("Sent pack to ${player.name}") } } - val players by ArgumentTypes.players() - executes { + requiresPermission("packy.send.others") + executes(ArgumentTypes.players().resolve()) { players -> packy.plugin.launch { - players().forEach { + players.forEach { PackyServer.sendPack(it) } - sender.success("Sent pack to ${players().take(6).joinToString(",") { it.name }}...") + sender.success("Sent pack to ${players.take(6).joinToString(",") { it.name }}...") } } } @@ -64,7 +67,6 @@ object PackyCommands { } "debug" { playerExecutes { - player.packyData.templates.mapNotNull { (packy.templates[it.key] ?: return@mapNotNull null) to it.value } .map { Component.textOfChildren( diff --git a/src/main/kotlin/com/mineinabyss/packy/PackyPlugin.kt b/src/main/kotlin/com/mineinabyss/packy/PackyPlugin.kt index b7ac5df..9972fbe 100644 --- a/src/main/kotlin/com/mineinabyss/packy/PackyPlugin.kt +++ b/src/main/kotlin/com/mineinabyss/packy/PackyPlugin.kt @@ -4,8 +4,11 @@ import com.charleskorn.kaml.PolymorphismStyle import com.charleskorn.kaml.SingleLineStringStyle import com.charleskorn.kaml.Yaml import com.charleskorn.kaml.YamlConfiguration +import com.mineinabyss.geary.addons.dsl.createAddon import com.mineinabyss.geary.autoscan.autoscan import com.mineinabyss.geary.modules.geary +import com.mineinabyss.geary.papermc.configure +import com.mineinabyss.geary.papermc.gearyPaper import com.mineinabyss.idofront.config.ConfigFormats import com.mineinabyss.idofront.config.Format import com.mineinabyss.idofront.config.config @@ -23,11 +26,15 @@ import team.unnamed.creative.ResourcePack class PackyPlugin : JavaPlugin() { + private val PackyAddon = createAddon("Packy", configuration = { + autoscan(classLoader, "com.mineinabyss.packy") { + all() + } + }) + override fun onLoad() { - geary { - autoscan(classLoader, "com.mineinabyss.packy") { - all() - } + gearyPaper.configure { + install(PackyAddon) } } diff --git a/src/main/kotlin/com/mineinabyss/packy/listener/PlayerListener.kt b/src/main/kotlin/com/mineinabyss/packy/listener/PlayerListener.kt index eca0773..94a3844 100644 --- a/src/main/kotlin/com/mineinabyss/packy/listener/PlayerListener.kt +++ b/src/main/kotlin/com/mineinabyss/packy/listener/PlayerListener.kt @@ -2,15 +2,14 @@ package com.mineinabyss.packy.listener import com.github.shynixn.mccoroutine.bukkit.launch import com.mineinabyss.geary.papermc.datastore.decode +import com.mineinabyss.geary.papermc.withGeary import com.mineinabyss.idofront.nms.nbt.getOfflinePDC import com.mineinabyss.idofront.textcomponents.miniMsg import com.mineinabyss.packy.PackyGenerator import com.mineinabyss.packy.components.PackyData import com.mineinabyss.packy.components.packyData -import com.mineinabyss.packy.config.PackyTemplate import com.mineinabyss.packy.config.packy import io.papermc.paper.adventure.PaperAdventure -import kotlinx.coroutines.runBlocking import net.kyori.adventure.resource.ResourcePackRequest import net.minecraft.server.MinecraftServer.ServerResourcePackInfo import net.minecraft.server.network.ConfigurationTask @@ -35,7 +34,10 @@ class PlayerListener : Listener { packy.templates.forEach { template -> packyData.templates.computeIfAbsent(template.id) { template.default || template.required } } } - private val configurationTasks = ServerConfigurationPacketListenerImpl::class.java.getDeclaredField("configurationTasks").apply { isAccessible = true } + private val configurationTasks = + ServerConfigurationPacketListenerImpl::class.java.getDeclaredField("configurationTasks") + .apply { isAccessible = true } + @EventHandler fun PlayerLinksSendEvent.sendResourcePackPreJoin() { if (player.isOnline) return @@ -44,7 +46,7 @@ class PlayerListener : Listener { .map { it.packetListener }.filterIsInstance() .firstOrNull { it.craftPlayer.uniqueId == player.uniqueId } ?: return val taskQueue = configurationTasks.get(packetListener) as? Queue ?: return - val packyData = player.getOfflinePDC()?.decode() ?: PackyData() + val packyData = player.withGeary { player.getOfflinePDC()?.decode() ?: PackyData() } val info = PackyGenerator.getCachedPack(packyData.enabledPackIds)?.resourcePackInfo if (info != null) { @@ -52,15 +54,22 @@ class PlayerListener : Listener { else { taskQueue.offer( ServerResourcePackConfigurationTask( - ServerResourcePackInfo(info.id(), info.uri().toString(), info.hash(), packy.config.force && !packyData.bypassForced, PaperAdventure.asVanilla( - packy.config.prompt?.miniMsg())) + ServerResourcePackInfo( + info.id(), + info.uri().toString(), + info.hash(), + packy.config.force && !packyData.bypassForced, + PaperAdventure.asVanilla( + packy.config.prompt?.miniMsg() + ) + ) ) ) } } else { packy.plugin.launch { - val info = PackyGenerator.getOrCreateCachedPack(packyData.enabledPackIds).await().resourcePackInfo - if (player.isOnline) player.sendResourcePacks(ResourcePackRequest.addingRequest(info)) + val packInfo = PackyGenerator.getOrCreateCachedPack(packyData.enabledPackIds).await().resourcePackInfo + if (player.isOnline) player.sendResourcePacks(ResourcePackRequest.addingRequest(packInfo)) } } } diff --git a/src/main/kotlin/com/mineinabyss/packy/listener/TemplateLoadTriggers.kt b/src/main/kotlin/com/mineinabyss/packy/listener/TemplateLoadTriggers.kt index ec12b1c..497c5e9 100644 --- a/src/main/kotlin/com/mineinabyss/packy/listener/TemplateLoadTriggers.kt +++ b/src/main/kotlin/com/mineinabyss/packy/listener/TemplateLoadTriggers.kt @@ -1,18 +1,12 @@ package com.mineinabyss.packy.listener -import com.mineinabyss.geary.addons.GearyPhase -import com.mineinabyss.geary.modules.geary -import com.mineinabyss.geary.papermc.gearyPaper -import com.mineinabyss.idofront.di.DI -import com.mineinabyss.idofront.messaging.broadcast import com.mineinabyss.idofront.plugin.Plugins import com.mineinabyss.idofront.plugin.listeners import com.mineinabyss.idofront.plugin.unregisterListeners -import com.mineinabyss.packy.config.PackyTemplate -import com.mineinabyss.packy.config.packy import com.mineinabyss.packy.PackyGenerator import com.mineinabyss.packy.PackySquash -import com.mineinabyss.packy.config.PackyContext +import com.mineinabyss.packy.config.PackyTemplate +import com.mineinabyss.packy.config.packy import com.mineinabyss.packy.listener.TemplateLoadTriggers.unregisterTemplateHandlers import com.ticxo.modelengine.api.events.ModelRegistrationEvent import com.ticxo.modelengine.api.generator.ModelGenerator @@ -21,12 +15,8 @@ import io.th0rgal.oraxen.OraxenPlugin import io.th0rgal.oraxen.api.events.OraxenPackPreUploadEvent import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import kr.toxicity.hud.api.event.PluginReloadedEvent -import kr.toxicity.hud.api.plugin.ReloadState import org.bukkit.event.EventHandler import org.bukkit.event.Listener -import team.unnamed.creative.ResourcePack -import team.unnamed.creative.part.ResourcePackPart object TemplateLoadTriggers { @@ -138,28 +128,6 @@ sealed interface LoadTrigger { } } - @Serializable - @SerialName("BetterHud") - data object BetterHudTrigger : LoadTrigger { - override fun registerLoadHandler(template: PackyTemplate) { - if (!Plugins.isEnabled("BetterHud")) return - - val id = template.id - unregisterTemplateHandlers() - val listener = object : Listener { - @EventHandler - fun PluginReloadedEvent.onPluginReload() { - if (result.state != ReloadState.SUCCESS) return - - packy.logger.w("BetterHud loadTrigger detected...") - template.clearFromCache() - } - } - template.triggerListener = listener - packy.plugin.listeners(listener) - } - } - @Serializable @SerialName("Oraxen") data object OraxenTrigger : LoadTrigger {