public final 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 org.slf4j.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.
|
AssetLoaders |
getAssetLoaders()
Return the asset loaders instance.
|
BlockFactory |
getBlockFactory()
Get the block factory from which new
BlockStateHolder s can be
constructed. |
LocalConfiguration |
getConfiguration()
Get Worldedit's configuration.
|
BlockVector3 |
getDiagonalDirection(Player player,
java.lang.String dirStr)
Get the direction vector for a player's direction.
|
BlockVector3 |
getDirection(Player player,
java.lang.String dirStr)
Get the direction vector for a player's direction.
|
EditSessionFactory |
getEditSessionFactory()
Deprecated.
Use
newEditSessionBuilder() instead. See EditSessionFactory for details. |
EventBus |
getEventBus()
Get the event bus for WorldEdit.
|
com.google.common.util.concurrent.ListeningExecutorService |
getExecutorService()
Get the executor service.
|
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(Actor actor,
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(Actor actor,
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.
|
Supervisor |
getSupervisor()
Get the supervisor.
|
TranslationManager |
getTranslationManager()
Return the translation manager.
|
static java.lang.String |
getVersion()
Get the version.
|
java.io.File |
getWorkingDirectoryFile(java.lang.String path)
Deprecated.
Use
getWorkingDirectoryPath(String) instead |
java.nio.file.Path |
getWorkingDirectoryPath(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)
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 |
loadMappings()
Load the bundled mappings.
|
<A extends Actor & Locatable> |
newEditSession(A locatableActor)
Shorthand for
newEditSessionBuilder().locatableActor(locatableActor).build() . |
EditSession |
newEditSession(World world)
Shorthand for
newEditSessionBuilder().world(world).build() . |
EditSessionBuilder |
newEditSessionBuilder()
Create a builder for
EditSession s. |
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 Supervisor getSupervisor()
public com.google.common.util.concurrent.ListeningExecutorService getExecutorService()
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 TranslationManager getTranslationManager()
public AssetLoaders getAssetLoaders()
public java.io.File getSafeSaveFile(Actor actor, 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.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 anyFilenameException
- thrown if the filename is invalidpublic java.io.File getSafeOpenFile(Actor actor, 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.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 anyFilenameException
- thrown if the filename is invalidpublic void loadMappings()
public void checkMaxRadius(double radius) throws MaxRadiusException
radius
- the radiusMaxRadiusException
- if the radius is bigger than the configured radiuspublic void checkMaxBrushRadius(double radius) throws MaxBrushRadiusException
radius
- the radiusMaxBrushRadiusException
- if the radius is bigger than the configured radius@Deprecated public java.io.File getWorkingDirectoryFile(java.lang.String path)
getWorkingDirectoryPath(String)
insteadpath
- the subpath under the working directorypublic java.nio.file.Path getWorkingDirectoryPath(java.lang.String path)
path
- the subpath under the working directorypublic BlockVector3 getDirection(@Nullable Player player, java.lang.String dirStr) throws UnknownDirectionException
player
- the playerdirStr
- the direction stringUnknownDirectionException
- thrown if the direction is not known, or a relative direction is used with null playerpublic BlockVector3 getDiagonalDirection(@Nullable Player player, java.lang.String dirStr) throws UnknownDirectionException
player
- the playerdirStr
- the direction stringUnknownDirectionException
- thrown if the direction is not known, or a relative direction is used with null playerpublic 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 player@Deprecated public boolean handleBlockRightClick(Player player, Location clicked)
player
- the playerclicked
- the clicked blockpublic boolean handleBlockRightClick(Player player, Location clicked, @Nullable Direction face)
player
- the playerclicked
- the clicked blockface
- The clicked face@Deprecated public boolean handleBlockLeftClick(Player player, Location clicked)
player
- the playerclicked
- the clicked blockpublic boolean handleBlockLeftClick(Player player, Location clicked, @Nullable Direction face)
player
- the playerclicked
- the clicked blockface
- The clicked facepublic 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
- if something goes wrongpublic LocalConfiguration getConfiguration()
@Deprecated public EditSessionFactory getEditSessionFactory()
newEditSessionBuilder()
instead. See EditSessionFactory
for details.EditSession
s.public EditSessionBuilder newEditSessionBuilder()
EditSession
s.public EditSession newEditSession(@Nullable World world)
newEditSessionBuilder().world(world).build()
.world
- the worldEditSession
public <A extends Actor & Locatable> EditSession newEditSession(A locatableActor)
newEditSessionBuilder().locatableActor(locatableActor).build()
.locatableActor
- the actorEditSession
public static java.lang.String getVersion()