Class PluginContext

java.lang.Object
me.pauleff.converter.api.PluginContext

public final class PluginContext extends Object
Holds shared state for a conversion run and is passed to each MOOCPlugin.

Created from ParsedArguments, it resolves the server and world folders and accumulates detection results (server type, folder structure, save format) plus UUID remappings produced during conversion.

  • Method Details

    • from

      public static PluginContext from(ParsedArguments parsedArgs) throws PathNotValidException
      Builds a PluginContext from successfully parsed CLI arguments.

      Resolves the server folder (defaulting to the current directory), requires server.properties, derives the world folder from level-name, and sets the conversion target from the online/offline flags (offline when absent).

      Parameters:
      parsedArgs - the parsed CLI arguments
      Returns:
      a new context ready for plugin execution
      Throws:
      PathNotValidException - if the server folder, server.properties, or world folder is missing
      NullPointerException - if parsedArgs is null
    • putUuidMapping

      public void putUuidMapping(UUID from, UUID to)
      Records a UUID remapping from an original player UUID to its converted counterpart.
      Parameters:
      from - the original UUID
      to - the remapped UUID
      Throws:
      NullPointerException - if from or to is null
    • getTargetUuid

      public UUID getTargetUuid(UUID from)
      Returns the remapped UUID previously stored for the given original UUID.
      Parameters:
      from - the original UUID to look up
      Returns:
      the remapped UUID, or null if no mapping exists
      Throws:
      NullPointerException - if from is null
    • serverFolder

      public Path serverFolder()
      Returns the absolute, normalized path to the server root folder.
      Returns:
      the server folder path
    • worldFolder

      public Path worldFolder()
      Returns the path to the world folder resolved from server.properties.
      Returns:
      the world folder path
    • conversionTarget

      public ConversionTarget conversionTarget()
      Returns whether this run converts toward online or offline mode.
      Returns:
      the conversion target
    • serverType

      public ServerType serverType()
      Returns the detected server type, if set by a detection plugin.
      Returns:
      the server type, or null if not yet detected
    • worldFolderStructure

      public WorldFolderStructure worldFolderStructure()
      Returns the detected world folder structure, if set by a detection plugin.
      Returns:
      the world folder structure, or null if not yet detected
    • saveFileFormat

      public SaveFileFormat saveFileFormat()
      Returns the detected save file format, if set by a detection plugin.
      Returns:
      the save file format, or null if not yet detected
    • uuidMap

      public Map<UUID,UUID> uuidMap()
      Returns the live map of original-to-remapped player UUIDs.

      Mutations via putUuidMapping(UUID, UUID) are visible through this map.

      Returns:
      the UUID remapping map; never null
    • setServerType

      public void setServerType(ServerType serverType)
      Sets the detected server type for this conversion run.
      Parameters:
      serverType - the detected ServerType
    • setWorldFolderStructure

      public void setWorldFolderStructure(WorldFolderStructure worldFolderStructure)
      Sets the detected world folder structure for this conversion run.
      Parameters:
      worldFolderStructure - the detected WorldFolderStructure
    • setSaveFileFormat

      public void setSaveFileFormat(SaveFileFormat saveFileFormat)
      Sets the detected save file format for this conversion run.
      Parameters:
      saveFileFormat - the detected SaveFileFormat
    • parsedArguments

      public ParsedArguments parsedArguments()
      Returns the parsed CLI arguments for this run.
      Returns:
      the ParsedArguments used to build this context
    • isConversionOperation

      public boolean isConversionOperation()
      Indicates whether an online/offline conversion was requested on the command line.
      Returns:
      true if a conversion operation was requested; false otherwise
    • toString

      public String toString()
      Returns a string representation of this context for debugging.
      Overrides:
      toString in class Object
      Returns:
      a string including folders, conversion target, detection fields, and UUID map