Class PluginContext
MOOCPlugin.
Created from ParsedArguments, it resolves the server and world folders,
optionally a conversion-only folder from -customFolder or file from
-customFile, and accumulates detection results (server type, folder structure,
save format) plus UUID remappings produced during conversion.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the file conversion is limited to, if-customFilewas set.Returns the folder conversion is limited to, if-customFolderwas set.Returns whether this run converts toward online or offline mode.static PluginContextfrom(ParsedArguments parsedArgs) Builds aPluginContextfrom successfully parsed CLI arguments.getTargetUuid(UUID from) Returns the remapped UUID previously stored for the given original UUID.booleanIndicates whether an online/offline conversion was requested on the command line.booleanIndicates whether conversion is limited toconversionFile().booleanIndicates whether conversion is limited toconversionFolder().booleanisInConversionScope(Path path) Indicates whetherpathmay be modified by a conversion plugin.booleanIndicates whether conversion is limited to a custom folder or file.Returns the parsed CLI arguments for this run.voidputUuidMapping(UUID from, UUID to) Records a UUID remapping from an original player UUID to its converted counterpart.Returns the detected save file format, if set by a detection plugin.Returns the absolute, normalized path to the server root folder.Returns the detected server type, if set by a detection plugin.voidsetSaveFileFormat(SaveFileFormat saveFileFormat) Sets the detected save file format for this conversion run.voidsetServerType(ServerType serverType) Sets the detected server type for this conversion run.voidsetWorldFolderStructure(WorldFolderStructure worldFolderStructure) Sets the detected world folder structure for this conversion run.toString()Returns a string representation of this context for debugging.uuidMap()Returns the live map of original-to-remapped player UUIDs.Returns the path to the world folder resolved fromserver.properties.Returns the detected world folder structure, if set by a detection plugin.
-
Method Details
-
from
Builds aPluginContextfrom successfully parsed CLI arguments.Resolves the server folder (defaulting to the current directory), requires
server.properties, derives the world folder fromlevel-name, resolves-customFolderor-customFilewhen present, 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, world folder, conversion folder, or conversion file is missingNullPointerException- ifparsedArgsisnull
-
putUuidMapping
Records a UUID remapping from an original player UUID to its converted counterpart.- Parameters:
from- the original UUIDto- the remapped UUID- Throws:
NullPointerException- iffromortoisnull
-
getTargetUuid
Returns the remapped UUID previously stored for the given original UUID.- Parameters:
from- the original UUID to look up- Returns:
- the remapped UUID, or
nullif no mapping exists - Throws:
NullPointerException- iffromisnull
-
serverFolder
Returns the absolute, normalized path to the server root folder.- Returns:
- the server folder path
-
worldFolder
Returns the path to the world folder resolved fromserver.properties.- Returns:
- the world folder path
-
conversionFolder
-
conversionFile
-
isFolderScopedConversion
public boolean isFolderScopedConversion()Indicates whether conversion is limited toconversionFolder().- Returns:
trueif-customFolderwas set;falseotherwise
-
isFileScopedConversion
public boolean isFileScopedConversion()Indicates whether conversion is limited toconversionFile().- Returns:
trueif-customFilewas set;falseotherwise
-
isScopedConversion
public boolean isScopedConversion()Indicates whether conversion is limited to a custom folder or file.- Returns:
trueif-customFolderor-customFilewas set
-
isInConversionScope
Indicates whetherpathmay be modified by a conversion plugin.When no custom folder or file is set, every path is in scope. For
-customFolder, the path must be that folder or something inside it. For-customFile, the path must be that file or an ancestor directory of it (so a plugin that targets a parent folder can still filter down to the file).- Parameters:
path- the candidate file or directory- Returns:
trueif conversion may touchpath;falseotherwise- Throws:
NullPointerException- ifpathisnull
-
conversionTarget
Returns whether this run converts toward online or offline mode.- Returns:
- the conversion target
-
serverType
Returns the detected server type, if set by a detection plugin.- Returns:
- the server type, or
nullif not yet detected
-
worldFolderStructure
Returns the detected world folder structure, if set by a detection plugin.- Returns:
- the world folder structure, or
nullif not yet detected
-
saveFileFormat
Returns the detected save file format, if set by a detection plugin.- Returns:
- the save file format, or
nullif not yet detected
-
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
Sets the detected server type for this conversion run.- Parameters:
serverType- the detectedServerType
-
setWorldFolderStructure
Sets the detected world folder structure for this conversion run.- Parameters:
worldFolderStructure- the detectedWorldFolderStructure
-
setSaveFileFormat
Sets the detected save file format for this conversion run.- Parameters:
saveFileFormat- the detectedSaveFileFormat
-
parsedArguments
Returns the parsed CLI arguments for this run.- Returns:
- the
ParsedArgumentsused to build this context
-
isConversionOperation
public boolean isConversionOperation()Indicates whether an online/offline conversion was requested on the command line.- Returns:
trueif a conversion operation was requested;falseotherwise
-
toString
-