From 710ec9b6e7493dea4d8b94634b868d8ffbaded72 Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 29 Dec 2020 22:45:49 +0100 Subject: [PATCH] Add API in Argument --- .../src/de/steamwar/commandn/Argument.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/commandn/Argument.java b/SpigotCore_Main/src/de/steamwar/commandn/Argument.java index 9a574f3..92eb7d4 100644 --- a/SpigotCore_Main/src/de/steamwar/commandn/Argument.java +++ b/SpigotCore_Main/src/de/steamwar/commandn/Argument.java @@ -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 parse(CommandSender sender, String arg); + T parse(String arg) throws InvalidArgumentException; + void checkConstraints(CommandSender sender, T argument) throws InvalidArgumentException; + List tabComplete(CommandSender sender, String arg) throws InvalidArgumentException; + default BiPredicate tabCompleteFilter() { + return String::startsWith; + } abstract class IntArgument implements Argument { @Override - public Integer parse(CommandSender sender, String arg) { + public Integer parse(String arg) { return Integer.parseInt(arg); } } abstract class DoubleArgument implements Argument { @Override - public Double parse(CommandSender sender, String arg) { + public Double parse(String arg) { return Double.parseDouble(arg); } }