mirror of
https://github.com/raws/minecraft-forge-mattercraft.git
synced 2025-09-22 11:54:39 -04:00
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:
parent
ad2bf97410
commit
1eaecfd45b
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user