From f96a711ba9c1868f1486d787487b6efe80f92a0d Mon Sep 17 00:00:00 2001 From: Boy Date: Sat, 17 Aug 2024 15:16:24 +0200 Subject: [PATCH] feat: add placeholderapi for proxy usage --- core/build.gradle.kts | 2 ++ .../com/mineinabyss/emojy/EmojyPlaceholders.kt | 18 ++++++++++++++++++ .../com/mineinabyss/emojy/EmojyPlugin.kt | 1 + settings.gradle.kts | 4 +--- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlaceholders.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index af2933d..97c6dc9 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -11,6 +11,7 @@ repositories { maven("https://repo.mineinabyss.com/snapshots") maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.unnamed.team/repository/unnamed-public/") + maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") google() } @@ -24,6 +25,7 @@ dependencies { compileOnly(idofrontLibs.creative.api) compileOnly(idofrontLibs.creative.serializer.minecraft) + compileOnly("me.clip:placeholderapi:2.11.6") // Shaded implementation("com.aaaaahhhhh.bananapuncher714:GifConverter:1.0") diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlaceholders.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlaceholders.kt new file mode 100644 index 0000000..bd3202a --- /dev/null +++ b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlaceholders.kt @@ -0,0 +1,18 @@ +package com.mineinabyss.emojy + +import com.mineinabyss.idofront.textcomponents.serialize +import me.clip.placeholderapi.expansion.PlaceholderExpansion +import org.bukkit.OfflinePlayer + +class EmojyPlaceholders : PlaceholderExpansion() { + override fun getIdentifier() = "emojy" + + override fun getAuthor() = "boy0000" + + override fun getVersion() = emojy.plugin.pluginMeta.version + + override fun onRequest(player: OfflinePlayer?, params: String): String? { + val emote = emojy.emotes.firstOrNull { it.id == params }?.formattedUnicode() ?: emojy.gifs.firstOrNull { it.id == params }?.formattedUnicode() + return emote?.serialize() + } +} \ No newline at end of file diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt index ed7d726..99267a0 100644 --- a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt +++ b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt @@ -62,6 +62,7 @@ class EmojyPlugin : JavaPlugin() { GlobalTranslator.translator().sources().filter { it.name() == EmojyTranslator.key }.forEach(GlobalTranslator.translator()::removeSource) GlobalTranslator.translator().addSource(EmojyTranslator()) + EmojyPlaceholders().register() } } diff --git a/settings.gradle.kts b/settings.gradle.kts index e1b872d..2a3a943 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -29,9 +29,7 @@ dependencyResolutionManagement { } versionCatalogs { - create("idofrontLibs"){ - from("com.mineinabyss:catalog:$idofrontVersion") - } + create("idofrontLibs").from("com.mineinabyss:catalog:$idofrontVersion") } }