Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package commands;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12.  
  13. public class tpatest implements CommandExecutor {
  14.  
  15. HashMap<Integer, Player> playertemp = new HashMap<Integer, Player>();
  16. HashMap<Integer, Location> loctemp = new HashMap<Integer, Location>();
  17.  
  18. @Override
  19. public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
  20. if(label.equalsIgnoreCase("tprequest") && sender instanceof Player){
  21. Player player = (Player)sender;
  22. if(args.length == 0){
  23. player.sendMessage(ChatColor.DARK_RED + "Not enough arguments.");
  24. }else if(args.length ==1){
  25. Player target = Bukkit.getPlayer(args[0]);
  26. if(target != null){
  27. player.sendMessage("tou tried to tp");
  28. target.sendMessage("someone tried to tp to you");
  29. playertemp.put(1, player);
  30. playertemp.put(2, target);
  31. loctemp.put(1, target.getLocation());
  32. return true;
  33. }else{
  34. player.sendMessage(ChatColor.DARK_RED + "Target is not online.");
  35. }
  36. }
  37. }else if(label.equalsIgnoreCase("tpaccept")){
  38. if(args.length == 0){
  39. Object A = playertemp.get(1);
  40. Object B = playertemp.get(2);
  41. Object C = loctemp.get(1);
  42. if(A != null){
  43. if(B != null){
  44. if(C != null){
  45. Player player = playertemp.get(1);
  46. Player target = playertemp.get(2);
  47. Location location = target.getLocation(loctemp.get(1));
  48. player.teleport(location);
  49. target.sendMessage("someone tped");
  50. player.sendMessage("you tped!");
  51. return true;
  52. }
  53. }
  54. }
  55.  
  56. }
  57. }
  58. return false;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement