@@ -20,13 +20,13 @@ public class PropertyType<T> {
2020 public static final PropertyType <Integer > INTEGER = new PropertyType <>(Integer .class ) {
2121 @ Override
2222 public Integer parse (CommandSender sender , Arguments arguments , @ Nullable Integer currentValue ) {
23- return Integer .parseInt (arguments .getLast ( ));
23+ return Integer .parseInt (arguments .get ( 0 ));
2424 }
2525 };
2626 public static final PropertyType <Double > DOUBLE = new PropertyType <>(Double .class , "decimal" ) {
2727 @ Override
2828 public Double parse (CommandSender sender , Arguments arguments , @ Nullable Double currentValue ) {
29- return Double .parseDouble (arguments .getLast ( ));
29+ return Double .parseDouble (arguments .get ( 0 ));
3030 }
3131 };
3232 public static final PropertyType <Boolean > BOOLEAN = new PropertyType <>(Boolean .class ) {
@@ -35,7 +35,7 @@ public Boolean parse(CommandSender sender, Arguments arguments, @Nullable Boolea
3535 if (!arguments .is (0 , "true" ) && !arguments .is (0 , "false" )) {
3636 throw new AzaleaException (); // ensure explicit "true" or "false" text has been provided
3737 }
38- return Boolean .parseBoolean (arguments .getLast ( ));
38+ return Boolean .parseBoolean (arguments .get ( 0 ));
3939 }
4040
4141 @ Override
@@ -129,7 +129,7 @@ public List<String> complete(CommandSender sender, Arguments arguments, @Nullabl
129129
130130 @ Override
131131 public World parse (CommandSender sender , Arguments arguments , @ Nullable World currentValue ) {
132- return Bukkit .getWorld (arguments .getLast ( ));
132+ return Bukkit .getWorld (arguments .get ( 0 ));
133133 }
134134
135135 @ Override
@@ -173,7 +173,7 @@ public List<String> complete(CommandSender sender, Arguments arguments, @Nullabl
173173 }
174174
175175 public T parse (CommandSender sender , Arguments arguments , @ Nullable T currentValue ) {
176- return (T ) arguments .getLast ( );
176+ return (T ) arguments .get ( 0 );
177177 }
178178
179179 public Object serialize (T object ) {
@@ -188,6 +188,16 @@ public String print(T object) {
188188 return object .toString ();
189189 }
190190
191+ // TODO - review
192+ public boolean test (CommandSender sender , Arguments arguments ) {
193+ try {
194+ parse (sender , arguments , null );
195+ return true ;
196+ } catch (Exception exception ) {
197+ return false ;
198+ }
199+ }
200+
191201 @ Override
192202 public boolean equals (Object object ) {
193203 if (object instanceof PropertyType <?> propertyType ) {
0 commit comments