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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1586 - (show annotations) (download)
Sun Aug 7 20:25:13 2011 UTC (12 years, 9 months ago) by torben
File size: 1249 byte(s)
switch to permissions instead of isOp() and add a permissions controlled /tp command
1 package dk.thoerup.bukkit.hoeruputils;
2
3 import org.bukkit.Location;
4 import org.bukkit.World;
5 import org.bukkit.command.Command;
6 import org.bukkit.command.CommandExecutor;
7 import org.bukkit.command.CommandSender;
8 import org.bukkit.entity.Player;
9
10 public class TeleportCommand implements CommandExecutor {
11
12 @Override
13 public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
14
15 if (!(sender instanceof Player)) { // it's not a console command
16 return false;
17 }
18
19 Player p = (Player) sender;
20
21 if ( ! p.hasPermission("hoeruputils.tp")) {
22 p.sendMessage("You don't have permissions to use teleport");
23 return true;
24 }
25
26 if (args.length != 2) {
27 sender.sendMessage("Usage: /tp <source> <destination");
28 return true;
29 }
30
31 Player source = p.getServer().getPlayer( args[0] );
32
33 if (source == null) {
34 p.sendMessage("Could not find source: " + args[0]);
35 return true;
36 }
37
38 Player dest = p.getServer().getPlayer( args[1] );
39 if (dest == null) {
40 p.sendMessage("Could not find destination: " + args[1]);
41 return true;
42 }
43
44 if (args[0].equals(args[1]) ) {
45 p.sendMessage("you can't tp a player to himself");
46 return true;
47 }
48 source.teleport( dest );
49
50 return true;
51 }
52 }

  ViewVC Help
Powered by ViewVC 1.1.20