Skip to content

Commit f4c52d3

Browse files
committed
Use generics for custom parameters to generate compile-time errors
1 parent 56da909 commit f4c52d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/me/despical/commandframework/CommandFramework.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class CommandFramework implements CommandExecutor, TabCompleter {
7979
* Map of custom parameters for command methods.
8080
*/
8181
@NotNull
82-
private final Map<String, Function<CommandArguments, Object>> customParametersMap = new HashMap<>();
82+
private final Map<String, Function<CommandArguments, ?>> customParametersMap = new HashMap<>();
8383
/**
8484
* Function to apply if there is no matched commands related framework.
8585
* <p>
@@ -130,7 +130,7 @@ public void setMatchFunction(@NotNull Function<CommandArguments, Boolean> matchF
130130
this.matchFunction = matchFunction;
131131
}
132132

133-
public void addCustomParameter(@NotNull Class<?> instanceClass, @NotNull Function<CommandArguments, Object> function) {
133+
public <A, B extends A> void addCustomParameter(@NotNull Class<A> instanceClass, @NotNull Function<CommandArguments, B> function) {
134134
final String simpleName = instanceClass.getSimpleName();
135135

136136
if (this.customParametersMap.containsKey(simpleName))

0 commit comments

Comments
 (0)