- Add support for PlaceholderAPI's placeholders in the chatconfig.yml's

channel_format lines.
This commit is contained in:
Llm Dl committed 2019-10-14 11:48:50 -05:00
1 parent 475e26dc81
commit d038dd6a3a
5 files changed
+29 -8

No files matched your search

+10
View File
@@ -60,6 +60,10 @@
<id>github-Towny</id>
<url>https://maven.pkg.github.com/TownyAdvanced/Towny</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
@@ -87,6 +91,12 @@
<version>3.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
+2 -1
View File
@@ -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.)
- 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.
+1 -1
View File
@@ -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]
############################################################
# +------------------------------------------------------+ #
@@ -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;
}
}
@@ -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));