Package com.sk89q.worldedit
Class WorldEdit
java.lang.Object
com.sk89q.worldedit.WorldEdit
The entry point and container for a working implementation of WorldEdit.
An instance handles event handling; block, mask, pattern, etc. registration;
the management of sessions; the creation of EditSession
s; and more.
In order to use WorldEdit, at least one Platform
must be registered
with WorldEdit using PlatformManager.register(Platform)
on the
manager retrieved using getPlatformManager()
.
An instance of WorldEdit can be retrieved using the static
method getInstance()
, which is shared among all
platforms within the same classloader hierarchy.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkExtentHeightBounds
(BlockVector3 position, Extent extent) Check if the given position is contained by the extent's min/max heightvoid
checkMaxBrushRadius
(double radius) Deprecated.void
checkMaxBrushRadius
(double radius, Actor actor) Check the given radius against the give actor's limit.void
checkMaxBrushRadius
(Expression radius) Deprecated, for removal: This API element is subject to removal in a future version.void
checkMaxBrushRadius
(Expression expression, Actor actor) Check the given radius against the give actor's limit.void
checkMaxRadius
(double radius) Deprecated.void
checkMaxRadius
(double radius, Actor actor) Check the given radius against the give actor's limit.void
flushBlockBag
(Actor actor, EditSession editSession) Flush a block bag's changes to a player.Get the block factory from which newBlockStateHolder
s can be constructed.Get Worldedit's configuration.getDiagonalDirection
(Player player, String dirStr) Get the direction vector for a player's direction.getDirection
(Player player, String dirStr) Get the direction vector for a player's direction.Deprecated.UsenewEditSessionBuilder()
instead.Get the event bus for WorldEdit.com.google.common.util.concurrent.ListeningExecutorService
Get the executor service.static WorldEdit
Gets the current instance of this class.Get the item factory from which newBaseItem
s can be constructed.Get the mask factory from which newMask
s can be constructed.Get the pattern factory from which newPattern
s can be constructed.Get the platform manager, where platforms (that implement WorldEdit) can be registered and information about registered platforms can be queried.Gets the path to a file.Gets the path to a file.Gets the path to the folder in which schematics are saved by defaultReturn the session manager.Get the supervisor.Get the transform factory from which newResettableExtent
s can be constructed.Return the translation manager.static String
Get the version.Deprecated.UsegetWorkingDirectoryPath(String)
insteadGet a file relative to the defined working directory.boolean
handleArmSwing
(Player player) Called on arm swing.boolean
handleBlockLeftClick
(Player player, Location clicked) Deprecated.boolean
handleBlockLeftClick
(Player player, Location clicked, Direction face) Called on left click.boolean
handleBlockRightClick
(Player player, Location clicked) Deprecated.boolean
handleBlockRightClick
(Player player, Location clicked, Direction face) Called on right click.boolean
handleRightClick
(Player player) Called on right click (not on a block).void
Load the bundled mappings.<A extends Actor & Locatable>
EditSessionnewEditSession
(A locatableActor) Shorthand fornewEditSessionBuilder().locatableActor(locatableActor).build()
.newEditSession
(World world) Shorthand fornewEditSessionBuilder().world(world).build()
.Create a builder forEditSession
s.void
Executes a WorldEdit script.
-
Field Details
-
logger
This is for internal use only.
-
-
Method Details
-
getInstance
Gets the current instance of this class.An instance will always be available, but no platform may yet be registered with WorldEdit, meaning that a number of operations may fail. However, event handlers can be registered.
- Returns:
- an instance of WorldEdit.
-
getPlatformManager
Get the platform manager, where platforms (that implement WorldEdit) can be registered and information about registered platforms can be queried.- Returns:
- the platform manager
-
getEventBus
Get the event bus for WorldEdit.Event handlers can be registered on the event bus.
- Returns:
- the event bus
-
getSupervisor
Get the supervisor. Internal, not for API use.- Returns:
- the supervisor
-
getExecutorService
public com.google.common.util.concurrent.ListeningExecutorService getExecutorService()Get the executor service. Internal, not for API use.- Returns:
- the executor service
-
getBlockFactory
Get the block factory from which newBlockStateHolder
s can be constructed.- Returns:
- the block factory
-
getItemFactory
Get the item factory from which newBaseItem
s can be constructed.- Returns:
- the item factory
-
getMaskFactory
Get the mask factory from which newMask
s can be constructed.- Returns:
- the mask factory
-
getPatternFactory
Get the pattern factory from which newPattern
s can be constructed.- Returns:
- the pattern factory
-
getTransformFactory
Get the transform factory from which newResettableExtent
s can be constructed.- Returns:
- the transform factory
-
getSessionManager
Return the session manager.- Returns:
- the session manager
-
getTranslationManager
Return the translation manager.- Returns:
- the translation manager
-
getSafeSaveFile
public File getSafeSaveFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException Gets the path to a file. This method will check to see if the filename has valid characters and has an extension. It also prevents directory traversal exploits by checking the root directory and the file directory. On success, ajava.io.File
object will be returned.- Parameters:
actor
- the actordir
- sub-directory to look infilename
- filename (user-submitted)defaultExt
- append an extension if missing one, null to not useextensions
- list of extensions, null for any- Returns:
- a file
- Throws:
FilenameException
- thrown if the filename is invalid
-
getSafeOpenFile
public File getSafeOpenFile(Actor actor, File dir, String filename, String defaultExt, String... extensions) throws FilenameException Gets the path to a file. This method will check to see if the filename has valid characters and has an extension. It also prevents directory traversal exploits by checking the root directory and the file directory. On success, ajava.io.File
object will be returned.- Parameters:
actor
- the actordir
- sub-directory to look infilename
- filename (user-submitted)defaultExt
- append an extension if missing one, null to not useextensions
- list of extensions, null for any- Returns:
- a file
- Throws:
FilenameException
- thrown if the filename is invalid
-
loadMappings
public void loadMappings()Load the bundled mappings. -
checkMaxRadius
Deprecated.Checks to see if the specified radius is within bounds.- Parameters:
radius
- the radius- Throws:
MaxRadiusException
- if the radius is bigger than the configured radius
-
checkMaxBrushRadius
Deprecated.Checks to see if the specified brush radius is within bounds.- Parameters:
radius
- the radius- Throws:
MaxBrushRadiusException
- if the radius is bigger than the configured radius
-
checkMaxBrushRadius
@Deprecated(forRemoval=true, since="2.11.0") public void checkMaxBrushRadius(Expression radius) throws MaxBrushRadiusException Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
MaxBrushRadiusException
-
checkMaxRadius
Check the given radius against the give actor's limit.- Parameters:
radius
- Radius to checkactor
- Actor to check for- Throws:
MaxRadiusException
- If given radius larger than allowed- Since:
- 2.11.0
-
checkMaxBrushRadius
Check the given radius against the give actor's limit.- Parameters:
radius
- Radius to checkactor
- Actor to check for- Throws:
MaxRadiusException
- If given radius larger than allowed- Since:
- 2.11.0
-
checkMaxBrushRadius
Check the given radius against the give actor's limit.- Parameters:
expression
- Radius to checkactor
- Actor to check for- Throws:
BrushRadiusLimitException
- If given radius larger than allowed- Since:
- 2.11.0
-
checkExtentHeightBounds
Check if the given position is contained by the extent's min/max height- Parameters:
position
- Position to checkextent
- Extent to check in- Throws:
OutsideWorldBoundsException
- If the position is outside the world height limits- Since:
- 2.11.0
-
getWorkingDirectoryFile
Deprecated.UsegetWorkingDirectoryPath(String)
insteadGet a file relative to the defined working directory. If the specified path is absolute, then the working directory is not used.- Parameters:
path
- the subpath under the working directory- Returns:
- a working directory
-
getWorkingDirectoryPath
Get a file relative to the defined working directory. If the specified path is absolute, then the working directory is not used.- Parameters:
path
- the subpath under the working directory- Returns:
- a working directory
-
getSchematicsFolderPath
Gets the path to the folder in which schematics are saved by default- Returns:
- Path to the schematic folder
-
getDirection
public BlockVector3 getDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException Get the direction vector for a player's direction.- Parameters:
player
- the playerdirStr
- the direction string- Returns:
- a direction vector
- Throws:
UnknownDirectionException
- thrown if the direction is not known, or a relative direction is used with null player
-
getDiagonalDirection
public BlockVector3 getDiagonalDirection(@Nullable Player player, String dirStr) throws UnknownDirectionException Get the direction vector for a player's direction.- Parameters:
player
- the playerdirStr
- the direction string- Returns:
- a direction vector
- Throws:
UnknownDirectionException
- thrown if the direction is not known, or a relative direction is used with null player
-
flushBlockBag
Flush a block bag's changes to a player.- Parameters:
actor
- the actoreditSession
- the edit session
-
handleArmSwing
Called on arm swing.- Parameters:
player
- the player- Returns:
- true if the swing was handled
-
handleRightClick
Called on right click (not on a block).- Parameters:
player
- the player- Returns:
- true if the right click was handled
-
handleBlockRightClick
Deprecated.Called on right click.- Parameters:
player
- the playerclicked
- the clicked block- Returns:
- false if you want the action to go through
-
handleBlockRightClick
Called on right click.- Parameters:
player
- the playerclicked
- the clicked blockface
- The clicked face- Returns:
- false if you want the action to go through
-
handleBlockLeftClick
Deprecated.Called on left click.- Parameters:
player
- the playerclicked
- the clicked block- Returns:
- false if you want the action to go through
-
handleBlockLeftClick
Called on left click.- Parameters:
player
- the playerclicked
- the clicked blockface
- The clicked face- Returns:
- false if you want the action to go through
-
runScript
Executes a WorldEdit script.- Parameters:
player
- the playerf
- the script file to executeargs
- arguments for the script- Throws:
WorldEditException
- if something goes wrong
-
getConfiguration
Get Worldedit's configuration.- Returns:
- a configuration
-
getEditSessionFactory
Deprecated.UsenewEditSessionBuilder()
instead. SeeEditSessionFactory
for details.Get a factory forEditSession
s. -
newEditSessionBuilder
Create a builder forEditSession
s. -
newEditSession
Shorthand fornewEditSessionBuilder().world(world).build()
.- Parameters:
world
- the world- Returns:
- the new
EditSession
-
newEditSession
Shorthand fornewEditSessionBuilder().locatableActor(locatableActor).build()
.- Parameters:
locatableActor
- the actor- Returns:
- the new
EditSession
-
getVersion
Get the version.- Returns:
- the version of WorldEdit
-
checkMaxBrushRadius(double, Actor)