Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. package me.gmanos.gutils;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Location;
  5. import org.bukkit.World;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10.  
  11. public class Comandos implements CommandExecutor {
  12.  
  13. @Override
  14. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  15. if(command.getName().equalsIgnoreCase("local")){
  16. if(!(sender instanceof Player)){
  17. sender.sendMessage("§cEsse comando é apenas para players!");
  18. return true;
  19. }
  20.  
  21. if(args[1].equalsIgnoreCase("set")){
  22. String msg = args[2];
  23. Player p = (Player) sender;
  24. Main.getInstance().getConfig().set(msg + ".X", p.getLocation().getX());
  25. Main.getInstance().getConfig().set(msg + ".Y", p.getLocation().getY());
  26. Main.getInstance().getConfig().set(msg + ".Z", p.getLocation().getZ());
  27. Main.getInstance().getConfig().set(msg + ".Pitch", p.getLocation().getPitch());
  28. Main.getInstance().getConfig().set(msg + ".Yaw", p.getLocation().getYaw());
  29. Main.getInstance().getConfig().set(msg + ".Word", p.getWorld().getName());
  30. Main.getInstance().saveConfig();
  31. Main.getInstance().saveDefaultConfig();
  32. sender.sendMessage("§6Local §e" + msg + " §6Definido com sucesso!");
  33.  
  34. }else{
  35. sender.sendMessage("§cVocê precisar por o nome do local!");
  36. }
  37. }
  38.  
  39. if(command.getName().equalsIgnoreCase(label)){
  40. if(!(sender instanceof Player)){
  41. sender.sendMessage("§cApenas jogadores podem usar este comando!");
  42. return true;
  43. }
  44.  
  45. Player p = (Player) sender;
  46. if(Main.getInstance().getConfig().contains(label)){
  47.  
  48. Double X = Main.getInstance().getConfig().getDouble(label + ".X");
  49. Double Y = Main.getInstance().getConfig().getDouble(label + ".Y");
  50. Double Z = Main.getInstance().getConfig().getDouble(label + ".Z");
  51. float Pitch = (float)Main.getInstance().getConfig().getDouble(label + ".Pitch");
  52. float Yaw = (float)Main.getInstance().getConfig().getDouble(label + ".Yaw");
  53. World W = Bukkit.getWorld(Main.getInstance().getConfig().getString(label + ".World"));
  54.  
  55. Location label1 = new Location(W, X, Y, Z, Yaw, Pitch);
  56. p.teleport(label1);
  57. p.sendMessage("§6Teleportado com sucesso!");
  58.  
  59. }
  60.  
  61.  
  62. }
  63.  
  64. return false;
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement