🐛 Fix float/double arguments
This commit is contained in:
parent
63dce244aa
commit
c4abf4eca3
3 changed files with 18 additions and 4 deletions
|
|
@ -123,8 +123,8 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
|
||||||
|
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Double> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Double> {
|
||||||
|
|
||||||
private double min = Double.MIN_VALUE;
|
private double min = Double.NEGATIVE_INFINITY;
|
||||||
private double max = Double.MAX_VALUE;
|
private double max = Double.POSITIVE_INFINITY;
|
||||||
|
|
||||||
protected Builder(final @NonNull String name) {
|
protected Builder(final @NonNull String name) {
|
||||||
super(Double.class, name);
|
super(Double.class, name);
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,8 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
|
||||||
|
|
||||||
public static final class Builder<C> extends CommandArgument.Builder<C, Float> {
|
public static final class Builder<C> extends CommandArgument.Builder<C, Float> {
|
||||||
|
|
||||||
private float min = Float.MIN_VALUE;
|
private float min = Float.NEGATIVE_INFINITY;
|
||||||
private float max = Float.MAX_VALUE;
|
private float max = Float.POSITIVE_INFINITY;
|
||||||
|
|
||||||
protected Builder(final @NonNull String name) {
|
protected Builder(final @NonNull String name) {
|
||||||
super(Float.class, name);
|
super(Float.class, name);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ package cloud.commandframework;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import cloud.commandframework.arguments.compound.ArgumentPair;
|
import cloud.commandframework.arguments.compound.ArgumentPair;
|
||||||
import cloud.commandframework.arguments.standard.EnumArgument;
|
import cloud.commandframework.arguments.standard.EnumArgument;
|
||||||
|
import cloud.commandframework.arguments.standard.FloatArgument;
|
||||||
import cloud.commandframework.arguments.standard.IntegerArgument;
|
import cloud.commandframework.arguments.standard.IntegerArgument;
|
||||||
import cloud.commandframework.arguments.standard.StringArgument;
|
import cloud.commandframework.arguments.standard.StringArgument;
|
||||||
import cloud.commandframework.context.CommandContext;
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
|
@ -126,6 +127,13 @@ class CommandTreeTest {
|
||||||
System.out.println("Enum: " + c.flags().getValue("enum", FlagEnum.PROXI));
|
System.out.println("Enum: " + c.flags().getValue("enum", FlagEnum.PROXI));
|
||||||
})
|
})
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
/* Build command for testing float */
|
||||||
|
manager.command(manager.commandBuilder("float")
|
||||||
|
.argument(FloatArgument.of("num"))
|
||||||
|
.handler(c -> {
|
||||||
|
System.out.printf("%f\n", c.<Float>get("num"));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -238,6 +246,12 @@ class CommandTreeTest {
|
||||||
manager.command(manager.commandBuilder("two").argument(argument)));
|
manager.command(manager.commandBuilder("two").argument(argument)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFloats() {
|
||||||
|
manager.executeCommand(new TestCommandSender(), "float 0.0").join();
|
||||||
|
manager.executeCommand(new TestCommandSender(), "float 100").join();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final class SpecificCommandSender extends TestCommandSender {
|
public static final class SpecificCommandSender extends TestCommandSender {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue