Class UsercacheFile

java.lang.Object
me.pauleff.common.handlers.files.UsercacheFile

public final class UsercacheFile extends Object
Represents a Minecraft usercache.json file.

Prefer loadArray(Path) for one-shot loads. Use of(Path) when reusing a handle.

  • Method Details

    • of

      public static UsercacheFile of(Path path)
      Returns a handle for the given usercache path.
      Parameters:
      path - the path to usercache.json
      Returns:
      a usercache file handle
      Throws:
      NullPointerException - if path is null
    • loadArray

      public static org.json.JSONArray loadArray(Path path)
      Loads the contents of the given usercache file as a JSONArray.
      Parameters:
      path - the path to usercache.json
      Returns:
      the parsed JSON array, or an empty array if the file could not be read
    • path

      public Path path()
      Returns the path to this usercache file.
      Returns:
      the usercache file path
    • loadArray

      public org.json.JSONArray loadArray()
      Loads the contents of this usercache file as a JSONArray.

      On read failure, logs a warning and returns an empty array so callers can continue without prefetched user data.

      Returns:
      the parsed JSON array, or an empty array if the file could not be read