-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealCommand.java
More file actions
29 lines (26 loc) · 927 Bytes
/
Copy pathHealCommand.java
File metadata and controls
29 lines (26 loc) · 927 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
29
// Register this executor for the "heal" command in your plugin.yml.
// Command: /heal [player]
public class HealCommand 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: /heal <player>");
return true;
}
target = (Player) sender;
} else {
target = Bukkit.getPlayer(args[0]);
if (target == null) {
sender.sendMessage("§cPlayer not found!");
return true;
}
}
target.setHealth(target.getMaxHealth());
target.setFoodLevel(20);
target.setSaturation(20f);
target.sendMessage("§aYou have been healed!");
return true;
}
}