Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
KillCommand.java
1 package org.bukkit.command.defaults;
2 
3 import java.util.List;
4 
5 import org.apache.commons.lang.Validate;
6 import org.bukkit.Bukkit;
8 import org.bukkit.entity.Player;
10 
11 import com.google.common.collect.ImmutableList;
12 
13 public class KillCommand extends VanillaCommand {
14  public KillCommand() {
15  super("kill");
16  this.description = "Commits suicide, only usable as a player";
17  this.usageMessage = "/kill";
18  this.setPermission("bukkit.command.kill");
19  }
20 
21  @Override
22  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
23  if (!testPermission(sender)) return true;
24 
25  if (sender instanceof Player) {
26  Player player = (Player) sender;
27 
30  if (ede.isCancelled()) return true;
31 
32  ede.getEntity().setLastDamageCause(ede);
33  player.setHealth(0);
34  sender.sendMessage("Ouch. That look like it hurt.");
35  } else {
36  sender.sendMessage("You can only perform this command as a player");
37  }
38 
39  return true;
40  }
41 
42  @Override
43  public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
44  Validate.notNull(sender, "Sender cannot be null");
45  Validate.notNull(args, "Arguments cannot be null");
46  Validate.notNull(alias, "Alias cannot be null");
47 
48  return ImmutableList.of();
49  }
50 }
boolean testPermission(CommandSender target)
void setLastDamageCause(EntityDamageEvent event)
void setHealth(double health)
void sendMessage(String message)
void setPermission(String permission)
static PluginManager getPluginManager()
Definition: Bukkit.java:208