Skip to content

Commit 0a72194

Browse files
committed
removed unused param
1 parent f27c8f4 commit 0a72194

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

src/main/java/net/azalealibrary/configuration/property/ConfigurableProperty.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public abstract class ConfigurableProperty<T, P> {
1818
protected final List<AssignmentPolicy<T>> policies;
1919
protected final String name;
2020
protected final Consumer<P> callback;
21-
private final List<String> description;
22-
private final Supplier<P> defaultValue;
23-
private @Nullable P value;
21+
protected final List<String> description;
22+
protected final Supplier<P> defaultValue;
23+
protected @Nullable P value;
2424

2525
protected ConfigurableProperty(PropertyType<T> propertyType, Supplier<P> defaultValue, String name, List<String> description, Consumer<P> callback, List<AssignmentPolicy<T>> policies) {
2626
this.propertyType = propertyType;
@@ -79,9 +79,8 @@ public void onExecute(CommandSender sender, Arguments arguments) {
7979
set(sender, arguments);
8080
}
8181

82-
@SuppressWarnings("unchecked")
8382
public List<String> onComplete(CommandSender sender, Arguments arguments) {
84-
return propertyType.complete(sender, arguments, (T) get());
83+
return propertyType.complete(sender, arguments);
8584
}
8685

8786
protected abstract void set(CommandSender sender, Arguments arguments);

src/main/java/net/azalealibrary/configuration/property/ListProperty.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected void set(CommandSender sender, Arguments arguments) {
2828
String action = arguments.matchesAny(0, "list operation", ADD, REMOVE, REPLACE);
2929

3030
if (action.equals(ADD)) {
31-
get().add(verify(propertyType.parse(sender, arguments.subArguments(1), null)));
31+
get().add(verify(propertyType.parse(sender, arguments.subArguments(1))));
3232
callback.accept(get());
3333
} else {
3434
int index = arguments.find(1, "position", input -> Integer.parseInt(input.replace("@", "")));
@@ -38,7 +38,7 @@ protected void set(CommandSender sender, Arguments arguments) {
3838
}
3939

4040
if (action.equals(REPLACE)) {
41-
get().set(index, verify(propertyType.parse(sender, arguments.subArguments(2), null)));
41+
get().set(index, verify(propertyType.parse(sender, arguments.subArguments(2))));
4242
callback.accept(get());
4343
} else {
4444
get().remove(index);
@@ -56,7 +56,7 @@ public List<String> onComplete(CommandSender sender, Arguments arguments) {
5656
} else if (arguments.is(0, ADD) || arguments.is(0, REPLACE)) {
5757
// avoid suggesting more than necessary
5858
Arguments data = arguments.subArguments(arguments.is(0, ADD) ? 0 : 1);
59-
List<String> suggestion = propertyType.complete(sender, data, null);
59+
List<String> suggestion = propertyType.complete(sender, data);
6060
return arguments.size() -1 <= suggestion.size() ? suggestion : List.of();
6161
}
6262
return List.of();

src/main/java/net/azalealibrary/configuration/property/Property.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private Property(PropertyType<T> type, Supplier<T> defaultValue, String name, Li
1919

2020
@Override
2121
protected void set(CommandSender sender, Arguments arguments) {
22-
set(verify(propertyType.parse(sender, arguments, get())));
22+
set(verify(propertyType.parse(sender, arguments)));
2323
callback.accept(get());
2424
}
2525

src/main/java/net/azalealibrary/configuration/property/PropertyType.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.bukkit.entity.Player;
1111
import org.bukkit.util.Vector;
1212

13-
import javax.annotation.Nullable;
1413
import java.util.List;
1514
import 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

Comments
 (0)