Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. package us.riotnetwork.teleport;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.Location;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10. import java.util.Random;
  11.  
  12. /**
  13. * Created by Anthony on 12/19/2014.
  14. */
  15. public class Teleport extends JavaPlugin {
  16. @Override
  17. public void onEnable() {
  18. getLogger().info("onEnable has been invoked!");
  19. }
  20.  
  21. @Override
  22. public void onDisable() {
  23. getLogger().info("onDisable has been invoked!");
  24. }
  25.  
  26. @Override
  27. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  28. if (!(sender instanceof Player)) {
  29. sender.sendMessage(ChatColor.RED + "You need to be a player to do this!");
  30. return true;
  31. }
  32. final Player p = (Player) sender;
  33. if (cmd.getName().equalsIgnoreCase("location")) {
  34. double x = p.getLocation().getX();
  35. double y = p.getLocation().getY();
  36. double z = p.getLocation().getZ();
  37. p.sendMessage(ChatColor.RED + "Your location is" + "" + x + "" + y + "" + z);
  38. return true;
  39. }
  40. return false;
  41.  
  42. if (args.length == 3 && cmd.getName().equalsIgnoreCase("teleport")) {
  43. Location loc = p.getLocation();
  44. int x = Integer.parseInt(args[0]);
  45. int y = Integer.parseInt(args[1]);
  46. int z = Integer.parseInt(args[2]);
  47. loc.setX(x);
  48. loc.setY(y);
  49. loc.setZ(z);
  50. p.teleport(loc);
  51. p.sendMessage(ChatColor.RED + "You have been teleported to" + "" + x + "" + y + "" + z);
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement