Skip to content

Commit f926c79

Browse files
committed
fix: don't try and send register packet if the sender is not ready
1 parent 0b1c8fd commit f926c79

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/net/hypixel/modapi/HypixelModAPI.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import net.hypixel.modapi.packet.HypixelPacket;
99
import net.hypixel.modapi.packet.PacketRegistry;
1010
import net.hypixel.modapi.packet.impl.clientbound.*;
11-
import net.hypixel.modapi.packet.impl.clientbound.ClientboundHelloPacket;
1211
import net.hypixel.modapi.packet.impl.clientbound.event.ClientboundLocationPacket;
13-
import net.hypixel.modapi.packet.impl.serverbound.*;
12+
import net.hypixel.modapi.packet.impl.serverbound.ServerboundPartyInfoPacket;
13+
import net.hypixel.modapi.packet.impl.serverbound.ServerboundPingPacket;
14+
import net.hypixel.modapi.packet.impl.serverbound.ServerboundPlayerInfoPacket;
15+
import net.hypixel.modapi.packet.impl.serverbound.ServerboundRegisterPacket;
1416
import net.hypixel.modapi.serializer.PacketSerializer;
1517

1618
import java.util.*;
@@ -92,6 +94,11 @@ public void subscribeToEventPacket(Class<? extends EventPacket> packet) {
9294
}
9395

9496
private void sendRegisterPacket(boolean alwaysSendIfNotEmpty) {
97+
if (packetSender == null) {
98+
// Allow registering events before the mod has fully initialized
99+
return;
100+
}
101+
95102
if (lastSubscribedEvents.equals(subscribedEvents) && !(alwaysSendIfNotEmpty && !subscribedEvents.isEmpty())) {
96103
return;
97104
}

0 commit comments

Comments
 (0)