public class WorldEdit
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Logger |
logger |
Modifier and Type | Method and Description |
---|---|
void |
checkMaxBrushRadius(double radius)
Checks to see if the specified brush radius is within bounds.
|
void |
checkMaxRadius(double radius)
Checks to see if the specified radius is within bounds.
|
void |
flushBlockBag(Actor actor,
EditSession editSession)
Flush a block bag's changes to a player.
|
BlockFactory |
getBlockFactory()
Get the block factory from which new
BlockStateHolder s can be
constructed. |
LocalConfiguration |
getConfiguration()
Get Worldedit's configuration.
|
Vector |
getDirection(Player player,
java.lang.String dirStr)
Get the direction vector for a player's direction.
|
EditSessionFactory |
getEditSessionFactory()
Get a factory for
EditSession s. |
EventBus |
getEventBus()
Get the event bus for WorldEdit.
|
static WorldEdit |
getInstance()
Gets the current instance of this class.
|
ItemFactory |
getItemFactory()
Get the item factory from which new
BaseItem s can be
constructed. |
MaskFactory |
getMaskFactory()
Get the mask factory from which new
Mask s
can be constructed. |
PatternFactory |
getPatternFactory()
Get the pattern factory from which new
Pattern s
can be constructed. |
PlatformManager |
getPlatformManager()
Get the platform manager, where platforms (that implement WorldEdit)
can be registered and information about registered platforms can
be queried.
|
java.io.File |
getSafeOpenFile(Player player,
java.io.File dir,
java.lang.String filename,
java.lang.String defaultExt,
java.lang.String... extensions)
Gets the path to a file.
|
java.io.File |
getSafeSaveFile(Player player,
java.io.File dir,
java.lang.String filename,
java.lang.String defaultExt,
java.lang.String... extensions)
Gets the path to a file.
|
SessionManager |
getSessionManager()
Return the session manager.
|
static java.lang.String |
getVersion()
Get the version.
|
java.io.File |
getWorkingDirectoryFile(java.lang.String path)
Get a file relative to the defined working directory.
|
boolean |
handleArmSwing(Player player)
Called on arm swing.
|
boolean |
handleBlockLeftClick(Player player,
Location clicked)
Called on left click.
|
boolean |
handleBlockRightClick(Player player,
Location clicked)
Called on right click.
|
boolean |
handleRightClick(Player player)
Called on right click (not on a block).
|
void |
loadMappings()
Load the bundled mappings.
|
void |
runScript(Player player,
java.io.File f,
java.lang.String[] args)
Executes a WorldEdit script.
|
public static WorldEdit getInstance()
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.
public PlatformManager getPlatformManager()
public EventBus getEventBus()
Event handlers can be registered on the event bus.
public BlockFactory getBlockFactory()
BlockStateHolder
s can be
constructed.public ItemFactory getItemFactory()
BaseItem
s can be
constructed.public MaskFactory getMaskFactory()
Mask
s
can be constructed.public PatternFactory getPatternFactory()
Pattern
s
can be constructed.public SessionManager getSessionManager()
public java.io.File getSafeSaveFile(Player player, java.io.File dir, java.lang.String filename, java.lang.String defaultExt, java.lang.String... extensions) throws FilenameException
java.io.File
object will be returned.player
- the playerdir
- sub-directory to look infilename
- filename (user-submitted)defaultExt
- append an extension if missing one, null to not useextensions
- list of extensions, null for anyFilenameException
- thrown if the filename is invalidpublic java.io.File getSafeOpenFile(Player player, java.io.File dir, java.lang.String filename, java.lang.String defaultExt, java.lang.String... extensions) throws FilenameException
java.io.File
object will be returned.player
- the playerdir
- sub-directory to look infilename
- filename (user-submitted)defaultExt
- append an extension if missing one, null to not useextensions
- list of extensions, null for anyFilenameException
- thrown if the filename is invalidpublic void loadMappings()
public void checkMaxRadius(double radius) throws MaxRadiusException
radius
- the radiusMaxRadiusException
public void checkMaxBrushRadius(double radius) throws MaxBrushRadiusException
radius
- the radiusMaxBrushRadiusException
public java.io.File getWorkingDirectoryFile(java.lang.String path)
path
- the subpath under the working directorypublic Vector getDirection(Player player, java.lang.String dirStr) throws UnknownDirectionException
player
- the playerdirStr
- the direction stringUnknownDirectionException
- thrown if the direction is not knownpublic void flushBlockBag(Actor actor, EditSession editSession)
actor
- the actoreditSession
- the edit sessionpublic boolean handleArmSwing(Player player)
player
- the playerpublic boolean handleRightClick(Player player)
player
- the playerpublic boolean handleBlockRightClick(Player player, Location clicked)
player
- the playerclicked
- the clicked blockpublic boolean handleBlockLeftClick(Player player, Location clicked)
player
- the playerclicked
- the clicked blockpublic void runScript(Player player, java.io.File f, java.lang.String[] args) throws WorldEditException
player
- the playerf
- the script file to executeargs
- arguments for the scriptWorldEditException
public LocalConfiguration getConfiguration()
public EditSessionFactory getEditSessionFactory()
EditSession
s.public static java.lang.String getVersion()