SteamWar/SpigotCore
Archiviert
13
0

Add API in Argument

Dieser Commit ist enthalten in:
jojo 2020-12-29 22:45:49 +01:00
Ursprung 80b85e3ee9
Commit 710ec9b6e7

Datei anzeigen

@ -24,22 +24,28 @@ package de.steamwar.commandn;
import org.bukkit.command.CommandSender;
import java.util.List;
import java.util.function.BiPredicate;
public interface Argument<T> {
T parse(CommandSender sender, String arg);
T parse(String arg) throws InvalidArgumentException;
void checkConstraints(CommandSender sender, T argument) throws InvalidArgumentException;
List<String> tabComplete(CommandSender sender, String arg) throws InvalidArgumentException;
default BiPredicate<String, String> tabCompleteFilter() {
return String::startsWith;
}
abstract class IntArgument implements Argument<Integer> {
@Override
public Integer parse(CommandSender sender, String arg) {
public Integer parse(String arg) {
return Integer.parseInt(arg);
}
}
abstract class DoubleArgument implements Argument<Double> {
@Override
public Double parse(CommandSender sender, String arg) {
public Double parse(String arg) {
return Double.parseDouble(arg);
}
}