From c79c1bcbee22993c2b408335bfb8542d42bc4b9b Mon Sep 17 00:00:00 2001 From: Draycia Date: Sun, 27 Sep 2020 00:12:45 -0700 Subject: [PATCH] Fix format getting and message parsing --- .../carbon/api/config/ChannelOptions.java | 17 +++++++++++++++-- .../common/channels/CarbonChatChannel.java | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java index fa48daa7..9fc9c24c 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java @@ -81,10 +81,23 @@ public class ChannelOptions { return this.contexts; } + @Nullable + public String format(final String key) { + if (this.formats == null) { + return this.defaultOptions().formats().get(key); + } + + final String format = this.formats.get(key); + + if (format != null) { + return format; + } + + return this.defaultOptions().formats().get(key); + } + @Nullable public Map formats() { - // TODO: properly implement default format inheritence - // TODO: perhaps add an option to make it so overriding any format overrides all? if (this.formats == null) { return this.defaultOptions().formats(); } diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java index 5ae97997..266bd20b 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonChatChannel.java @@ -304,7 +304,7 @@ public class CarbonChatChannel implements ChatChannel { @Override @Nullable public String format(final @NonNull String group) { - return this.options().formats().get("formats." + group); + return this.options().format(group); } private boolean isUserSpying(final @NonNull ChatUser sender, final @NonNull ChatUser target) {