From ba695ae06c17c5166567941364e666c9bb846c86 Mon Sep 17 00:00:00 2001 From: LlmDl Date: Mon, 19 Feb 2024 17:29:31 -0600 Subject: [PATCH] - Add support for channels.yml's with legacy channelTag keys. (#59) --- pom.xml | 2 +- resources/changelog.txt | 4 +++- .../bukkit/TownyChat/config/ChannelsSettings.java | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index ef10d4b..077e9b5 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.palmergames.bukkit TownyChat jar - 0.114 + 0.115 diff --git a/resources/changelog.txt b/resources/changelog.txt index e928775..43f9fa6 100644 --- a/resources/changelog.txt +++ b/resources/changelog.txt @@ -488,4 +488,6 @@ v0.113: - Fix channelTag not parsing properly. - Closes https://github.com/TownyAdvanced/Towny/issues/7239. v0.114: - - Actually fix {channelTag} not parsing properly. \ No newline at end of file + - Actually fix {channelTag} not parsing properly. +v0.115: + - Add support for channels.yml's with legacy channelTag keys. \ No newline at end of file diff --git a/src/com/palmergames/bukkit/TownyChat/config/ChannelsSettings.java b/src/com/palmergames/bukkit/TownyChat/config/ChannelsSettings.java index 9452701..ba7761a 100644 --- a/src/com/palmergames/bukkit/TownyChat/config/ChannelsSettings.java +++ b/src/com/palmergames/bukkit/TownyChat/config/ChannelsSettings.java @@ -27,6 +27,7 @@ public class ChannelsSettings { private final static List DEFAULT_CHANNELS = Arrays.asList("general","town","nation","alliance","admin","mod","local"); private static final String CHANNEL_TAG = "channeltag"; + private static final String LEGACY_CHANNEL_TAG = "channelTag"; private static final String SPAM_TIME = "spam_time"; private static final String RANGE = "range"; private static final String DEFAULT = "default"; @@ -321,11 +322,12 @@ public String getType() { } public boolean hasChannelTag() { - return channelSettingsMap.containsKey(CHANNEL_TAG); + return channelSettingsMap.containsKey(CHANNEL_TAG) || channelSettingsMap.containsKey(LEGACY_CHANNEL_TAG); } public String getChannelTag() { - return (String) channelSettingsMap.getOrDefault(CHANNEL_TAG, ""); + String slug = channelSettingsMap.containsKey(LEGACY_CHANNEL_TAG) ? LEGACY_CHANNEL_TAG : CHANNEL_TAG; + return (String) channelSettingsMap.getOrDefault(slug, ""); } public boolean hasMessageColour() {