Change argument order, restrict range type

This commit is contained in:
Németh Noel 2021-08-22 08:45:39 +02:00
parent 293786854b
commit f633cef273
3 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import net.minestom.server.utils.math.FloatRange;
public class ArgumentFloatRange extends ArgumentRange<FloatRange, Float> {
public ArgumentFloatRange(String id) {
super(id, Float.MIN_VALUE, Float.MAX_VALUE, Float::parseFloat, "minecraft:float_range", FloatRange::new);
super(id, "minecraft:float_range", Float.MIN_VALUE, Float.MAX_VALUE, Float::parseFloat, FloatRange::new);
}
@Override

View File

@ -10,7 +10,7 @@ import net.minestom.server.utils.math.IntRange;
public class ArgumentIntRange extends ArgumentRange<IntRange, Integer> {
public ArgumentIntRange(String id) {
super(id, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer::parseInt, "minecraft:int_range", IntRange::new);
super(id, "minecraft:int_range", Integer.MIN_VALUE, Integer.MAX_VALUE, Integer::parseInt, IntRange::new);
}
@Override

View File

@ -4,7 +4,7 @@ import net.minestom.server.command.builder.NodeMaker;
import net.minestom.server.command.builder.arguments.Argument;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import net.minestom.server.utils.math.FloatRange;
import net.minestom.server.utils.math.Range;
import org.jetbrains.annotations.NotNull;
import java.util.function.BiFunction;
@ -16,7 +16,7 @@ import java.util.regex.Pattern;
*
* @param <T> the type of the range
*/
public abstract class ArgumentRange<T, N extends Number> extends Argument<T> {
public abstract class ArgumentRange<T extends Range<N>, N extends Number> extends Argument<T> {
public static final int FORMAT_ERROR = -1;
private final N min;
@ -25,7 +25,7 @@ public abstract class ArgumentRange<T, N extends Number> extends Argument<T> {
private final String parserName;
private final BiFunction<N, N, T> rangeConstructor;
public ArgumentRange(@NotNull String id, N min, N max, Function<String, N> parser, String parserName, BiFunction<N, N, T> rangeConstructor) {
public ArgumentRange(@NotNull String id, String parserName, N min, N max, Function<String, N> parser, BiFunction<N, N, T> rangeConstructor) {
super(id);
this.min = min;
this.max = max;