Skip to content

Commit

Permalink
feat: bump ido & geary
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Oct 27, 2024
1 parent aee872e commit 96a7c9f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 65 deletions.
16 changes: 6 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -49,10 +48,12 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:4.12.0")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlin {
compilerOptions {
freeCompilerArgs = listOf(
"-Xcontext-receivers",
freeCompilerArgs.addAll(
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlin.ExperimentalUnsignedTypes",
"-Xcontext-receivers"
)
}
}
Expand All @@ -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") {
Expand Down Expand Up @@ -94,10 +95,5 @@ paper {
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
joinClasspath = true
}
register("BetterHud") {
required = false
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
joinClasspath = true
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=0.7
idofrontVersion=0.24.23
idofrontVersion=0.25.17-dev.2
5 changes: 2 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 7 additions & 5 deletions src/main/kotlin/com/mineinabyss/packy/PackyCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}...")
}
}
}
Expand All @@ -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(
Expand Down
15 changes: 11 additions & 4 deletions src/main/kotlin/com/mineinabyss/packy/PackyPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}

Expand Down
25 changes: 17 additions & 8 deletions src/main/kotlin/com/mineinabyss/packy/listener/PlayerListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -44,23 +46,30 @@ class PlayerListener : Listener {
.map { it.packetListener }.filterIsInstance<ServerConfigurationPacketListenerImpl>()
.firstOrNull { it.craftPlayer.uniqueId == player.uniqueId } ?: return
val taskQueue = configurationTasks.get(packetListener) as? Queue<ConfigurationTask> ?: return
val packyData = player.getOfflinePDC()?.decode<PackyData>() ?: PackyData()
val packyData = player.withGeary { player.getOfflinePDC()?.decode<PackyData>() ?: PackyData() }

val info = PackyGenerator.getCachedPack(packyData.enabledPackIds)?.resourcePackInfo
if (info != null) {
if (player.isOnline) player.sendResourcePacks(ResourcePackRequest.addingRequest(info))
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))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 96a7c9f

Please sign in to comment.