Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes weird import leftover from mappings updater #345

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tools.redstone.redstonetools.features.arguments.serializers;

import ;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
Expand Down Expand Up @@ -59,23 +58,24 @@ private T deserializeUnchecked(String serialized) {
return tryParse(serialized);
}

if(serialized.charAt(0) == '-' && serialized.chars().filter(ch -> ch == '-').count() == 1){
if (serialized.charAt(0) == '-' && serialized.chars().filter(ch -> ch == '-').count() == 1) {
isNegative = true;
serialized = serialized.replace("-","");
serialized = serialized.replace("-", "");
}

if (serialized.charAt(0) == '0') {
if(serialized.length() > 1) {
if (serialized.length() > 1) {
var prefixedBase = serialized.substring(0, 2);
var number = serialized.substring(2);

var numberBase = NumberBase.fromPrefix(prefixedBase).orElse(null);

if (numberBase != null) {
return isNegative ? tryParse("-" + number, numberBase.toInt()) : tryParse(number, numberBase.toInt());
return isNegative ? tryParse("-" + number, numberBase.toInt())
: tryParse(number, numberBase.toInt());
}
} else {
return tryParse(serialized,10);
return tryParse(serialized, 10);
}
}

Expand All @@ -94,10 +94,10 @@ private T deserializeUnchecked(String serialized) {
throw new IllegalArgumentException("Invalid base '" + parts[1] + "'.");
}

return isNegative ? tryParse("-"+number, base) : tryParse(number, base);
return isNegative ? tryParse("-" + number, base) : tryParse(number, base);
}

return isNegative ? tryParse("-"+serialized) : tryParse(serialized);
return isNegative ? tryParse("-" + serialized) : tryParse(serialized);
}

private T tryParse(String string) {
Expand All @@ -107,8 +107,8 @@ private T tryParse(String string) {
private T tryParse(String string, int radix) {
return tryParseOptional(string, radix)
.orElseThrow(() -> new IllegalArgumentException(radix == 10
? "Invalid number '" + string + "'."
: "Invalid base " + radix + " number '" + string + "'."));
? "Invalid number '" + string + "'."
: "Invalid base " + radix + " number '" + string + "'."));
}

protected abstract Optional<T> tryParseOptional(String string, int radix);
Expand Down
Loading