1010import org .bukkit .entity .Player ;
1111import org .bukkit .util .Vector ;
1212
13- import javax .annotation .Nullable ;
1413import java .util .List ;
1514import java .util .UUID ;
1615
@@ -20,45 +19,45 @@ public class PropertyType<T> {
2019 public static final PropertyType <String > STRING = new PropertyType <>(String .class , "text" );
2120 public static final PropertyType <Integer > INTEGER = new PropertyType <>(Integer .class ) {
2221 @ Override
23- public Integer parse (CommandSender sender , Arguments arguments , @ Nullable Integer currentValue ) {
22+ public Integer parse (CommandSender sender , Arguments arguments ) {
2423 return Integer .parseInt (arguments .get (0 ));
2524 }
2625 };
2726 public static final PropertyType <Double > DOUBLE = new PropertyType <>(Double .class , "decimal" ) {
2827 @ Override
29- public Double parse (CommandSender sender , Arguments arguments , @ Nullable Double currentValue ) {
28+ public Double parse (CommandSender sender , Arguments arguments ) {
3029 return Double .parseDouble (arguments .get (0 ));
3130 }
3231 };
3332 public static final PropertyType <Boolean > BOOLEAN = new PropertyType <>(Boolean .class ) {
3433 @ Override
35- public Boolean parse (CommandSender sender , Arguments arguments , @ Nullable Boolean currentValue ) {
34+ public Boolean parse (CommandSender sender , Arguments arguments ) {
3635 if (!arguments .is (0 , "true" ) && !arguments .is (0 , "false" )) {
3736 throw new AzaleaException (); // ensure explicit "true" or "false" text has been provided
3837 }
3938 return Boolean .parseBoolean (arguments .get (0 ));
4039 }
4140
4241 @ Override
43- public List <String > complete (CommandSender sender , Arguments arguments , @ Nullable Boolean currentValue ) {
44- return List .of (Boolean . toString ( Boolean . FALSE . equals ( currentValue )) );
42+ public List <String > complete (CommandSender sender , Arguments arguments ) {
43+ return List .of ("true" , "false" );
4544 }
4645 };
4746 public static final PropertyType <Vector > VECTOR = new PropertyType <>(Vector .class ) {
4847 @ Override
49- public List <String > complete (CommandSender sender , Arguments arguments , @ Nullable Vector currentValue ) {
48+ public List <String > complete (CommandSender sender , Arguments arguments ) {
5049 if (sender instanceof Player player ) {
5150 Location location = player .getLocation ();
5251 double x = location .getBlockX () + .5 ;
5352 double y = location .getBlockY () + .5 ;
5453 double z = location .getBlockZ () + .5 ;
5554 return List .of (x + " " + y + " " + z );
5655 }
57- return super .complete (sender , arguments , currentValue );
56+ return super .complete (sender , arguments );
5857 }
5958
6059 @ Override
61- public Vector parse (CommandSender sender , Arguments arguments , @ Nullable Vector currentValue ) {
60+ public Vector parse (CommandSender sender , Arguments arguments ) {
6261 double x = arguments .find (0 , "x" , Double ::parseDouble );
6362 double y = arguments .find (1 , "y" , Double ::parseDouble );
6463 double z = arguments .find (2 , "z" , Double ::parseDouble );
@@ -67,7 +66,7 @@ public Vector parse(CommandSender sender, Arguments arguments, @Nullable Vector
6766 };
6867 public static final PropertyType <Location > LOCATION = new PropertyType <>(Location .class , "position" ) {
6968 @ Override
70- public List <String > complete (CommandSender sender , Arguments arguments , @ Nullable Location currentValue ) {
69+ public List <String > complete (CommandSender sender , Arguments arguments ) {
7170 if (sender instanceof Player player ) {
7271 Location location = player .getLocation ();
7372 double x = location .getBlockX () + .5 ;
@@ -77,11 +76,11 @@ public List<String> complete(CommandSender sender, Arguments arguments, @Nullabl
7776 float pitch = location .getPitch ();
7877 return List .of (x + " " + y + " " + z + " " + yaw + " " + pitch );
7978 }
80- return super .complete (sender , arguments , currentValue );
79+ return super .complete (sender , arguments );
8180 }
8281
8382 @ Override
84- public Location parse (CommandSender sender , Arguments arguments , @ Nullable Location currentValue ) {
83+ public Location parse (CommandSender sender , Arguments arguments ) {
8584 if (sender instanceof Player player ) {
8685 double x = arguments .find (0 , "x" , Double ::parseDouble );
8786 double y = arguments .find (1 , "y" , Double ::parseDouble );
@@ -90,20 +89,20 @@ public Location parse(CommandSender sender, Arguments arguments, @Nullable Locat
9089 float pitch = arguments .find (4 , "pitch" , Float ::parseFloat );
9190 return new Location (player .getWorld (), x , y , z , yaw , pitch );
9291 }
93- return super .parse (sender , arguments , currentValue );
92+ return super .parse (sender , arguments );
9493 }
9594 };
9695 public static final PropertyType <Player > PLAYER = new PropertyType <>(Player .class ) {
9796 @ Override
98- public List <String > complete (CommandSender sender , Arguments arguments , @ Nullable Player currentValue ) {
97+ public List <String > complete (CommandSender sender , Arguments arguments ) {
9998 if (sender instanceof Player player ) {
10099 return player .getWorld ().getPlayers ().stream ().map (Player ::getDisplayName ).toList ();
101100 }
102- return super .complete (sender , arguments , currentValue );
101+ return super .complete (sender , arguments );
103102 }
104103
105104 @ Override
106- public Player parse (CommandSender sender , Arguments arguments , @ Nullable Player currentValue ) {
105+ public Player parse (CommandSender sender , Arguments arguments ) {
107106 return (Player ) sender ;
108107 }
109108
@@ -124,12 +123,12 @@ public String print(Player object) {
124123 };
125124 public static final PropertyType <World > WORLD = new PropertyType <>(World .class ) {
126125 @ Override
127- public List <String > complete (CommandSender sender , Arguments arguments , @ Nullable World currentValue ) {
126+ public List <String > complete (CommandSender sender , Arguments arguments ) {
128127 return Bukkit .getServer ().getWorlds ().stream ().map (World ::getName ).toList ();
129128 }
130129
131130 @ Override
132- public World parse (CommandSender sender , Arguments arguments , @ Nullable World currentValue ) {
131+ public World parse (CommandSender sender , Arguments arguments ) {
133132 return Bukkit .getWorld (arguments .get (0 ));
134133 }
135134
@@ -169,11 +168,11 @@ public final String getExpected() {
169168 return StringUtils .capitalize (expected .toLowerCase ());
170169 }
171170
172- public List <String > complete (CommandSender sender , Arguments arguments , @ Nullable T currentValue ) {
171+ public List <String > complete (CommandSender sender , Arguments arguments ) {
173172 return arguments .size () == 1 ? List .of ("<" + expected + ">" ) : List .of ();
174173 }
175174
176- public T parse (CommandSender sender , Arguments arguments , @ Nullable T currentValue ) {
175+ public T parse (CommandSender sender , Arguments arguments ) {
177176 return (T ) arguments .get (0 );
178177 }
179178
@@ -192,7 +191,7 @@ public String print(T object) {
192191 // TODO - review
193192 public boolean test (CommandSender sender , Arguments arguments ) {
194193 try {
195- parse (sender , arguments , null );
194+ parse (sender , arguments );
196195 return true ;
197196 } catch (Exception exception ) {
198197 return false ;
0 commit comments