diff --git a/resources/changelog.txt b/resources/changelog.txt index 489cde3..4a3c2f2 100644 --- a/resources/changelog.txt +++ b/resources/changelog.txt @@ -454,4 +454,9 @@ v0.105: v0.106: - Add focusable option to channels in the channels.yml. - By default channels are focusable and adding focusable: true has no effect. - - Adding focusable: false will prevent players making their primary channel, ie using /tc with no message. \ No newline at end of file + - Adding focusable: false will prevent players making their primary channel, ie using /tc with no message. + - Add new chat slug: {primaryresidentrank} + - When a resident has a primary rank with a prefix this will display their prefix with a space added to the end. + - Primary ranks and their prefixes are set in the townyperms.yml like so: + - towny.rankpriority.# + - towny.rankprefix. \ No newline at end of file diff --git a/src/com/palmergames/bukkit/TownyChat/TownyChatFormatter.java b/src/com/palmergames/bukkit/TownyChat/TownyChatFormatter.java index ad3d118..cb516ae 100644 --- a/src/com/palmergames/bukkit/TownyChat/TownyChatFormatter.java +++ b/src/com/palmergames/bukkit/TownyChat/TownyChatFormatter.java @@ -46,6 +46,7 @@ public class TownyChatFormatter { replacer.registerReplacer("{permgroupprefix}", event -> getVaultPrefixSuffix(event.getResident(), "groupprefix")); replacer.registerReplacer("{permgroupsuffix}", event -> getVaultPrefixSuffix(event.getResident(), "groupsuffix")); replacer.registerReplacer("{playername}", event -> event.getEvent().getPlayer().getName()); + replacer.registerReplacer("{primaryresidentrank}", event -> getPrimaryRankPrefix(event.getResident())); } public static String getChatFormat(LocalTownyChatEvent event) { @@ -176,7 +177,14 @@ public class TownyChatFormatter { return TownySettings.getMayorPostfix(resident); return ""; } - + + public static String getPrimaryRankPrefix(Resident resident) { + if (resident == null) + return ""; + String rank = resident.getPrimaryRankPrefix(); + return rank.isEmpty() ? "" : rank + " "; + } + private static String getName(Government gov) { return StringMgmt.remUnderscore(gov.getName()); } diff --git a/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java b/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java index 6b526c8..79bd1d8 100644 --- a/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java +++ b/src/com/palmergames/bukkit/TownyChat/config/ChatConfigNodes.java @@ -53,6 +53,8 @@ public enum ChatConfigNodes { "# {permprefix} - Permission group and user prefix.", "# {permsuffix} - Permission group and user suffix.", "#", + "# {primaryresidentrank} - When a resident has a primary rank with a prefix this will display their prefix with a space added to the end.", + "#", "# {playername} - Default player name.", "# {modplayername} - Modified player name (use if Towny is over writing some other plugins changes).", "# {msg} - The message sent.",