diff --git a/pom.xml b/pom.xml
index 7788a01..809a542 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,10 @@
github-Towny
https://maven.pkg.github.com/TownyAdvanced/Towny
+
+ placeholderapi
+ http://repo.extendedclip.com/content/repositories/placeholderapi/
+
@@ -87,6 +91,12 @@
3.0-SNAPSHOT
provided
+
+ me.clip
+ placeholderapi
+ 2.10.4
+ provided
+
diff --git a/resources/changelog.txt b/resources/changelog.txt
index db955e1..0b1ac7d 100644
--- a/resources/changelog.txt
+++ b/resources/changelog.txt
@@ -245,4 +245,5 @@ v0.57:
- New ChatConfig option: chat_colour.nomad
- Default: &f
- You can now set the {townycolour} for players without a town.
- - Fix missing space following the title in {townyprefix} (when there is no mayor/king prefix present.)
\ No newline at end of file
+ - Fix missing space following the title in {townyprefix} (when there is no mayor/king prefix present.)
+ - Add support for PlaceholderAPI's placeholders in the chatconfig.yml's Channel_format lines.
\ No newline at end of file
diff --git a/resources/plugin.yml b/resources/plugin.yml
index c683d3e..ef40a81 100644
--- a/resources/plugin.yml
+++ b/resources/plugin.yml
@@ -7,7 +7,7 @@ website: http://towny.palmergames.com/towny/townychat/
description: >
TownyChat plugin which hooks into Towny.
-softdepend: [Towny, CraftIRC]
+softdepend: [Towny, CraftIRC, PlaceholderAPI]
############################################################
# +------------------------------------------------------+ #
diff --git a/src/com/palmergames/bukkit/TownyChat/Chat.java b/src/com/palmergames/bukkit/TownyChat/Chat.java
index e77ccc5..ac60579 100644
--- a/src/com/palmergames/bukkit/TownyChat/Chat.java
+++ b/src/com/palmergames/bukkit/TownyChat/Chat.java
@@ -42,7 +42,8 @@ public class Chat extends JavaPlugin {
protected PluginManager pm;
private Towny towny = null;
private DynmapAPI dynMap = null;
-
+
+ public static boolean usingPlaceholderAPI = false;
boolean chatConfigError = false;
boolean channelsConfigError = false;
@@ -120,6 +121,11 @@ public class Chat extends JavaPlugin {
if (test != null) {
dynMap = (DynmapAPI) test;
}
+
+ test = pm.getPlugin("PlaceholderAPI");
+ if (test != null) {
+ usingPlaceholderAPI = true;
+ }
}
diff --git a/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java b/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java
index 065c716..dec8152 100644
--- a/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java
+++ b/src/com/palmergames/bukkit/TownyChat/channels/StandardChannel.java
@@ -15,6 +15,9 @@ import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.TownyUniverse;
import com.palmergames.bukkit.util.Colors;
+
+import me.clip.placeholderapi.PlaceholderAPI;
+
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@@ -103,14 +106,15 @@ public class StandardChannel extends Channel {
recipients = new HashSet<>(findRecipients(player, new ArrayList<>(event.getRecipients())));
break;
}
-
+
/*
* Perform all replace functions on this format
*/
- //if (ChatSettings.isModify_chat())
- event.setFormat(Format.replace("{channelTag}", getChannelTag()).replace("{msgcolour}", getMessageColour()));
- //else
- // event.setFormat(event.getFormat().replace("{channelTag}", getChannelTag()).replace("{msgcolour}", getMessageColour()));
+ if (Chat.usingPlaceholderAPI) {
+ Format = PlaceholderAPI.setPlaceholders(player, Format);
+ }
+
+ event.setFormat(Format.replace("{channelTag}", getChannelTag()).replace("{msgcolour}", getMessageColour()));
LocalTownyChatEvent chatEvent = new LocalTownyChatEvent(event, resident);
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));