Skip to content

Instantly share code, notes, and snippets.

@lualzockt
Created August 29, 2013 19:46
Show Gist options
  • Save lualzockt/6382564 to your computer and use it in GitHub Desktop.
Save lualzockt/6382564 to your computer and use it in GitHub Desktop.
public final class LocationSerialation {
public static String serial(Location l) {
return new String(l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ() + "," + l.getWorld().getName());
}
public static Location deserial(String s) {
String[] a = s.split(",");
World w = Bukkit.getWorld(a[3]);
if(w == null) {
w = Bukkit.getWorlds().get(0);
}
int x = Integer.parseInt(a[0]);
int y = Integer.parseInt(a[1]);
int z = Integer.parseInt(a[2]);
Location l = new Location(w,x,y,z);
return l;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment