diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2023-01-13 11:06:54 -0500 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2023-01-13 11:06:54 -0500 |
commit | 348abd9142f75d9fb723237fdd3cfa3174bbbc21 (patch) | |
tree | 2da34632e23327b73378d03428c2f14233d61cb4 /src/main/java/cc/woverflow | |
parent | 9b50f588f1d5899bfe1b7f6aa1f42bc204257bf4 (diff) | |
download | Chatting-348abd9142f75d9fb723237fdd3cfa3174bbbc21.tar.gz Chatting-348abd9142f75d9fb723237fdd3cfa3174bbbc21.tar.bz2 Chatting-348abd9142f75d9fb723237fdd3cfa3174bbbc21.zip |
fix chat head crash
Diffstat (limited to 'src/main/java/cc/woverflow')
-rw-r--r-- | src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java b/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java index b739284..ab052ae 100644 --- a/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java +++ b/src/main/java/cc/woverflow/chatting/mixin/ChatLineMixin.java @@ -34,26 +34,30 @@ public class ChatLineMixin implements ChatLineHook { private void onInit(int i, IChatComponent iChatComponent, int j, CallbackInfo ci) { chatLines.add(new WeakReference<>((ChatLine) (Object) this)); NetHandlerPlayClient netHandler = Minecraft.getMinecraft().getNetHandler(); + if (netHandler == null) return; Map<String, NetworkPlayerInfo> nicknameCache = new HashMap<>(); - for (String word : iChatComponent.getFormattedText().split("(§.)|\\W")) { - if (word.isEmpty()) continue; - playerInfo = netHandler.getPlayerInfo(word); - if (playerInfo == null) { - playerInfo = getPlayerFromNickname(word, netHandler, nicknameCache); - } - if (playerInfo != null) { - detectedPlayerInfo = playerInfo; - detected = true; - if (playerInfo == lastPlayerInfo) { - first = false; - if (ChattingConfig.INSTANCE.getHideChatHeadOnConsecutiveMessages()) { - playerInfo = null; + try { + for (String word : iChatComponent.getFormattedText().split("(§.)|\\W")) { + if (word.isEmpty()) continue; + playerInfo = netHandler.getPlayerInfo(word); + if (playerInfo == null) { + playerInfo = getPlayerFromNickname(word, netHandler, nicknameCache); + } + if (playerInfo != null) { + detectedPlayerInfo = playerInfo; + detected = true; + if (playerInfo == lastPlayerInfo) { + first = false; + if (ChattingConfig.INSTANCE.getHideChatHeadOnConsecutiveMessages()) { + playerInfo = null; + } + } else { + lastPlayerInfo = playerInfo; } - } else { - lastPlayerInfo = playerInfo; + break; } - break; } + } catch (Exception ignored) { } } |