Skip to content

Commit 4b3ec0f

Browse files
committed
fix: Don't use optional reading for packet header
1 parent 6059e8e commit 4b3ec0f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import net.hypixel.modapi.serializer.PacketSerializer;
1717

1818
import java.util.List;
19-
import java.util.Optional;
2019
import java.util.concurrent.CopyOnWriteArrayList;
2120

2221
public class HypixelModAPI {
@@ -66,9 +65,9 @@ public void handle(String identifier, PacketSerializer serializer) {
6665
}
6766

6867
// All responses contain a boolean of if the response is a success, if not then a further var int is included to identify the error
69-
Optional<ErrorReason> errorReasonOptional = serializer.readOptional(PacketSerializer::readVarInt).map(ErrorReason::getById);
70-
if (errorReasonOptional.isPresent()) {
71-
throw new ModAPIException(identifier, errorReasonOptional.get());
68+
if (!serializer.readBoolean()) {
69+
ErrorReason reason = ErrorReason.getById(serializer.readVarInt());
70+
throw new ModAPIException(identifier, reason);
7271
}
7372

7473
ClientboundHypixelPacket packet = registry.createClientboundPacket(identifier, serializer);

0 commit comments

Comments
 (0)