Class LocationData

java.lang.Object
studio.magemonkey.codex.mccore.config.LocationData

public class LocationData extends Object
Provides methods of serializing and then parsing back location data for config storage
  • Constructor Details

    • LocationData

      public LocationData()
  • Method Details

    • serializeSimpleLocation

      public static String serializeSimpleLocation(org.bukkit.Location loc)

      Serializes a location using as little space as possible

      This only keeps the block coordinates instead of the precise coordinates

      Yaw and pitch are not preserved either

      Returns null for a null location

      Parameters:
      loc - location to serialize
      Returns:
      data string
    • serializeLocation

      public static String serializeLocation(org.bukkit.Location loc)

      Serializes a location with the exact coordinates but without keeping the yaw and pitch

      Returns null for a null location

      Parameters:
      loc - location to serialize
      Returns:
      data string
    • serializeDetailedLocation

      public static String serializeDetailedLocation(org.bukkit.Location loc)

      Serializes all data for a location including exact coordinates, yaw, and pitch

      Returns null for a null location

      Parameters:
      loc - location to serialize
      Returns:
      data string
    • parseLocation

      public static org.bukkit.Location parseLocation(String dataString)

      Parses a location from a data string

      This accepts simple, normal, and detailed locations

      Returns null for invalid formats or a null data string

      Parameters:
      dataString - data string to parse
      Returns:
      parsed location
    • serializeSimpleLocations

      public static List<String> serializeSimpleLocations(List<org.bukkit.Location> locations)

      Serializes a list of locations, preserving the block coordinates only

      If the provided list is null or empty, this method returns null

      Parameters:
      locations - locations to serialize
      Returns:
      list of data strings
    • serializeLocations

      public static List<String> serializeLocations(List<org.bukkit.Location> locations)

      Serializes a list of locations, preserving the exact coordinates but not the yaw and pitch

      If the provided list is null or empty, this method returns null

      Parameters:
      locations - locations to serialize
      Returns:
      list of data strings
    • serializeDetailedLocations

      public static List<String> serializeDetailedLocations(List<org.bukkit.Location> locations)

      Serializes a list of locations, preserving the exact coordinates, yaw, and pitch

      If the provided list is null or empty, this method returns null

      Parameters:
      locations - locations to serialize
      Returns:
      list of data strings
    • parseLocations

      public static List<org.bukkit.Location> parseLocations(List<String> dataStrings)

      Parses a list of locations from a list of data strings

      This method accepts simple, normal, and detailed data string lists

      If the provided list is null or empty, this method returns null

      Parameters:
      dataStrings - data strings to parse
      Returns:
      list of parsed locations
    • serializeCompactSimpleLocations

      public static String serializeCompactSimpleLocations(List<org.bukkit.Location> locations)

      Serializes a list of locations into a single string, keeping only the block coordinates

      Returns null if the provided list is null or empty

      Parameters:
      locations - locations to serialize
      Returns:
      data string
    • serializeCompactLocations

      public static String serializeCompactLocations(List<org.bukkit.Location> locations)

      Serializes a list of locations into a single string, keeping only the exact coordinates without yaw or pitch

      Returns null if the provided list is null or empty

      Parameters:
      locations - locations to serialize
      Returns:
      data string
    • serializeCompactDetailedLocations

      public static String serializeCompactDetailedLocations(List<org.bukkit.Location> locations)

      Serializes a list of locations into a single string, keeping only the exact coordinates without yaw or pitch

      Returns null if the provided list is null or empty

      Parameters:
      locations - locations to serialize
      Returns:
      data string
    • parseCompactLocations

      public static List<org.bukkit.Location> parseCompactLocations(String dataString)

      Parses a list of locations from a compact data string

      Compact data strings are the results from the serializeCompactLocation methods

      Returns null if the data string is null or empty

      Parameters:
      dataString - compact data string to parse
      Returns:
      parsed list of locations