mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-04 14:38:58 +00:00
- Add support for PlaceholderAPI's placeholders in the chatconfig.yml's
channel_format lines.
This commit is contained in:
1 parent
475e26dc81
commit
d038dd6a3a
5 files changed
+29
-8
No files matched your search
@@ -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>
|
||||||
|
|||||||
@@ -245,4 +245,5 @@ v0.57:
|
|||||||
- New ChatConfig option: chat_colour.nomad
|
- New ChatConfig option: chat_colour.nomad
|
||||||
- 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.
|
||||||
@@ -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]
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ public class Chat extends JavaPlugin {
|
|||||||
protected PluginManager pm;
|
protected PluginManager pm;
|
||||||
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;
|
||||||
|
|
||||||
@@ -120,6 +121,11 @@ public class Chat extends JavaPlugin {
|
|||||||
if (test != null) {
|
if (test != null) {
|
||||||
dynMap = (DynmapAPI) test;
|
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.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;
|
||||||
@@ -103,14 +106,15 @@ public class StandardChannel extends Channel {
|
|||||||
recipients = new HashSet<>(findRecipients(player, new ArrayList<>(event.getRecipients())));
|
recipients = new HashSet<>(findRecipients(player, new ArrayList<>(event.getRecipients())));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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));
|
||||||
|
|||||||
Reference in new issue
Block a user