/[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 1684 - (hide annotations) (download)
Fri Jan 27 12:21:27 2012 UTC (12 years, 4 months ago) by torben
File size: 1427 byte(s)
move source to mvn structure
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 torben 1502 if (args.length <1 || args.length > 2) {
25     p.sendMessage("Usage: /zap <player> [hard]");
26 torben 1500 return true;
27     }
28 torben 1502 boolean hard = false;
29     if (args.length == 2) {
30     if ( !args[1].equals("hard") ) {
31     p.sendMessage("Usage: /zap <player> [hard]");
32     return true;
33     } else if (p.isOp() ){
34     hard = true;
35     } else {
36     p.sendMessage("Only ops can zap hard");
37     return true;
38     }
39     }
40    
41    
42 torben 1500 Server server = p.getServer();
43    
44     Player target = server.getPlayer(args[0]);
45     if (target == null) {
46     p.sendMessage("/zap: could not find player " + args[0] );
47     return true;
48     }
49    
50     World w = target.getWorld();
51     Location l = target.getLocation();
52 torben 1502 if (hard == true) {
53     w.strikeLightning(l);
54     } else {
55     w.strikeLightningEffect( l );
56     }
57 torben 1500 server.broadcastMessage( ChatColor.YELLOW + target.getName() + " was zapped by " + p.getName() );
58    
59     return true;
60     }
61     }

Properties

Name Value
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.20