Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.coding4you.ban.util;
- /*
- *
- * (c) by coding4you.io you are not permit to sell it!
- *
- */
- import io.coding4you.ban.main.BanPlugin;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.configuration.file.YamlConfiguration;
- import java.io.File;
- import java.io.IOException;
- public class LocationManager {
- Location loc;
- final static String prefix = "§eLocationManager";
- public LocationManager(String name, Location location){
- File file = new File("plugins//" + BanPlugin.getInstance().getDescription().getName() + "//locations//" + name + ".yml");
- YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
- configuration.set("X", location.getX());
- configuration.set("Y", location.getY());
- configuration.set("Z", location.getZ());
- configuration.set("Yaw", location.getYaw());
- configuration.set("Pitch", location.getPitch());
- configuration.set("World", location.getWorld().getName());
- World world = Bukkit.getWorld(configuration.getString("World"));
- loc = new Location(world, configuration.getDouble("X"), configuration.getDouble("Y"), configuration.getDouble("Z"));
- if(! file.exists()){
- try{
- configuration.save(file);
- }catch(IOException e){
- }
- }
- }
- public static Location getLocation(String name){
- File file = new File("plugins//" + BanPlugin.getInstance().getDescription().getName() + "//locations//" + name + ".yml");
- YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
- if(file.exists()){
- World world = Bukkit.getWorld(configuration.getString("World"));
- Location loc = new Location(world, configuration.getDouble("X"), configuration.getDouble("Y"), configuration.getDouble("Z"));
- return loc;
- }else{
- Bukkit.getConsoleSender().sendMessage(prefix + " this location does not exists! ( " + name + " )");
- }
- return null;
- }
- public static boolean locationExists(String name){
- File file = new File("plugins//" + BanPlugin.getInstance().getDescription().getName() + "//locations//" + name + ".yml");
- YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
- if(file.exists()){
- return true;
- }else {
- return false;
- }
- }
- public double getX(){
- return loc.getX();
- }
- public double getY(){
- return loc.getY();
- }
- public double getZ(){
- return loc.getZ();
- }
- public float getYaw(){
- return loc.getYaw();
- }
- public float getPitch(){
- return loc.getPitch();
- }
- public World getWorld(){
- return loc.getWorld();
- }
- public String getWorldName(){
- return loc.getWorld().getName();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement