- 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
+26 -5

No files matched your search

+10
View File
@@ -60,6 +60,10 @@
<id>github-Towny</id> <id>github-Towny</id>
<url>https://maven.pkg.github.com/TownyAdvanced/Towny</url> <url>https://maven.pkg.github.com/TownyAdvanced/Towny</url>
</repository> </repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@@ -87,6 +91,12 @@
<version>3.0-SNAPSHOT</version> <version>3.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.4</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
+1
View File
@@ -246,3 +246,4 @@ v0.57:
- Default: &f - Default: &f
- You can now set the {townycolour} for players without a town. - 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: > description: >
TownyChat plugin which hooks into Towny. TownyChat plugin which hooks into Towny.
softdepend: [Towny, CraftIRC] softdepend: [Towny, CraftIRC, PlaceholderAPI]
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@@ -43,6 +43,7 @@ public class Chat extends JavaPlugin {
private Towny towny = null; private Towny towny = null;
private DynmapAPI dynMap = null; private DynmapAPI dynMap = null;
public static boolean usingPlaceholderAPI = false;
boolean chatConfigError = false; boolean chatConfigError = false;
boolean channelsConfigError = false; boolean channelsConfigError = false;
@@ -121,6 +122,11 @@ public class Chat extends JavaPlugin {
dynMap = (DynmapAPI) test; dynMap = (DynmapAPI) test;
} }
test = pm.getPlugin("PlaceholderAPI");
if (test != null) {
usingPlaceholderAPI = true;
}
} }
public void registerEvents() { public void registerEvents() {
@@ -15,6 +15,9 @@ import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town; import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.TownyUniverse; import com.palmergames.bukkit.towny.TownyUniverse;
import com.palmergames.bukkit.util.Colors; import com.palmergames.bukkit.util.Colors;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
@@ -107,10 +110,11 @@ public class StandardChannel extends Channel {
/* /*
* Perform all replace functions on this format * Perform all replace functions on this format
*/ */
//if (ChatSettings.isModify_chat()) if (Chat.usingPlaceholderAPI) {
event.setFormat(Format.replace("{channelTag}", getChannelTag()).replace("{msgcolour}", getMessageColour())); Format = PlaceholderAPI.setPlaceholders(player, Format);
//else }
// event.setFormat(event.getFormat().replace("{channelTag}", getChannelTag()).replace("{msgcolour}", getMessageColour()));
event.setFormat(Format.replace("{channelTag}", getChannelTag()).replace("{msgcolour}", getMessageColour()));
LocalTownyChatEvent chatEvent = new LocalTownyChatEvent(event, resident); LocalTownyChatEvent chatEvent = new LocalTownyChatEvent(event, resident);
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent)); event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));