File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
src/main/java/xyz/damt/command Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ public CommandHandler(JavaPlugin javaPlugin) {
4444 * @return {@link CommandHandler}
4545 */
4646
47- public final CommandHandler bind (Class <? > clazz , CommandProvider <? > commandProvider ) {
47+ public final < T > CommandHandler bind (Class <T > clazz , CommandProvider <T > commandProvider ) {
4848 commandProviderHandler .register (clazz , commandProvider );
4949 return this ;
5050 }
Original file line number Diff line number Diff line change 1010import java .lang .reflect .Parameter ;
1111import java .util .HashMap ;
1212import java .util .Map ;
13+ import java .util .UUID ;
1314
1415public class CommandProviderHandler {
1516
@@ -37,6 +38,7 @@ private final void init() {
3738 this .register (Float .class , new FloatCommandProvider ());
3839 this .register (Boolean .class , new BooleanCommandProvider ());
3940 this .register (Double .class , new DoubleCommandProvider ());
41+ this .register (UUID .class , new UUIDCommandProvider ());
4042 this .register (String [].class , new StringArrayCommandProvider ());
4143
4244 this .register (Player .class , new PlayerCommandProvider (commandHandler .getJavaPlugin ()));
Original file line number Diff line number Diff line change 1+ package xyz .damt .command .provider .impl .normal ;
2+
3+ import org .bukkit .ChatColor ;
4+ import xyz .damt .command .exception .CommandProviderNullException ;
5+ import xyz .damt .command .provider .CommandProvider ;
6+
7+ import java .util .UUID ;
8+
9+ public class UUIDCommandProvider implements CommandProvider <UUID > {
10+
11+ @ Override
12+ public UUID provide (String s ) throws CommandProviderNullException {
13+ UUID uuid ;
14+
15+ try {
16+ uuid = UUID .fromString (s );
17+ } catch (Exception exception ) {
18+ throw new CommandProviderNullException (ChatColor .RED + "The UUID you have inputted is not valid!" );
19+ }
20+
21+ return uuid ;
22+ }
23+
24+ }
You can’t perform that action at this time.
0 commit comments