From 808f67754748dc28c179bccc8523c251148b9492 Mon Sep 17 00:00:00 2001 From: MD <1917406+mdcfe@users.noreply.github.com> Date: Tue, 2 Aug 2022 21:11:45 +0100 Subject: [PATCH] we don't have the technology --- EssentialsChat/build.gradle | 4 ++++ .../essentials/chat/processing/AbstractChatHandler.java | 6 ++++++ EssentialsChat/src/main/resources/plugin.yml | 1 + EssentialsDiscord/build.gradle | 5 ++++- build-logic/src/main/kotlin/EssentialsBaseExtension.kt | 1 + .../main/kotlin/essentials.base-conventions.gradle.kts | 9 ++++++++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/EssentialsChat/build.gradle b/EssentialsChat/build.gradle index e0b9454d2..73f4f442b 100644 --- a/EssentialsChat/build.gradle +++ b/EssentialsChat/build.gradle @@ -2,6 +2,10 @@ plugins { id("essentials.module-conventions") } +essentials { + injectPlaceholderApi = true +} + dependencies { compileOnly project(':EssentialsX') } diff --git a/EssentialsChat/src/main/java/com/earth2me/essentials/chat/processing/AbstractChatHandler.java b/EssentialsChat/src/main/java/com/earth2me/essentials/chat/processing/AbstractChatHandler.java index b0dd5e73a..c4f9c13cd 100644 --- a/EssentialsChat/src/main/java/com/earth2me/essentials/chat/processing/AbstractChatHandler.java +++ b/EssentialsChat/src/main/java/com/earth2me/essentials/chat/processing/AbstractChatHandler.java @@ -6,6 +6,7 @@ import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import com.earth2me.essentials.chat.EssentialsChat; import com.earth2me.essentials.utils.FormatUtil; +import me.clip.placeholderapi.PlaceholderAPI; import net.ess3.api.events.LocalChatSpyEvent; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -28,12 +29,14 @@ public abstract class AbstractChatHandler { protected final Essentials ess; protected final EssentialsChat essChat; + protected final boolean isPapi; protected final Server server; protected final ChatProcessingCache cache; protected AbstractChatHandler(Essentials ess, EssentialsChat essChat) { this.ess = ess; this.essChat = essChat; + this.isPapi = essChat.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null; this.server = ess.getServer(); this.cache = new ChatProcessingCache(); } @@ -83,6 +86,9 @@ public abstract class AbstractChatHandler { format = format.replace("{7}", suffix); format = format.replace("{8}", username); format = format.replace("{9}", nickname == null ? username : nickname); + if (isPapi) { + format = PlaceholderAPI.setPlaceholders(event.getPlayer(), format); + } synchronized (format) { event.setFormat(format); } diff --git a/EssentialsChat/src/main/resources/plugin.yml b/EssentialsChat/src/main/resources/plugin.yml index ab1d85c5a..fc96189f8 100644 --- a/EssentialsChat/src/main/resources/plugin.yml +++ b/EssentialsChat/src/main/resources/plugin.yml @@ -7,6 +7,7 @@ website: https://essentialsx.net/ description: Provides chat control features for Essentials. Requires Permissions. authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy, Iaccidentally, mdcfe, JRoy, triagonal] depend: [Essentials] +softdepend: [PlaceholderAPI] api-version: 1.13 commands: toggleshout: diff --git a/EssentialsDiscord/build.gradle b/EssentialsDiscord/build.gradle index 9a8e7fe1f..839b3fbda 100644 --- a/EssentialsDiscord/build.gradle +++ b/EssentialsDiscord/build.gradle @@ -2,6 +2,10 @@ plugins { id("essentials.shadow-module") } +essentials { + injectPlaceholderApi = true +} + dependencies { compileOnly project(':EssentialsX') implementation('net.dv8tion:JDA:4.4.0_350') { @@ -10,7 +14,6 @@ dependencies { implementation 'com.vdurmont:emoji-java:5.1.1' implementation 'club.minnced:discord-webhooks:0.7.2' compileOnly 'org.apache.logging.log4j:log4j-core:2.15.0' - compileOnly 'me.clip:placeholderapi:2.10.9' } shadowJar { diff --git a/build-logic/src/main/kotlin/EssentialsBaseExtension.kt b/build-logic/src/main/kotlin/EssentialsBaseExtension.kt index bc3901781..bc556890c 100644 --- a/build-logic/src/main/kotlin/EssentialsBaseExtension.kt +++ b/build-logic/src/main/kotlin/EssentialsBaseExtension.kt @@ -5,4 +5,5 @@ import org.gradle.kotlin.dsl.property abstract class EssentialsBaseExtension(private val project: Project) { val injectBukkitApi: Property = project.objects.property().convention(true) val injectBstats: Property = project.objects.property().convention(true) + val injectPlaceholderApi: Property = project.objects.property().convention(false) } diff --git a/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts b/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts index c0df3166f..0ad0850ec 100644 --- a/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/essentials.base-conventions.gradle.kts @@ -13,6 +13,8 @@ val checkstyleVersion = "8.36.2" val spigotVersion = "1.19.1-R0.1-SNAPSHOT" val junit5Version = "5.7.0" val mockitoVersion = "3.2.0" +val bstatsVersion = "1.8" +val placeholderApiVersion = "2.11.2" dependencies { testImplementation("org.junit.jupiter", "junit-jupiter", junit5Version) @@ -34,7 +36,12 @@ afterEvaluate { } if (baseExtension.injectBstats.get()) { dependencies { - implementation("org.bstats", "bstats-bukkit", "1.8") + implementation("org.bstats", "bstats-bukkit", bstatsVersion) + } + } + if (baseExtension.injectPlaceholderApi.get()) { + dependencies { + compileOnly("me.clip", "placeholderapi", placeholderApiVersion) } } }