Advertisement
Guest User

Untitled

a guest
Apr 7th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package me.korex.setspawn;
  2.  
  3. import java.io.File;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.configuration.file.YamlConfiguration;
  11. import org.bukkit.entity.Player;
  12.  
  13. import me.korex.main.Main;
  14.  
  15. public class newspawncmd implements CommandExecutor{
  16.  
  17.  
  18. int high = 4;
  19. int countdown;
  20.  
  21. private Main plugin;
  22.  
  23. public newspawncmd(Main pl) {
  24. this.plugin = pl;
  25. }
  26.  
  27. @Override
  28. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  29.  
  30. final Player p = (Player)sender;
  31. int x = (int) p.getLocation().getX();
  32. int y = (int) p.getLocation().getY();
  33. double z = (int) p.getLocation().getZ();
  34. final Location loc1 = new Location(p.getWorld(), x, y, z);
  35.  
  36.  
  37.  
  38.  
  39. p.sendMessage(Main.pr + "In §a3 §6Sekunden wirst du zum Spawn teleportiert!");
  40.  
  41. countdown = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin,new Runnable() {
  42. public void run() {
  43.  
  44. int x2 = (int) p.getLocation().getX();
  45. int y2= (int) p.getLocation().getY();
  46. double z2 = (int) p.getLocation().getZ();
  47. Location loc2 = new Location(p.getWorld(), x2, y2, z2);
  48.  
  49. if(loc1.equals(loc2)) {
  50. if(high != 1) {
  51. high--;
  52. p.sendMessage(" §a" + high + "§6Sekunden...");
  53. } else {
  54. p.sendMessage(Main.pr + "Du wurdest zum §aSpawn §6teleportiert!");
  55.  
  56. Bukkit.getScheduler().cancelTask(countdown);
  57. high=4;
  58.  
  59. File file = new File("plugins/Spawn","Spawn.yml");
  60. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  61.  
  62. String world = cfg.getString("spawn.world");
  63. double x = cfg.getDouble("spawn.x");
  64. double y = cfg.getDouble("spawn.y");
  65. double z = cfg.getDouble("spawn.z");
  66. float yaw = (float) cfg.getDouble("spawn.yaw");
  67. float pitch = (float) cfg.getDouble("spawn.pitch");
  68.  
  69. Location loc = new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
  70. p.teleport(loc);
  71. }
  72. } else {
  73. p.sendMessage(Main.pr + "Teleportation abgebrochen, du darfst dich §cnicht §6bewegen!");
  74. Bukkit.getScheduler().cancelTask(countdown);
  75. high=4;
  76. }
  77. }
  78. }, 0, 20);
  79.  
  80.  
  81.  
  82.  
  83. return true;
  84. }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement