diff --git a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/AvailableCommandsSerializer_v291.java b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/AvailableCommandsSerializer_v291.java index 2e0b5b238..43f996b19 100644 --- a/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/AvailableCommandsSerializer_v291.java +++ b/bedrock-codec/src/main/java/org/cloudburstmc/protocol/bedrock/codec/v291/serializer/AvailableCommandsSerializer_v291.java @@ -258,10 +258,8 @@ protected CommandParamData readParameter(ByteBuf buffer, BedrockCodecHelper help param.setEnumData(enums.get(symbol & ~(ARG_FLAG_ENUM | ARG_FLAG_VALID))); } else { int parameterTypeId = symbol & ~ARG_FLAG_VALID; - try { - CommandParam type = paramTypeMap.getType(parameterTypeId); - param.setType(type); - } catch (NullPointerException e) { + CommandParam type = paramTypeMap.getTypeUnsafe(parameterTypeId); + if (type == null) { throw new IllegalStateException("Invalid parameter type: " + parameterTypeId + ", Symbol: " + symbol); } } diff --git a/common/src/main/java/org/cloudburstmc/protocol/common/util/TypeMap.java b/common/src/main/java/org/cloudburstmc/protocol/common/util/TypeMap.java index d69aa71c5..c7d14edcb 100644 --- a/common/src/main/java/org/cloudburstmc/protocol/common/util/TypeMap.java +++ b/common/src/main/java/org/cloudburstmc/protocol/common/util/TypeMap.java @@ -50,6 +50,10 @@ public T getType(int id) { return value; } + public T getTypeUnsafe(int id) { + return toObject.get(id); + } + public Builder toBuilder() { Builder builder = new Builder<>(type); this.toObject.forEach(builder::insert);