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.
This commit is contained in:
Ross Paffett 2021-01-17 16:21:46 -08:00
parent ad2bf97410
commit 1eaecfd45b
2 changed files with 1 additions and 41 deletions

View File

@ -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() {

View File

@ -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<String, String> 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);
}
}