2929@ Mixin (Connection .class )
3030public class OnPacketMixin {
3131 @ Inject (method = "genericsFtw" , at = @ At ("HEAD" ), cancellable = true )
32- private static <T extends PacketListener > void onGameMessage (Packet <T > packet , PacketListener listener , CallbackInfo ci ) {
32+ private static <T extends PacketListener > void onGameMessage (Packet <@ org . jetbrains . annotations . NotNull T > packet , PacketListener listener , CallbackInfo ci ) {
3333 if (packet instanceof ClientboundSystemChatPacket (Component content , boolean overlay )) {
3434 handleChatPacket (content , overlay , ci );
3535 }
@@ -77,7 +77,7 @@ private static void handleChatPacket(Component content, boolean overlay, Callbac
7777 GameState .melonJoin = LocalDateTime .now ();
7878 }
7979
80- if (!Mwonmod .onMelonKing ()) return ;
80+ if (!Mwonmod .onMelonKing () || Minecraft . getInstance (). player == null ) return ;
8181 if (message .equals ("» All combatants perished, so the battle was lost." )) {
8282 BossState .updateBoss (null );
8383 }
@@ -89,22 +89,21 @@ private static void handleChatPacket(Component content, boolean overlay, Callbac
8989 if (Config .HANDLER .instance ().hideSellFailMessage && Objects .equals (message , "> You don't have any Super Enchanted Melons. Get them by cooking four Enchanted Melon Slices, which are gotten by cooking four Melon Slices." )) {
9090 ci .cancel ();
9191 }
92- if (Config .HANDLER .instance ().what && Objects .equals (message , "> What?" ) && Minecraft . getInstance (). player != null ) {
92+ if (Config .HANDLER .instance ().what && Objects .equals (message , "> What?" )) {
9393 Mwonmod .notification ("> What?" , "> What?" );
9494 Minecraft .getInstance ().execute (() -> Minecraft .getInstance ().player .connection .sendChat ("> What?" ));
9595 }
96- if (Config .HANDLER .instance ().down && Objects .equals (message , "> Down." ) && Minecraft . getInstance (). player != null ) {
96+ if (Config .HANDLER .instance ().down && Objects .equals (message , "> Down." )) {
9797 Mwonmod .notification ("> Down." , "> Down." );
9898 Minecraft .getInstance ().execute (() -> Minecraft .getInstance ().player .connection .sendChat ("> Down." ));
9999 }
100100 Pattern auctionPattern = Pattern .compile ("^>\\ s*(?:First up,|And next,|Next,|And now,|And lastly,|Now,|Up next,)?\\ s*(?:a|an|some)\\ s+(.+?)!$" );
101- Pattern newKingPattern = Pattern .compile ("^>\\ s*([ \\ w] +)\\ s+is\\ s+the\\ s+new\\ s+(?:king|queen|monarch)!$" );
101+ Pattern newKingPattern = Pattern .compile ("^>\\ s*(\\ w+)\\ s+is\\ s+the\\ s+new\\ s+(?:king|queen|monarch)!$" );
102102
103103 Matcher auctionMatcher = auctionPattern .matcher (message );
104104 Matcher kingMatcher = newKingPattern .matcher (message );
105105
106106 if (auctionMatcher .find ()) {
107- assert Minecraft .getInstance ().player != null ;
108107 if (Config .HANDLER .instance ().debugMode )
109108 Minecraft .getInstance ().player .displayClientMessage (net .minecraft .network .chat .Component .literal ("Auction Item: " + auctionMatcher .group (1 )), false );
110109 try {
@@ -122,7 +121,6 @@ private static void handleChatPacket(Component content, boolean overlay, Callbac
122121 Minecraft .getInstance ().player .displayClientMessage (net .minecraft .network .chat .Component .literal ("Error accessing item data: " + e .getMessage ()), false );
123122 }
124123 } else if (kingMatcher .find ()) {
125- assert Minecraft .getInstance ().player != null ;
126124 if (Config .HANDLER .instance ().kingChangeNotification ) {
127125 GameState .bank_gold = 0 ;
128126 GameState .coins = 0 ;
0 commit comments