Skip to content

Commit

Permalink
Merge pull request #192 from RedstoneTools/dev
Browse files Browse the repository at this point in the history
Update 1.1.1
  • Loading branch information
Matthias1590 authored May 29, 2023
2 parents c6b6408 + ebaeab2 commit 4d44458
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx4G
loader_version=0.14.6

# Mod Properties
mod_version = 1.18.2-1.1.0
mod_version = 1.18.2-1.1.1
maven_group = tools.redstone
archives_base_name = redstonetools

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,28 @@ private T deserializeUnchecked(String serialized) {
case 'o' -> NumberBase.OCTAL;
case 'd' -> NumberBase.DECIMAL;
case 'x' -> NumberBase.HEXADECIMAL;
default -> throw new IllegalArgumentException("Invalid base '" + prefixedBase.charAt(1) + "'.");
default -> null;
};

return tryParse(number, numberBase.toInt());
if (numberBase != null) {
return tryParse(number, numberBase.toInt());
}
}

// TODO(Error handling): Add some checks here to make sure the specified base is valid
var parts = serialized.split("_", 2);
if (parts.length == 2) {
var number = parts[0];
var base = Integer.parseInt(parts[1]);

int base;
try {
base = Integer.parseInt(parts[1]);

if (2 > base || base > 36) {
throw new NumberFormatException();
}
} catch (NumberFormatException ignored) {
throw new IllegalArgumentException("Invalid base '" + parts[1] + "'.");
}

return tryParse(number, base);
}
Expand Down

0 comments on commit 4d44458

Please sign in to comment.