-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Worked on switching some Serializer classes to ArgumentType classes a…
…nd adding the serializers as subclasses.
- Loading branch information
1 parent
64a7d47
commit 10d9b82
Showing
18 changed files
with
198 additions
and
98 deletions.
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
src/main/java/tools/redstone/redstonetools/RedstoneToolsClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...a/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerArgumentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package tools.redstone.redstonetools.features.arguments.serializers; | ||
|
||
import net.minecraft.command.CommandRegistryAccess; | ||
import net.minecraft.command.argument.serialize.ArgumentSerializer; | ||
|
||
import java.math.BigInteger; | ||
import java.util.Optional; | ||
|
||
public class BigIntegerArgumentType extends IntLikeArgumentType<BigInteger> { | ||
private static final BigIntegerArgumentType INSTANCE = new BigIntegerArgumentType(null, null); | ||
|
||
public static BigIntegerArgumentType bigInteger() { | ||
return INSTANCE; | ||
} | ||
|
||
public static BigIntegerArgumentType bigInteger(BigInteger min) { | ||
return new BigIntegerArgumentType(min, null); | ||
} | ||
|
||
public static BigIntegerArgumentType bigInteger(BigInteger min, BigInteger max) { | ||
return new BigIntegerArgumentType(min, max); | ||
} | ||
|
||
private BigIntegerArgumentType(BigInteger min, BigInteger max) { | ||
super(BigInteger.class, min, max); | ||
|
||
} | ||
|
||
@Override | ||
protected Optional<BigInteger> tryParseOptional(String string, int radix) { | ||
try { | ||
return Optional.of(new BigInteger(string, radix)); | ||
} catch (NumberFormatException ignored) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public static class BigIntegerSerializer extends Serializer<BigIntegerArgumentType, ArgumentSerializer.ArgumentTypeProperties<BigIntegerArgumentType>>{ | ||
|
||
@Override | ||
public ArgumentTypeProperties<BigIntegerArgumentType> getArgumentTypeProperties(BigIntegerArgumentType argumentType) { | ||
return new Properties(argumentType.max,argumentType.min); | ||
} | ||
|
||
public final class Properties | ||
implements ArgumentSerializer.ArgumentTypeProperties<BigIntegerArgumentType>{ | ||
final BigInteger max, min; | ||
|
||
public Properties(BigInteger max, BigInteger min) { | ||
this.max = max; | ||
this.min = min; | ||
} | ||
|
||
@Override | ||
public BigIntegerArgumentType createType(CommandRegistryAccess commandRegistryAccess) { | ||
return new BigIntegerArgumentType(this.max,this.min); | ||
} | ||
|
||
@Override | ||
public ArgumentSerializer<BigIntegerArgumentType, ?> getSerializer() { | ||
return BigIntegerSerializer.this; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
33 changes: 0 additions & 33 deletions
33
...ava/tools/redstone/redstonetools/features/arguments/serializers/BigIntegerSerializer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.