-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKillCommand.java
More file actions
30 lines (27 loc) · 982 Bytes
/
Copy pathKillCommand.java
File metadata and controls
30 lines (27 loc) · 982 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
30
// Register this executor for the "kill" command in your plugin.yml.
// Command: /kill [player]
public class KillCommand 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: /kill <player>");
return true;
}
target = (Player) sender;
} else {
if (!sender.hasPermission("myplugin.kill.others")) {
sender.sendMessage("§cYou don't have permission to kill other players!");
return true;
}
target = Bukkit.getPlayer(args[0]);
if (target == null) {
sender.sendMessage("§cPlayer not found!");
return true;
}
}
target.setHealth(0);
return true;
}
}