File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -70,15 +70,27 @@ public class ItemStackCommand {
7070* Example provider
7171
7272``` java
73- public class ItemStackProvider implements CommandProvider<ItemStack > {
73+ public class PlayerCommandProvider implements CommandProvider<Player > {
74+
75+ private final JavaPlugin javaPlugin;
76+
77+ public PlayerCommandProvider (JavaPlugin javaPlugin ) {
78+ this . javaPlugin = javaPlugin;
79+ }
7480
7581 @Override
76- public ItemStack provide (String s ) throws CommandProviderNullException {
82+ public Player provide (String s ) throws CommandProviderNullException {
83+ final Player player = javaPlugin. getServer(). getPlayer(s);
7784
78- if (! s . equalsIgnoreCase( " itemStack " ) )
79- throw new CommandProviderNullException (ChatColor . RED + " You need to type 'itemStack' to get this provider !" );
85+ if (player == null )
86+ throw new CommandProviderNullException (ChatColor . RED + " The player you specified is not online or does not exist !" );
8087
81- return new ItemStack (Material . DIRT );
88+ return player;
89+ }
90+
91+ @Override
92+ public List<String > suggestions (CommandParameter commandParameter ) {
93+ return javaPlugin. getServer(). getOnlinePlayers(). stream(). map(HumanEntity :: getName). collect(Collectors . toList());
8294 }
8395
8496}
You can’t perform that action at this time.
0 commit comments