Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. package net.maschinenmc.lobby.commands;
  2.  
  3. import java.io.File;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.World;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.configuration.file.YamlConfiguration;
  12. import org.bukkit.entity.Player;
  13.  
  14. import net.maschinenmc.lobby.main.Main;
  15.  
  16. public class SpawnCommand implements CommandExecutor {
  17.  
  18. @Override
  19. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  20. if(!(sender instanceof Player)) {
  21. System.out.println("Das darf nur ein Spieler!");
  22. return true;
  23. }
  24. Player p =(Player) sender;
  25.  
  26. File file = new File("plugins//MaschinenMC-Lobby//spawn.yml");
  27. if(!file.exists()) {
  28. p.sendMessage(Main.prefix + " Es wurde kein Spawn gesetzt! Bitte kontaktiere einen Admin!");
  29. return true;
  30. }
  31.  
  32. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
  33. Location loc = p.getLocation();
  34. double x = cfg.getDouble("X");
  35. double y = cfg.getDouble("Y");
  36. double z = cfg.getDouble("Z");
  37. double yaw = cfg.getDouble("Yaw");
  38. double pitch = cfg.getDouble("Pitch");
  39. String worldname = cfg.getString("Worldname");
  40.  
  41. World welt = Bukkit.getWorld(worldname);
  42.  
  43. loc.setX(x);
  44. loc.setY(y);
  45. loc.setZ(z);
  46. loc.setYaw((float) yaw);
  47. loc.setPitch((float) pitch);
  48. loc.setWorld(welt);
  49.  
  50.  
  51. p.teleport(loc);
  52. p.sendMessage(Main.prefix + " Du bist nun am Spawn!");
  53.  
  54. return true;
  55. }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement