From e10ba6f427e88a053b9044f102b8e205a552f7ef Mon Sep 17 00:00:00 2001 From: Llm Dl Date: Mon, 30 Nov 2020 15:42:29 -0600 Subject: [PATCH] v0.84: - Fix nation and town names not parsing out the _'s for spaces. - Closes https://github.com/TownyAdvanced/Towny/issues/4489. --- pom.xml | 2 +- resources/changelog.txt | 5 +++- .../bukkit/TownyChat/TownyChatFormatter.java | 30 ++++++++++++------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index c2e1946..694f068 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.palmergames.bukkit TownyChat jar - 0.83 + 0.84 diff --git a/resources/changelog.txt b/resources/changelog.txt index 5ef5fcf..aaa7397 100644 --- a/resources/changelog.txt +++ b/resources/changelog.txt @@ -348,4 +348,7 @@ v0.82: - Should solve load order issues. v0.83: - Fix townychat.spam.bypass doing the opposite of its job. - - Fix spam countdown resetting if you speak too early. \ No newline at end of file + - Fix spam countdown resetting if you speak too early. +v0.84: + - Fix nation and town names not parsing out the _'s for spaces. + - Closes https://github.com/TownyAdvanced/Towny/issues/4489. \ 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 4374661..4348021 100644 --- a/src/com/palmergames/bukkit/TownyChat/TownyChatFormatter.java +++ b/src/com/palmergames/bukkit/TownyChat/TownyChatFormatter.java @@ -6,9 +6,11 @@ import com.palmergames.bukkit.TownyChat.util.StringReplaceManager; import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.TownySettings; import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; +import com.palmergames.bukkit.towny.object.Government; import com.palmergames.bukkit.towny.object.Nation; import com.palmergames.bukkit.towny.object.Resident; import com.palmergames.bukkit.towny.object.Town; +import com.palmergames.util.StringMgmt; import com.palmergames.bukkit.towny.TownyUniverse; import java.util.regex.Pattern; @@ -238,12 +240,12 @@ public class TownyChatFormatter { try { if (resident.hasTown()) { Town town = resident.getTown(); - String townTag = town.getTag(); + String townTag = getTag(town); Nation nation = null; String nationTag = null; if (resident.hasNation()) { nation = town.getNation(); - nationTag = nation.getTag(); + nationTag = getTag(nation); } String nTag = "", tTag = ""; @@ -257,13 +259,13 @@ public class TownyChatFormatter { if (townTag != null && !townTag.isEmpty()) tTag = townTag; else if (override || full) - tTag = town.getName(); + tTag = getName(town); // Load the nation tags/names if ((nationTag != null) && !nationTag.isEmpty()) nTag = nationTag; else if (resident.hasNation() && (override || full)) - nTag = nation.getName(); + nTag = getName(nation); // Output depending on what tags are present if ((!tTag.isEmpty()) && (!nTag.isEmpty())) { @@ -296,11 +298,11 @@ public class TownyChatFormatter { try { if (resident.hasTown()) if (full) - return hexIfCompatible(String.format(ChatSettings.getTownTag(), resident.getTown().getName())); + return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(resident.getTown()))); else if (resident.getTown().hasTag()) - return hexIfCompatible(String.format(ChatSettings.getTownTag(), resident.getTown().getTag())); + return hexIfCompatible(String.format(ChatSettings.getTownTag(), getTag(resident.getTown()))); else if (override) - return hexIfCompatible(String.format(ChatSettings.getTownTag(), resident.getTown().getName())); + return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(resident.getTown()))); } catch (NotRegisteredException e) { } @@ -311,11 +313,11 @@ public class TownyChatFormatter { try { if (resident.hasNation()) if (full) - return hexIfCompatible(String.format(ChatSettings.getNationTag(), resident.getTown().getNation().getName())); + return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(resident.getTown().getNation()))); else if (resident.getTown().getNation().hasTag()) - return hexIfCompatible(String.format(ChatSettings.getNationTag(), resident.getTown().getNation().getTag())); + return hexIfCompatible(String.format(ChatSettings.getNationTag(), getTag(resident.getTown().getNation()))); else if (override) - return hexIfCompatible(String.format(ChatSettings.getNationTag(), resident.getTown().getNation().getName())); + return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(resident.getTown().getNation()))); } catch (NotRegisteredException e) { } @@ -343,4 +345,12 @@ public class TownyChatFormatter { return TownySettings.getMayorPostfix(resident); return ""; } + + private static String getName(Government gov) { + return StringMgmt.remUnderscore(gov.getName()); + } + + private static String getTag(Government gov) { + return gov.getTag(); + } }