diff --git a/Essentials/pom.xml b/Essentials/pom.xml
index a29fc8b0f..d268d4c4d 100644
--- a/Essentials/pom.xml
+++ b/Essentials/pom.xml
@@ -54,6 +54,12 @@
1.7
provided
+
+ me.clip
+ placeholderapi
+ 2.10.3
+ provided
+
io.papermc
paperlib
diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
index 11ffc46a8..269f54f02 100644
--- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
+++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
@@ -7,7 +7,9 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.DescParseTickFormat;
import com.earth2me.essentials.utils.NumberUtil;
+import me.clip.placeholderapi.PlaceholderAPI;
import net.ess3.api.IEssentials;
+import net.ess3.api.IUser;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@@ -33,6 +35,7 @@ public class KeywordReplacer implements IText {
private transient ExecuteTimer execTimer;
private final transient boolean replaceSpacesWithUnderscores;
private final EnumMap keywordCache = new EnumMap(KeywordType.class);
+ private static Boolean isPAPIAvailable;
public KeywordReplacer(final IText input, final CommandSource sender, final IEssentials ess) {
this.input = input;
@@ -73,14 +76,19 @@ public class KeywordReplacer implements IText {
for (int i = 0; i < input.getLines().size(); i++) {
String line = input.getLines().get(i);
- final Matcher matcher = KEYWORD.matcher(line);
+ // Replace in-built keywords
+ final Matcher matcher = KEYWORD.matcher(line);
while (matcher.find()) {
final String fullMatch = matcher.group(0);
final String keywordMatch = matcher.group(1);
final String[] matchTokens = KEYWORDSPLIT.split(keywordMatch);
line = replaceLine(line, fullMatch, matchTokens, user);
}
+
+ // Replace PlaceholderAPI placeholders if applicable
+ line = replacePAPI(ess, sender, line);
+
replaced.add(line);
}
@@ -290,7 +298,18 @@ public class KeywordReplacer implements IText {
}
line = line.replace(fullMatch, replacer);
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException ignored) {}
+
+ return line;
+ }
+
+ private static String replacePAPI(final IEssentials ess, CommandSource source, String line) {
+ if (isPAPIAvailable == null) {
+ isPAPIAvailable = ess.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI");
+ }
+
+ if (isPAPIAvailable && source.isPlayer()) {
+ line = PlaceholderAPI.setPlaceholders(source.getPlayer(), line);
}
return line;
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 38f798025..86624868c 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -5,7 +5,7 @@ main: com.earth2me.essentials.Essentials
version: ${full.version}
website: http://tiny.cc/EssentialsCommands
description: Provides an essential, core set of commands for Bukkit.
-softdepend: [Vault]
+softdepend: [Vault, PlaceholderAPI]
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Iaccidentally, drtshock, vemacs, SupaHam, md678685]
api-version: 1.13
commands:
diff --git a/pom.xml b/pom.xml
index 1fbf4d7a6..66a81ac12 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,10 @@
paper-repo
https://papermc.io/repo/repository/maven-public/
+
+ papi-repo
+ http://repo.extendedclip.com/content/repositories/placeholderapi/
+