From 1eaecfd45b3c4900708d623444a52d9dc6cadbfd Mon Sep 17 00:00:00 2001 From: Ross Paffett Date: Sun, 17 Jan 2021 16:21:46 -0800 Subject: [PATCH] Don't prefix incoming messages with protocol name Matterbridge's API doesn't always include the chat protocol in its streaming JSON. The protocol doesn't seem like very useful information to display anyway. --- .../rosspaffett/mattercraft/ChatMessage.java | 23 +------------------ .../mattercraft/MatterbridgeProtocol.java | 19 --------------- 2 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 src/main/java/com/rosspaffett/mattercraft/MatterbridgeProtocol.java diff --git a/src/main/java/com/rosspaffett/mattercraft/ChatMessage.java b/src/main/java/com/rosspaffett/mattercraft/ChatMessage.java index ae47750..e00812d 100644 --- a/src/main/java/com/rosspaffett/mattercraft/ChatMessage.java +++ b/src/main/java/com/rosspaffett/mattercraft/ChatMessage.java @@ -3,7 +3,6 @@ package com.rosspaffett.mattercraft; import net.minecraft.util.text.StringTextComponent; public class ChatMessage { - private String protocol; private final String text; private final String username; @@ -20,28 +19,8 @@ public class ChatMessage { return this.username; } - public String humanizedProtocol() { - return MatterbridgeProtocol.humanize(protocol); - } - - public String textWithUsername() { - return "<" + getUsername() + "> " + getText(); - } - public String toString() { - if (protocol == null) { - return toStringWithoutProtocol(); - } else { - return toStringWithProtocol(); - } - } - - private String toStringWithProtocol() { - return "[" + humanizedProtocol() + "] " + textWithUsername(); - } - - private String toStringWithoutProtocol() { - return textWithUsername(); + return "<" + getUsername() + "> " + getText(); } public StringTextComponent toTextComponent() { diff --git a/src/main/java/com/rosspaffett/mattercraft/MatterbridgeProtocol.java b/src/main/java/com/rosspaffett/mattercraft/MatterbridgeProtocol.java deleted file mode 100644 index 50c2e6b..0000000 --- a/src/main/java/com/rosspaffett/mattercraft/MatterbridgeProtocol.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.rosspaffett.mattercraft; - -import java.util.HashMap; - -/** - * Maps Matterbridge's chat protocol IDs to human-readable versions. - */ -public class MatterbridgeProtocol { - private static final HashMap IDS_TO_HUMANIZED_NAMES = new HashMap<>(); - - static { - IDS_TO_HUMANIZED_NAMES.put("discord", "Discord"); - IDS_TO_HUMANIZED_NAMES.put("irc", "IRC"); - } - - public static String humanize(String id) { - return IDS_TO_HUMANIZED_NAMES.getOrDefault(id, id); - } -}