Skip to content

Commit

Permalink
1.4.41
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoismysign committed Oct 17, 2022
1 parent eb8dcf7 commit a42ce3a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/us/mytheria/bloblib/utilities/BukkitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;

Expand Down Expand Up @@ -38,6 +40,34 @@ public static Location stringToLocation(String string) {
Double.parseDouble(split[3]));
}

public static ConfigurationSection serializeLocation(Location location, ConfigurationSection section) {
section.set("World", location.getWorld().getName());
section.set("X", location.getX());
section.set("Y", location.getY());
section.set("Z", location.getZ());
section.set("Yaw", location.getYaw());
section.set("Pitch", location.getPitch());
return section;
}

public static ConfigurationSection serializeLocation(Location location, YamlConfiguration config,
String path) {
ConfigurationSection section = config.createSection(path);
section.set("World", location.getWorld().getName());
section.set("X", location.getX());
section.set("Y", location.getY());
section.set("Z", location.getZ());
section.set("Yaw", location.getYaw());
section.set("Pitch", location.getPitch());
return section;
}

public static Location deserializeLocation(ConfigurationSection section) {
return new Location(Bukkit.getWorld(section.getString("World")), section.getDouble("X"),
section.getDouble("Y"), section.getDouble("Z"), (float) section.getDouble("Yaw"),
(float) section.getDouble("Pitch"));
}

/**
* Prints Location in a more readable way.
*
Expand Down

0 comments on commit a42ce3a

Please sign in to comment.