From 738efe8c50b817324c361ea2d178cfc2d2d67bca Mon Sep 17 00:00:00 2001 From: md678685 Date: Sun, 21 Jan 2018 09:37:30 +0000 Subject: [PATCH] Add Vault prefix/suffix support to EssXChat (#1663) * Add Vault prefix/suffix support to EssXChat Includes an example of how to use it in the config. --- Essentials/src/com/earth2me/essentials/Settings.java | 2 ++ Essentials/src/config.yml | 2 ++ .../chat/EssentialsChatPlayerListenerLowest.java | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 67e6b0a8a..b85aab2aa 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -427,6 +427,8 @@ public class Settings implements net.ess3.api.ISettings { mFormat = mFormat.replace("{TEAMPREFIX}", "{3}"); mFormat = mFormat.replace("{TEAMSUFFIX}", "{4}"); mFormat = mFormat.replace("{TEAMNAME}", "{5}"); + mFormat = mFormat.replace("{PREFIX}", "{6}"); + mFormat = mFormat.replace("{SUFFIX}", "{7}"); mFormat = "§r".concat(mFormat); chatFormats.put(group, mFormat); } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index c7223c195..22914bc32 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -647,9 +647,11 @@ chat: # Chat formatting can be done in two ways, you can either define a standard format for all chat. # Or you can give a group specific chat format, to give some extra variation. # For more information of chat formatting, check out the wiki: http://wiki.ess3.net/wiki/Chat_Formatting + # For EssentialsX changes, take a look at the EssentialsX wiki: https://github.com/EssentialsX/Essentials/wiki format: '<{DISPLAYNAME}> {MESSAGE}' #format: '&7[{GROUP}]&r {DISPLAYNAME}&7:&r {MESSAGE}' + #format: '&7{PREFIX}&r {DISPLAYNAME}&r &7{SUFFIX}&r: {MESSAGE}' group-formats: # Default: '{WORLDNAME} {DISPLAYNAME}&7:&r {MESSAGE}' diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java index a3df5215c..d99a099fe 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.User; import com.earth2me.essentials.utils.FormatUtil; import net.ess3.api.IEssentials; import org.bukkit.Server; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.AsyncPlayerChatEvent; @@ -41,7 +42,11 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer { event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage())); String group = user.getGroup(); String world = user.getWorld().getName(); - Team team = user.getBase().getScoreboard().getPlayerTeam(user.getBase()); + + Player player = user.getBase(); + String prefix = ess.getPermissionsHandler().getPrefix(player); + String suffix = ess.getPermissionsHandler().getSuffix(player); + Team team = player.getScoreboard().getPlayerTeam(player); String format = ess.getSettings().getChatFormat(group); format = format.replace("{0}", group); @@ -50,6 +55,8 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer { format = format.replace("{3}", team == null ? "" : team.getPrefix()); format = format.replace("{4}", team == null ? "" : team.getSuffix()); format = format.replace("{5}", team == null ? "" : team.getDisplayName()); + format = format.replace("{6}", prefix); + format = format.replace("{7}", suffix); synchronized (format) { event.setFormat(format); }