Skip to content

Commit b12ee6f

Browse files
committed
Added new method to add custom parameter provider using the class
1 parent b494ea3 commit b12ee6f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ public final <A, B extends A> void addCustomParameter(@NotNull String value, @No
142142
this.parameterHandler.addCustomParameter(value, function);
143143
}
144144

145+
/**
146+
* Adds a custom parameter to the parameter handler using a class type.
147+
*
148+
* <p>This method allows the addition of a custom parameter to the parameter handler by specifying
149+
* a class and a function that converts {@link CommandArguments} to an instance of {@link T}.
150+
* <p>
151+
* The parameter will be registered using the {@link Class#getSimpleName()} as the key.
152+
*
153+
* @param <T> the type of the custom parameter
154+
* @param clazz the class of the custom parameter, used to derive the key using {@link Class#getSimpleName()},
155+
* must not be null
156+
* @param function a function that takes {@link CommandArguments} and returns an instance of {@link T},
157+
* must not be null
158+
*
159+
* @throws me.despical.commandframework.exceptions.CommandException if a custom parameter with the same class name is already registered
160+
*/
161+
public final <T> void addCustomParameter(@NotNull Class<T> clazz, @NotNull Function<CommandArguments, T> function) {
162+
this.parameterHandler.addCustomParameter(clazz, function);
163+
}
164+
145165
/**
146166
* Returns the logger instance of Command Framework. By default, logger is {@link #plugin} 's logger.
147167
*

0 commit comments

Comments
 (0)