Interface LevelView
- Since:
- 2.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents the possible outcomes of a world deletion process. -
Method Summary
Modifier and TypeMethodDescriptiondefault longbackup(org.bukkit.World world) Deprecated, for removal: This API element is subject to removal in a future version.backupAsync(org.bukkit.World world) Creates a backup for the given world and returns the size of the backup in bytes.booleancancelScheduledDeletion(org.bukkit.World world) Cancels the deletion process for the specified world, if scheduled.booleancancelScheduledRegeneration(org.bukkit.World world) Cancels the regeneration process for the specified world, if scheduled.booleanDetermines if a level located at the specified path can be loaded.default Optional<org.bukkit.World> clone(org.bukkit.World world, Consumer<Level.Builder> builder, boolean full) Deprecated, for removal: This API element is subject to removal in a future version.CompletableFuture<org.bukkit.World> cloneAsync(org.bukkit.World world, Consumer<Level.Builder> builder, boolean full) Clones the specified world with the possibility to modify its properties through a builder.default LevelView.DeletionResultdelete(org.bukkit.World world, boolean schedule) Deprecated, for removal: This API element is subject to removal in a future version.deleteAsync(org.bukkit.World world, boolean schedule) Deletes the specified world from the server and disk.Retrieves the path to the backup folder.Optional<org.bukkit.plugin.java.JavaPlugin> getGenerator(org.bukkit.World world) Retrieves the plugin associated with the world generator for the given world, if it exists.Retrieves the path to the world container directory.booleanhasEndDimension(Path level) Determines whether the specified directory contains an End dimension folder.booleanhasNetherDimension(Path level) Determines whether the specified directory contains a Nether dimension folder.booleanisDeletionScheduled(org.bukkit.World world) Checks whether a deletion process is scheduled for the specified world.booleanisEnabled(org.bukkit.World world) Determines if the specified world is enabled and will be loaded on startup.booleanDetermines whether the specified directory represents a valid world folder.booleanisRegenerationScheduled(org.bukkit.World world) Checks whether a regeneration process is scheduled for the specified world.Returns an unmodifiable set of paths representing the directories of all levels available in the server'sworld container.Reads a level from the specified directory path.default LevelView.DeletionResultregenerate(org.bukkit.World world, boolean schedule) Deprecated, for removal: This API element is subject to removal in a future version.regenerateAsync(org.bukkit.World world, boolean schedule) Regenerates the specified world, either immediately or scheduled, based on the provided parameters.default voidsave(org.bukkit.World world, boolean flush) Deprecated, for removal: This API element is subject to removal in a future version.saveAsync(org.bukkit.World world, boolean flush) Saves the specified world, with an option to flush pending changes immediately.default voidsaveLevelData(org.bukkit.World world, boolean async) Deprecated, for removal: This API element is subject to removal in a future version.saveLevelDataAsync(org.bukkit.World world) Saves thelevel.datof the specified world to disk.voidsetEnabled(org.bukkit.World world, boolean enabled) Sets whether the specified world is enabled and will be loaded on startup.default booleanunload(org.bukkit.World world, boolean save) Deprecated, for removal: This API element is subject to removal in a future version.unloadAsync(org.bukkit.World world, boolean save) Unloads the specified world from the server.
-
Method Details
-
getBackupFolder
Retrieves the path to the backup folder.- Returns:
- the
Pathrepresenting the backup folder - Since:
- 3.0.0
-
getWorldContainer
Retrieves the path to the world container directory.- Returns:
- the
Pathrepresenting the world container directory - Since:
- 3.0.0
-
read
Reads a level from the specified directory path.- Parameters:
directory- the directory containing the level data to be read- Returns:
- an
Optionalcontaining theLevel.Builderif the directory represents a valid level, orOptional.empty()if the directory is invalid - Since:
- 3.0.0
-
getGenerator
@Contract(pure=true) Optional<org.bukkit.plugin.java.JavaPlugin> getGenerator(org.bukkit.World world) Retrieves the plugin associated with the world generator for the given world, if it exists.- Parameters:
world- the world whose generator plugin is to be retrieved- Returns:
- an
Optionalcontaining the associatedJavaPlugin, orOptional.empty()if the world does not have a generator or if the generator is not associated with a plugin - Since:
- 3.0.0
-
listLevels
Returns an unmodifiable set of paths representing the directories of all levels available in the server'sworld container. These directories are determined to be valid levels using specific validation criteria.- Returns:
- an unmodifiable set of
Pathobjects representing valid level directories, or an empty set if no valid levels are found or if an error occurs while accessing the filesystem. - Since:
- 3.0.0
-
canLoad
Determines if a level located at the specified path can be loaded. A level can be loaded if there is no other world loaded with the same path.- Parameters:
level- the path to the level directory to be checked- Returns:
- true if the level can be loaded, otherwise false
- Since:
- 3.0.0
-
hasEndDimension
Determines whether the specified directory contains an End dimension folder.- Parameters:
level- the path to the directory to be checked- Returns:
- true if the level directory contains a
DIM1folder, otherwise false - Since:
- 3.0.0
-
hasNetherDimension
Determines whether the specified directory contains a Nether dimension folder.- Parameters:
level- the path to the directory to be checked- Returns:
- true if the level directory contains a
DIM-1folder, otherwise false - Since:
- 3.0.0
-
isLevel
Determines whether the specified directory represents a valid world folder.- Parameters:
path- the path to the directory being checked- Returns:
trueif the directory contains alevel.datorlevel.dat_old, otherwisefalse- Since:
- 3.0.0
-
unload
@Contract(mutates="io,param1") @Deprecated(forRemoval=true, since="3.2.0") default boolean unload(org.bukkit.World world, boolean save) Deprecated, for removal: This API element is subject to removal in a future version.Unloads the specified world from the server.- Parameters:
world- the world to be unloadedsave- whether changes to the world should be saved before unloading- Returns:
- true if the world was successfully unloaded, otherwise false
- Since:
- 3.0.0
-
unloadAsync
@Contract(mutates="io,param1") CompletableFuture<Boolean> unloadAsync(org.bukkit.World world, boolean save) Unloads the specified world from the server.- Parameters:
world- the world to be unloadedsave- whether changes to the world should be saved before unloading- Returns:
- A
CompletableFuturecompleting with true if the world was successfully unloaded, otherwise false - Since:
- 3.2.0
-
save
@Contract(mutates="io,param1") @Deprecated(forRemoval=true, since="3.2.0") default void save(org.bukkit.World world, boolean flush) Deprecated, for removal: This API element is subject to removal in a future version.Saves the specified world, with an option to flush pending changes immediately.- Parameters:
world- the world to be savedflush- whether to flush pending changes to disk immediately- Since:
- 3.0.0
-
saveAsync
@Contract(mutates="io,param1") CompletableFuture<Void> saveAsync(org.bukkit.World world, boolean flush) Saves the specified world, with an option to flush pending changes immediately.- Parameters:
world- the world to be savedflush- whether to flush pending changes to disk immediately- Returns:
- A
CompletableFuturethat might complete exceptionally - Since:
- 3.2.0
-
saveLevelData
@Contract(mutates="io,param1") @Deprecated(forRemoval=true, since="3.2.0") default void saveLevelData(org.bukkit.World world, boolean async) Deprecated, for removal: This API element is subject to removal in a future version.Saves thelevel.datof the specified world to disk.- Parameters:
world- the world whose level data should be savedasync- whether the save operation should be performed asynchronously
-
saveLevelDataAsync
Saves thelevel.datof the specified world to disk.- Parameters:
world- the world whose level data should be saved- Since:
- 3.2.0
-
isEnabled
@Contract(pure=true) boolean isEnabled(org.bukkit.World world) Determines if the specified world is enabled and will be loaded on startup.- Parameters:
world- the world to check- Returns:
- true if the world is enabled, false otherwise
- Since:
- 3.2.0
-
setEnabled
@Contract(mutates="param1") void setEnabled(org.bukkit.World world, boolean enabled) Sets whether the specified world is enabled and will be loaded on startup.- Parameters:
world- the world to enable or disableenabled- true to enable the world, false to disable it- Since:
- 3.2.0
-
backup
@Contract(mutates="io,param1") @Deprecated(forRemoval=true, since="3.3.1") default long backup(org.bukkit.World world) throws IOException Deprecated, for removal: This API element is subject to removal in a future version.Creates a backup for the given world and returns the size of the backup in bytes.- Parameters:
world- the world to back up- Returns:
- the size of the created backup in bytes
- Throws:
IOException- if an I/O error occurs while creating the backup- Since:
- 3.0.0
-
backupAsync
Creates a backup for the given world and returns the size of the backup in bytes.Completes with an
IOExceptionif an I/O error occurs while creating the backup- Parameters:
world- the world to back up- Returns:
- A
CompletableFuturecompleting with the size of the created backup in bytes - Since:
- 3.2.0
-
clone
@Contract(mutates="io,param1") @Deprecated(forRemoval=true, since="3.2.0") default Optional<org.bukkit.World> clone(org.bukkit.World world, Consumer<Level.Builder> builder, boolean full) throws IllegalArgumentException, IllegalStateException, IOException Deprecated, for removal: This API element is subject to removal in a future version.Clones the specified world with the possibility to modify its properties through a builder. If afullclone is invoked, the entire world directory is duplicated, except for specific files and folders:advancements,datapacks,playerdata,stats,uid.dat, andsession.lock.By default, if a name or key is not provided, they are automatically generated using the pattern
OriginalName (#), and the key is a lowercased version of the generated name, replacing spaces with underscores and removing invalid namespace characters.Throws an
IllegalArgumentExceptionif the world name or key is already in use. Throws anIllegalStateExceptionif the target directory already exists.- Parameters:
world- the world to be clonedbuilder- a consumer that modifies theLevel.Builderproperties of the cloned worldfull- whether to fully clone including regions, entities..., or only thelevel.dat- Returns:
- an
Optionalcontaining the cloned world, orOptional.empty()if the cloning fails - Throws:
IllegalArgumentException- if the world name or key are already in useIllegalStateException- if the target directory already existsIOException- if an I/O error occurs during the cloning process- Since:
- 3.0.0
- See Also:
-
cloneAsync
@Contract(mutates="io,param1") CompletableFuture<org.bukkit.World> cloneAsync(org.bukkit.World world, Consumer<Level.Builder> builder, boolean full) Clones the specified world with the possibility to modify its properties through a builder. If afullclone is invoked, the entire world directory is duplicated, except for specific files and folders:advancements,datapacks,playerdata,stats,uid.dat, andsession.lock.By default, if a name or key is not provided, they are automatically generated using the pattern
OriginalName (#), and the key is a lowercased version of the generated name, replacing spaces with underscores and removing invalid namespace characters.Completes with an
IllegalArgumentExceptionif the world name or key is already in use.
Completes with anIllegalStateExceptionif the target directory already exists.
Completes with anIOExceptionif an I/O error occurs during the cloning process.- Parameters:
world- the world to be clonedbuilder- a consumer that modifies theLevel.Builderproperties of the cloned worldfull- whether to fully clone including regions, entities..., or only thelevel.dat- Returns:
- A
CompletableFuturecompleting with the cloned world - Since:
- 3.2.0
- See Also:
-
delete
@Contract(mutates="io,param1") @Deprecated(forRemoval=true, since="3.2.0") default LevelView.DeletionResult delete(org.bukkit.World world, boolean schedule) Deprecated, for removal: This API element is subject to removal in a future version.Deletes the specified world from the server and disk. The deletion can be executed immediately or scheduled for later, depending on the provided parameters.- Parameters:
world- the world to be deletedschedule- if true, the deletion process will be scheduled for a later operation (e.g., during server shutdown); if false, the deletion will be attempted immediately- Returns:
- a
DeletionResultindicating the outcome of the deletion process. - Since:
- 3.0.0
-
deleteAsync
@Contract(mutates="io,param1") CompletableFuture<LevelView.DeletionResult> deleteAsync(org.bukkit.World world, boolean schedule) Deletes the specified world from the server and disk. The deletion can be executed immediately or scheduled for later, depending on the provided parameters.- Parameters:
world- the world to be deletedschedule- if true, the deletion process will be scheduled for a later operation (e.g., during server shutdown); if false, the deletion will be attempted immediately- Returns:
- A
CompletableFuturecompleting with aDeletionResultindicating the outcome of the deletion process. - Since:
- 3.2.0
-
cancelScheduledDeletion
@Contract(mutates="this") boolean cancelScheduledDeletion(org.bukkit.World world) Cancels the deletion process for the specified world, if scheduled.- Parameters:
world- the world for which the scheduled deletion should be canceled- Returns:
- true if the scheduled deletion was successfully canceled, false if no deletion was scheduled
- Since:
- 3.0.0
-
isDeletionScheduled
@Contract(pure=true) boolean isDeletionScheduled(org.bukkit.World world) Checks whether a deletion process is scheduled for the specified world.- Parameters:
world- the world to check for a scheduled deletion- Returns:
- true if a deletion process is scheduled for the world, otherwise false
- Since:
- 3.0.0
-
regenerate
@Contract(mutates="io,param1") @Deprecated(forRemoval=true, since="3.2.0") default LevelView.DeletionResult regenerate(org.bukkit.World world, boolean schedule) Deprecated, for removal: This API element is subject to removal in a future version.Regenerates the specified world, either immediately or scheduled, based on the provided parameters.- Parameters:
world- the world to be regeneratedschedule- if true, the regeneration will be scheduled for later execution; if false, the regeneration will be attempted immediately- Returns:
- a
DeletionResultindicating the outcome of the regeneration process. - Since:
- 3.0.0
-
regenerateAsync
@Contract(mutates="io,param1") CompletableFuture<LevelView.DeletionResult> regenerateAsync(org.bukkit.World world, boolean schedule) Regenerates the specified world, either immediately or scheduled, based on the provided parameters.- Parameters:
world- the world to be regeneratedschedule- if true, the regeneration will be scheduled for later execution; if false, the regeneration will be attempted immediately- Returns:
- a
CompletableFuturecompleting with aDeletionResultindicating the outcome of the regeneration process. - Since:
- 3.2.0
-
cancelScheduledRegeneration
@Contract(mutates="this") boolean cancelScheduledRegeneration(org.bukkit.World world) Cancels the regeneration process for the specified world, if scheduled.- Parameters:
world- the world for which the scheduled regeneration should be canceled- Returns:
- true if the scheduled regeneration was successfully canceled, false if no regeneration was scheduled
- Since:
- 3.0.0
-
isRegenerationScheduled
@Contract(pure=true) boolean isRegenerationScheduled(org.bukkit.World world) Checks whether a regeneration process is scheduled for the specified world.- Parameters:
world- the world to check for a scheduled regeneration- Returns:
- true if a regeneration process is scheduled for the world, otherwise false
- Since:
- 3.0.0
-
backupAsync(World)