we don't have the technology

This commit is contained in:
MD 2022-08-02 21:11:45 +01:00
parent a0eba932d5
commit 808f677547
6 changed files with 24 additions and 2 deletions

View File

@ -2,6 +2,10 @@ plugins {
id("essentials.module-conventions") id("essentials.module-conventions")
} }
essentials {
injectPlaceholderApi = true
}
dependencies { dependencies {
compileOnly project(':EssentialsX') compileOnly project(':EssentialsX')
} }

View File

@ -6,6 +6,7 @@ import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.chat.EssentialsChat; import com.earth2me.essentials.chat.EssentialsChat;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import me.clip.placeholderapi.PlaceholderAPI;
import net.ess3.api.events.LocalChatSpyEvent; import net.ess3.api.events.LocalChatSpyEvent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -28,12 +29,14 @@ public abstract class AbstractChatHandler {
protected final Essentials ess; protected final Essentials ess;
protected final EssentialsChat essChat; protected final EssentialsChat essChat;
protected final boolean isPapi;
protected final Server server; protected final Server server;
protected final ChatProcessingCache cache; protected final ChatProcessingCache cache;
protected AbstractChatHandler(Essentials ess, EssentialsChat essChat) { protected AbstractChatHandler(Essentials ess, EssentialsChat essChat) {
this.ess = ess; this.ess = ess;
this.essChat = essChat; this.essChat = essChat;
this.isPapi = essChat.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null;
this.server = ess.getServer(); this.server = ess.getServer();
this.cache = new ChatProcessingCache(); this.cache = new ChatProcessingCache();
} }
@ -83,6 +86,9 @@ public abstract class AbstractChatHandler {
format = format.replace("{7}", suffix); format = format.replace("{7}", suffix);
format = format.replace("{8}", username); format = format.replace("{8}", username);
format = format.replace("{9}", nickname == null ? username : nickname); format = format.replace("{9}", nickname == null ? username : nickname);
if (isPapi) {
format = PlaceholderAPI.setPlaceholders(event.getPlayer(), format);
}
synchronized (format) { synchronized (format) {
event.setFormat(format); event.setFormat(format);
} }

View File

@ -7,6 +7,7 @@ website: https://essentialsx.net/
description: Provides chat control features for Essentials. Requires Permissions. 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] authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy, Iaccidentally, mdcfe, JRoy, triagonal]
depend: [Essentials] depend: [Essentials]
softdepend: [PlaceholderAPI]
api-version: 1.13 api-version: 1.13
commands: commands:
toggleshout: toggleshout:

View File

@ -2,6 +2,10 @@ plugins {
id("essentials.shadow-module") id("essentials.shadow-module")
} }
essentials {
injectPlaceholderApi = true
}
dependencies { dependencies {
compileOnly project(':EssentialsX') compileOnly project(':EssentialsX')
implementation('net.dv8tion:JDA:4.4.0_350') { implementation('net.dv8tion:JDA:4.4.0_350') {
@ -10,7 +14,6 @@ dependencies {
implementation 'com.vdurmont:emoji-java:5.1.1' implementation 'com.vdurmont:emoji-java:5.1.1'
implementation 'club.minnced:discord-webhooks:0.7.2' implementation 'club.minnced:discord-webhooks:0.7.2'
compileOnly 'org.apache.logging.log4j:log4j-core:2.15.0' compileOnly 'org.apache.logging.log4j:log4j-core:2.15.0'
compileOnly 'me.clip:placeholderapi:2.10.9'
} }
shadowJar { shadowJar {

View File

@ -5,4 +5,5 @@ import org.gradle.kotlin.dsl.property
abstract class EssentialsBaseExtension(private val project: Project) { abstract class EssentialsBaseExtension(private val project: Project) {
val injectBukkitApi: Property<Boolean> = project.objects.property<Boolean>().convention(true) val injectBukkitApi: Property<Boolean> = project.objects.property<Boolean>().convention(true)
val injectBstats: Property<Boolean> = project.objects.property<Boolean>().convention(true) val injectBstats: Property<Boolean> = project.objects.property<Boolean>().convention(true)
val injectPlaceholderApi: Property<Boolean> = project.objects.property<Boolean>().convention(false)
} }

View File

@ -13,6 +13,8 @@ val checkstyleVersion = "8.36.2"
val spigotVersion = "1.19.1-R0.1-SNAPSHOT" val spigotVersion = "1.19.1-R0.1-SNAPSHOT"
val junit5Version = "5.7.0" val junit5Version = "5.7.0"
val mockitoVersion = "3.2.0" val mockitoVersion = "3.2.0"
val bstatsVersion = "1.8"
val placeholderApiVersion = "2.11.2"
dependencies { dependencies {
testImplementation("org.junit.jupiter", "junit-jupiter", junit5Version) testImplementation("org.junit.jupiter", "junit-jupiter", junit5Version)
@ -34,7 +36,12 @@ afterEvaluate {
} }
if (baseExtension.injectBstats.get()) { if (baseExtension.injectBstats.get()) {
dependencies { dependencies {
implementation("org.bstats", "bstats-bukkit", "1.8") implementation("org.bstats", "bstats-bukkit", bstatsVersion)
}
}
if (baseExtension.injectPlaceholderApi.get()) {
dependencies {
compileOnly("me.clip", "placeholderapi", placeholderApiVersion)
} }
} }
} }