/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/OpkillCommand.java
ViewVC logotype

Contents of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/OpkillCommand.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3201 - (show annotations) (download)
Wed May 31 08:56:00 2017 UTC (6 years, 11 months ago) by torben
File size: 947 byte(s)
Code cleanup(still doesn't compile)
1 package dk.thoerup.bukkit.hoeruputils;
2
3 import org.bukkit.ChatColor;
4 import org.bukkit.command.Command;
5 import org.bukkit.command.CommandExecutor;
6 import org.bukkit.command.CommandSender;
7 import org.bukkit.entity.Player;
8
9 public class OpkillCommand implements CommandExecutor {
10
11 @Override
12 public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
13 if (! (sender instanceof Player) ) {
14 return false;
15 }
16
17 Player p = (Player) sender;
18
19 if (! p.isOp() ) {
20 p.sendMessage("Only server operators may use this command");
21 return true;
22 }
23
24 if (args.length != 1) {
25 p.sendMessage("Usage: /opkill <player>");
26 return true;
27 }
28
29
30 @SuppressWarnings("deprecation")
31 Player p2 = p.getServer().getPlayer(args[0]);
32
33 p2.setHealth(0);
34 p.getServer().broadcastMessage( ChatColor.YELLOW + p2.getName() + " was slained by server operator (" + p.getName() + ")" );
35
36
37
38 return true;
39 }
40
41 }

  ViewVC Help
Powered by ViewVC 1.1.20