Skip to content

Commit

Permalink
Do not throw an exception twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed Nov 6, 2023
1 parent a63a1d7 commit 1d956c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public T getType(int id) {
return value;
}

public T getTypeUnsafe(int id) {
return toObject.get(id);
}

public Builder<T> toBuilder() {
Builder<T> builder = new Builder<>(type);
this.toObject.forEach(builder::insert);
Expand Down

0 comments on commit 1d956c0

Please sign in to comment.