Package me.despical.commons.serializer
Class LocationSerializer
java.lang.Object
me.despical.commons.serializer.LocationSerializer
- Author:
- Despical
Created at 30.05.2020
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.bukkit.LocationDefault world spawn location.static final StringDefault serialized location. -
Method Summary
Modifier and TypeMethodDescriptionstatic WeakLocationconvertToWeakLocation(String input) Converts serialized location string to WeakLocation object.static org.bukkit.LocationfromString(String input) Parses a location from string format: "world, x, y, z" or "world, x, y, z, yaw, pitch"static booleanisDefaultLocation(String serializedLocation) Checks if serialized location is the same as default location.static booleanisDefaultLocation(org.bukkit.Location location) Checks if location is the same as default location.static StringtoString(WeakLocation location) Converts WeakLocation to serialized string format.static @NotNull StringtoString(org.bukkit.block.Block block) Converts block location to string format: "world, x, y, z"static @NotNull StringtoString(org.bukkit.Location loc) Converts location to string format: "world, x, y, z, yaw, pitch"
-
Field Details
-
DEFAULT_LOCATION
public static final org.bukkit.Location DEFAULT_LOCATIONDefault world spawn location. -
SERIALIZED_LOCATION
Default serialized location.
-
-
Method Details
-
fromString
Parses a location from string format: "world, x, y, z" or "world, x, y, z, yaw, pitch"- Parameters:
input- serialized location string- Returns:
- Location object or null if parsing fails
-
toString
Converts location to string format: "world, x, y, z, yaw, pitch"- Parameters:
loc- location to serialize- Returns:
- serialized location string
-
toString
Converts block location to string format: "world, x, y, z"- Parameters:
block- block to serialize- Returns:
- serialized location string
-
isDefaultLocation
Checks if serialized location is the same as default location.- Parameters:
serializedLocation- serialized location to check- Returns:
- true if it matches default location, false otherwise
-
isDefaultLocation
public static boolean isDefaultLocation(org.bukkit.Location location) Checks if location is the same as default location.- Parameters:
location- location to check- Returns:
- true if it matches default location, false otherwise
-
convertToWeakLocation
Converts serialized location string to WeakLocation object.- Parameters:
input- serialized location string- Returns:
- WeakLocation object or null if parsing fails
-
toString
Converts WeakLocation to serialized string format.- Parameters:
location- WeakLocation to serialize- Returns:
- serialized location string
-