Fix chat parsing a bit

This commit is contained in:
Chipmunk 2023-01-10 15:29:55 -05:00
parent ef4ce27a4a
commit 4f5d0f4c49
2 changed files with 5 additions and 4 deletions

View file

@ -35,14 +35,14 @@ public class KaboomChatParser implements SystemChatParser {
}
public PlayerMessage parse (TranslatableComponent message) {
if (!message.key().equals("%") || message.args().size() != 1 || !message.style().equals(empty)) return parse(message.args().get(0));
if (!message.key().equals("%") || message.args() == null || message.args().size() != 1 || !message.style().equals(empty)) return parse(message.args().get(0));
return null;
}
public PlayerMessage parse (TextComponent message) {
List<Component> children = message.children();
if (!message.content().equals("") || !message.style().equals(empty) || children.size() < 3) return null;
if (!message.content().equals("") || !message.style().equals(empty) || children == null || children.size() < 3) return null;
final Map<String, Component> parameters = new HashMap<>();
@ -59,7 +59,8 @@ public class KaboomChatParser implements SystemChatParser {
return null;
}
MutablePlayerListEntry sender = client.playerList().getEntry(prefix.append(displayName));
MutablePlayerListEntry sender = client.playerList().getEntry(Component.empty().append(prefix).append(displayName));
if (sender == null) sender = client.playerList().getEntry(prefix.append(displayName)); // deprecated
if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(new UUID(0l, 0l), null), GameMode.SURVIVAL, 0, displayName, 0L, null, new byte[0]);
parameters.put("sender", displayName);

View file

@ -41,7 +41,7 @@ public class MinecraftChatParser implements SystemChatParser {
public PlayerMessage parse (TranslatableComponent message) {
final List<Component> args = message.args();
final String key = message.key();
if (args.size() < 2 || !typeMap.containsKey(key)) return null;
if (args == null || args.size() < 2 || !typeMap.containsKey(key)) return null;
final String type = typeMap.get(key);