Skip to content

Commit 246bebb

Browse files
authored
Update README.md
1 parent 9585bc1 commit 246bebb

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)