-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeedCommand.java
More file actions
28 lines (25 loc) · 875 Bytes
/
Copy pathFeedCommand.java
File metadata and controls
28 lines (25 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Register this executor for the "feed" command in your plugin.yml.
// Command: /feed [player]
public class FeedCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player target;
if (args.length == 0) {
if (!(sender instanceof Player)) {
sender.sendMessage("§cUsage: /feed <player>");
return true;
}
target = (Player) sender;
} else {
target = Bukkit.getPlayer(args[0]);
if (target == null) {
sender.sendMessage("§cPlayer not found!");
return true;
}
}
target.setFoodLevel(20);
target.setSaturation(20f);
target.sendMessage("§aYou have been fed!");
return true;
}
}