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 |
clearSessions()
Deprecated.
|
void |
flushBlockBag(Actor actor,
EditSession editSession)
Flush a block bag's changes to a player.
|
BaseBlock |
getBlock(Player player,
java.lang.String id)
Deprecated.
|
BaseBlock |
getBlock(Player player,
java.lang.String arg,
boolean allAllowed)
Deprecated.
|
BaseBlock |
getBlock(Player player,
java.lang.String arg,
boolean allAllowed,
boolean allowNoData)
Deprecated.
|
BlockFactory |
getBlockFactory()
Get the block factory from which new
BaseBlock s can be
constructed. |
java.util.Set<java.lang.Integer> |
getBlockIDs(Player player,
java.lang.String list,
boolean allBlocksAllowed)
Deprecated.
|
Mask |
getBlockMask(Player player,
LocalSession session,
java.lang.String input)
Deprecated.
|
Pattern |
getBlockPattern(Player player,
java.lang.String input)
Deprecated.
|
java.util.Set<BaseBlock> |
getBlocks(Player player,
java.lang.String list)
Deprecated.
|
java.util.Set<BaseBlock> |
getBlocks(Player player,
java.lang.String list,
boolean allAllowed)
Deprecated.
|
java.util.Set<BaseBlock> |
getBlocks(Player player,
java.lang.String list,
boolean allAllowed,
boolean allowNoData)
Deprecated.
|
LocalConfiguration |
getConfiguration()
Get Worldedit's configuration.
|
Vector |
getDiagonalDirection(Player player,
java.lang.String dirStr)
Get diagonal direction vector for a player's direction.
|
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.
|
CuboidClipboard.FlipDirection |
getFlipDirection(Player player,
java.lang.String dirStr)
Get the flip direction for a player's direction.
|
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.
|
ServerInterface |
getServer()
Get the server interface.
|
LocalSession |
getSession(Player player)
Deprecated.
|
LocalSession |
getSession(java.lang.String player)
Deprecated.
|
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,
WorldVector clicked)
Called on left click.
|
boolean |
handleBlockRightClick(Player player,
WorldVector clicked)
Called on right click.
|
boolean |
handleRightClick(Player player)
Called on right click (not on a block).
|
boolean |
hasSession(Player player)
Deprecated.
|
void |
removeSession(Player player)
Deprecated.
|
void |
runScript(Player player,
java.io.File f,
java.lang.String[] args)
Executes a WorldEdit script.
|
void |
setEditSessionFactory(EditSessionFactory factory)
Deprecated.
EditSessionFactories are no longer used. Please register an
EditSessionEvent event
with the event bus in order to override or catch changes to the world |
static void |
setVersion(java.lang.String version)
Deprecated.
Declare your platform version with
Platform.getPlatformVersion() |
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()
BaseBlock
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()
@Deprecated public LocalSession getSession(java.lang.String player)
getSessionManager()
@Deprecated public LocalSession getSession(Player player)
getSessionManager()
@Deprecated public void removeSession(Player player)
getSessionManager()
@Deprecated public void clearSessions()
getSessionManager()
@Deprecated public boolean hasSession(Player player)
getSessionManager()
@Deprecated public BaseBlock getBlock(Player player, java.lang.String arg, boolean allAllowed) throws WorldEditException
getBlockFactory()
and AbstractFactory.parseFromInput(String, ParserContext)
WorldEditException
@Deprecated public BaseBlock getBlock(Player player, java.lang.String arg, boolean allAllowed, boolean allowNoData) throws WorldEditException
getBlockFactory()
and AbstractFactory.parseFromInput(String, ParserContext)
WorldEditException
@Deprecated public BaseBlock getBlock(Player player, java.lang.String id) throws WorldEditException
getBlockFactory()
and AbstractFactory.parseFromInput(String, ParserContext)
WorldEditException
@Deprecated public java.util.Set<BaseBlock> getBlocks(Player player, java.lang.String list, boolean allAllowed, boolean allowNoData) throws WorldEditException
getBlockFactory()
and BlockFactory.parseFromListInput(String, ParserContext)
WorldEditException
@Deprecated public java.util.Set<BaseBlock> getBlocks(Player player, java.lang.String list, boolean allAllowed) throws WorldEditException
getBlockFactory()
and AbstractFactory.parseFromInput(String, ParserContext)
WorldEditException
@Deprecated public java.util.Set<BaseBlock> getBlocks(Player player, java.lang.String list) throws WorldEditException
getBlockFactory()
and BlockFactory.parseFromListInput(String, ParserContext)
WorldEditException
@Deprecated public java.util.Set<java.lang.Integer> getBlockIDs(Player player, java.lang.String list, boolean allBlocksAllowed) throws WorldEditException
getBlockFactory()
and BlockFactory.parseFromListInput(String, ParserContext)
WorldEditException
@Deprecated public Pattern getBlockPattern(Player player, java.lang.String input) throws WorldEditException
getPatternFactory()
and AbstractFactory.parseFromInput(String, ParserContext)
WorldEditException
@Deprecated public Mask getBlockMask(Player player, LocalSession session, java.lang.String input) throws WorldEditException
getMaskFactory()
()} and AbstractFactory.parseFromInput(String, ParserContext)
WorldEditException
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 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 Vector getDiagonalDirection(Player player, java.lang.String dirStr) throws UnknownDirectionException
player
- the playerdirStr
- the direction stringUnknownDirectionException
- thrown if the direction is not knownpublic CuboidClipboard.FlipDirection getFlipDirection(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, WorldVector clicked)
player
- the playerclicked
- the clicked blockpublic boolean handleBlockLeftClick(Player player, WorldVector 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 ServerInterface getServer()
public EditSessionFactory getEditSessionFactory()
EditSession
s.@Deprecated public void setEditSessionFactory(EditSessionFactory factory)
EditSessionEvent
event
with the event bus in order to override or catch changes to the worldpublic static java.lang.String getVersion()
@Deprecated public static void setVersion(java.lang.String version)
Platform.getPlatformVersion()