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

Annotation of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/deprecated/ZapCommand.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1500 - (hide annotations) (download)
Sat Jun 4 11:47:19 2011 UTC (13 years ago) by torben
Original Path: miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/ZapCommand.java
File size: 1060 byte(s)
Add zap command
1 torben 1500 package dk.thoerup.bukkit.hoeruputils;
2    
3     import org.bukkit.ChatColor;
4     import org.bukkit.Location;
5     import org.bukkit.Server;
6     import org.bukkit.World;
7     import org.bukkit.command.Command;
8     import org.bukkit.command.CommandExecutor;
9     import org.bukkit.command.CommandSender;
10     import org.bukkit.entity.Player;
11    
12     public class ZapCommand implements CommandExecutor {
13    
14    
15     @Override
16     public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
17    
18     if (!(sender instanceof Player)) {
19     return false;
20     }
21    
22     Player p = (Player) sender;
23    
24     if (args.length != 1) {
25     p.sendMessage("Usage: /zap <player>");
26     return true;
27     }
28     Server server = p.getServer();
29    
30     Player target = server.getPlayer(args[0]);
31     if (target == null) {
32     p.sendMessage("/zap: could not find player " + args[0] );
33     return true;
34     }
35    
36     World w = target.getWorld();
37     Location l = target.getLocation();
38     w.strikeLightningEffect( l );
39     server.broadcastMessage( ChatColor.YELLOW + target.getName() + " was zapped by " + p.getName() );
40    
41     return true;
42     }
43     }

  ViewVC Help
Powered by ViewVC 1.1.20