public class CraftScriptContext extends CraftScriptEnvironment
config, controller, player, server, session
Constructor and Description |
---|
CraftScriptContext(WorldEdit controller,
Platform server,
LocalConfiguration config,
LocalSession session,
Player player,
java.lang.String[] args) |
Modifier and Type | Method and Description |
---|---|
void |
checkArgs(int min,
int max,
java.lang.String usage)
Checks to make sure that there are enough but not too many arguments.
|
void |
error(java.lang.String message)
Print an error message to the user.
|
void |
exit()
Immediately terminate execution of the script, but without a failure message.
|
BaseBlock |
getBlock(java.lang.String id)
Get a block.
|
BaseBlock |
getBlock(java.lang.String input,
boolean allAllowed)
Get an item from an item name or an item ID number.
|
Pattern |
getBlockPattern(java.lang.String list)
Get a list of blocks as a set.
|
java.util.Set<BaseBlock> |
getBlocks(java.lang.String list,
boolean allBlocksAllowed)
Get a list of blocks as a set.
|
LocalConfiguration |
getConfiguration()
Get the configuration for WorldEdit.
|
java.util.List<EditSession> |
getEditSessions()
Get a list of edit sessions that have been created.
|
Player |
getPlayer()
Get the player.
|
java.io.File |
getSafeOpenFile(java.lang.String folder,
java.lang.String filename,
java.lang.String defaultExt,
java.lang.String... exts)
Gets the path to a file for opening.
|
java.io.File |
getSafeSaveFile(java.lang.String folder,
java.lang.String filename,
java.lang.String defaultExt,
java.lang.String... exts)
Gets the path to a file for saving.
|
LocalSession |
getSession()
Get the player's session.
|
void |
print(java.lang.String message)
Print a regular message to the user.
|
void |
printRaw(java.lang.String message)
Print a raw message to the user.
|
EditSession |
remember()
Get an edit session.
|
public CraftScriptContext(WorldEdit controller, Platform server, LocalConfiguration config, LocalSession session, Player player, java.lang.String[] args)
public EditSession remember()
public Player getPlayer()
public LocalSession getSession()
public LocalConfiguration getConfiguration()
public java.util.List<EditSession> getEditSessions()
EditSession
spublic void print(java.lang.String message)
message
- a messagepublic void error(java.lang.String message)
message
- a messagepublic void printRaw(java.lang.String message)
message
- a messagepublic void checkArgs(int min, int max, java.lang.String usage) throws InsufficientArgumentsException
min
- a number of argumentsmax
- -1 for no maximumusage
- usage stringInsufficientArgumentsException
- if the arguments are not "sufficiently" goodpublic void exit()
public BaseBlock getBlock(java.lang.String input, boolean allAllowed) throws WorldEditException
input
- input to parseallAllowed
- true to ignore blacklistsNoMatchException
- if no block was foundDisallowedUsageException
- if the block is disallowedWorldEditException
public BaseBlock getBlock(java.lang.String id) throws WorldEditException
id
- the type IdNoMatchException
- if no block was foundDisallowedUsageException
- if the block is disallowedWorldEditException
public Pattern getBlockPattern(java.lang.String list) throws WorldEditException
list
- the inputNoMatchException
- if the pattern was invalidDisallowedUsageException
- if the block is disallowedWorldEditException
public java.util.Set<BaseBlock> getBlocks(java.lang.String list, boolean allBlocksAllowed) throws WorldEditException
list
- a listallBlocksAllowed
- true if all blocks are allowedNoMatchException
- if the blocks couldn't be foundDisallowedUsageException
- if the block is disallowedWorldEditException
public java.io.File getSafeOpenFile(java.lang.String folder, java.lang.String filename, java.lang.String defaultExt, java.lang.String... exts) throws FilenameException
java.io.File
object will be
returned.
Use this method if you need to read a file from a directory.
folder
- sub-directory to look infilename
- filename (user-submitted)defaultExt
- default extension to append if there is noneexts
- list of extensions for file open dialog, null for no filterFilenameException
- if there is a problem with the name of the filepublic java.io.File getSafeSaveFile(java.lang.String folder, java.lang.String filename, java.lang.String defaultExt, java.lang.String... exts) throws FilenameException
java.io.File
object will be
returned.
Use this method if you need to read a file from a directory.
folder
- sub-directory to look infilename
- filename (user-submitted)defaultExt
- default extension to append if there is noneexts
- list of extensions for file save dialog, null for no filterFilenameException
- if there is a problem with the name of the file