Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void createLocation(String name, Player player){
- File ordner = new File("plugins//Lobby//Locations//");
- File file = new File("plugins//Lobby//Locations//" + name + ".yml");
- if(!ordner.exists()){
- ordner.mkdir();
- }
- if(!file.exists()){
- try {
- file.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- Location loc = player.getLocation();
- cfg.set("X", loc.getBlockX());
- cfg.set("Y", loc.getBlockY());
- cfg.set("Z", loc.getBlockZ());
- cfg.set("Welt", loc.getWorld().getName());
- cfg.set("Yaw", loc.getYaw());
- cfg.set("Pitch", loc.getPitch());
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public static void getLocation(Player player, String name){
- File file = new File("plugins//Lobby//Locations//" + name + ".yml");
- if(!file.exists()){
- player.sendMessage(Main.prefix + "Die Location wurde nicht gefunden");
- }
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- World welt = Bukkit.getWorld(cfg.getString("Welt"));
- double yaw = cfg.getDouble("Yaw");
- double pitch = cfg.getDouble("Pitch");
- player.teleport(new Location(welt, cfg.getDouble("X"), cfg.getDouble("Y"), cfg.getDouble("Z"), (float) yaw, (float) pitch));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement