mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 14:48:34 +00:00
Major command changes that don't work yet.
This commit is contained in:
@ -8,11 +8,10 @@ import com.boydti.fawe.util.MainUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.BrushProcessor;
|
||||
import com.sk89q.worldedit.command.BrushCommands;
|
||||
import com.sk89q.worldedit.extension.factory.parser.mask.DefaultMaskParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser;
|
||||
import com.sk89q.worldedit.extension.factory.parser.pattern.DefaultPatternParser;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.util.command.ProcessedCallable;
|
||||
import com.sk89q.worldedit.util.command.parametric.FunctionParametricCallable;
|
||||
|
||||
@ -63,15 +62,15 @@ public class CommandScriptLoader {
|
||||
if (name.endsWith(".js")) {
|
||||
Fawe.debug("Loading script: " + name);
|
||||
List<FunctionParametricCallable> cmds = getCommands(file, Collections.emptyMap());
|
||||
FaweParser parser = null;
|
||||
if (aliases.length == 1) {
|
||||
FaweParser parser = null;
|
||||
switch (aliases[0]) {
|
||||
case "brush":
|
||||
if (!cmds.isEmpty()) {
|
||||
BrushProcessor processor = new BrushProcessor(WorldEdit.getInstance());
|
||||
BrushCommands processor = new BrushCommands(WorldEdit.getInstance());
|
||||
for (FunctionParametricCallable cmd : cmds) {
|
||||
ProcessedCallable processed = new ProcessedCallable(cmd, processor);
|
||||
CommandManager.getInstance().registerCommand(aliases, cmd.getCommand(), processed);
|
||||
PlatformCommandManager.getInstance().registerCommand(aliases, cmd.getCommand(), processed);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -90,7 +89,7 @@ public class CommandScriptLoader {
|
||||
}
|
||||
}
|
||||
for (FunctionParametricCallable cmd : cmds) {
|
||||
CommandManager.getInstance().registerCommand(aliases, cmd.getCommand(), cmd);
|
||||
PlatformCommandManager.getInstance().registerSubCommands(name);registerCommand(aliases, cmd.getCommand(), cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,4 +99,4 @@ public class CommandScriptLoader {
|
||||
String script = new String(Files.readAllBytes(file.toPath())) + loader;
|
||||
return (List) engine.evaluate(script, file.getPath(), vars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,13 @@
|
||||
|
||||
package com.sk89q.worldedit.scripting;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.DisallowedItemException;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.UnknownItemException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.InsufficientArgumentsException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
@ -56,7 +59,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
/**
|
||||
* Get an edit session. Every subsequent call returns a new edit session.
|
||||
* Usually you only need to use one edit session.
|
||||
*
|
||||
*
|
||||
* @return an edit session
|
||||
*/
|
||||
public EditSession remember() {
|
||||
@ -71,7 +74,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
*
|
||||
* @return the calling player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
@ -80,7 +83,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
/**
|
||||
* Get the player's session.
|
||||
*
|
||||
*
|
||||
* @return a session
|
||||
*/
|
||||
public LocalSession getSession() {
|
||||
@ -89,7 +92,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
/**
|
||||
* Get the configuration for WorldEdit.
|
||||
*
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
public LocalConfiguration getConfiguration() {
|
||||
@ -98,7 +101,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
/**
|
||||
* Get a list of edit sessions that have been created.
|
||||
*
|
||||
*
|
||||
* @return a list of created {@code EditSession}s
|
||||
*/
|
||||
public List<EditSession> getEditSessions() {
|
||||
@ -107,7 +110,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
/**
|
||||
* Print a regular message to the user.
|
||||
*
|
||||
*
|
||||
* @param message a message
|
||||
*/
|
||||
public void print(String message) {
|
||||
@ -116,7 +119,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
/**
|
||||
* Print an error message to the user.
|
||||
*
|
||||
*
|
||||
* @param message a message
|
||||
*/
|
||||
public void error(String message) {
|
||||
@ -125,7 +128,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
/**
|
||||
* Print an raw message to the user.
|
||||
*
|
||||
*
|
||||
* @param message a message
|
||||
*/
|
||||
public void printRaw(String message) {
|
||||
@ -184,8 +187,8 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
*
|
||||
* @param list the input
|
||||
* @return pattern
|
||||
* @throws UnknownItemException
|
||||
* @throws DisallowedItemException
|
||||
* @throws UnknownItemException
|
||||
* @throws DisallowedItemException
|
||||
*/
|
||||
public Pattern getBlockPattern(String list) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
@ -201,8 +204,8 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
* @param list a list
|
||||
* @param allBlocksAllowed true if all blocks are allowed
|
||||
* @return set
|
||||
* @throws UnknownItemException
|
||||
* @throws DisallowedItemException
|
||||
* @throws UnknownItemException
|
||||
* @throws DisallowedItemException
|
||||
*/
|
||||
public Set<BaseBlock> getBlocks(String list, boolean allBlocksAllowed) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
@ -219,15 +222,15 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
* directory traversal exploits by checking the root directory and the file
|
||||
* directory. On success, a {@code java.io.File} object will be
|
||||
* returned.
|
||||
*
|
||||
*
|
||||
* <p>Use this method if you need to read a file from a directory.</p>
|
||||
*
|
||||
*
|
||||
* @param folder sub-directory to look in
|
||||
* @param filename filename (user-submitted)
|
||||
* @param defaultExt default extension to append if there is none
|
||||
* @param exts list of extensions for file open dialog, null for no filter
|
||||
* @return a file
|
||||
* @throws FilenameException
|
||||
* @throws FilenameException
|
||||
*/
|
||||
public File getSafeOpenFile(String folder, String filename, String defaultExt, String... exts) throws FilenameException {
|
||||
File dir = controller.getWorkingDirectoryFile(folder);
|
||||
@ -240,15 +243,15 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
* directory traversal exploits by checking the root directory and the file
|
||||
* directory. On success, a {@code java.io.File} object will be
|
||||
* returned.
|
||||
*
|
||||
*
|
||||
* <p>Use this method if you need to read a file from a directory.</p>
|
||||
*
|
||||
*
|
||||
* @param folder sub-directory to look in
|
||||
* @param filename filename (user-submitted)
|
||||
* @param defaultExt default extension to append if there is none
|
||||
* @param exts list of extensions for file save dialog, null for no filter
|
||||
* @return a file
|
||||
* @throws FilenameException
|
||||
* @throws FilenameException
|
||||
*/
|
||||
public File getSafeSaveFile(String folder, String filename, String defaultExt, String... exts) throws FilenameException {
|
||||
File dir = controller.getWorkingDirectoryFile(folder);
|
||||
|
@ -58,8 +58,7 @@ public class NashornCraftScriptEngine implements CraftScriptEngine {
|
||||
}
|
||||
|
||||
try {
|
||||
Object result = engine.eval(script, bindings);
|
||||
return result;
|
||||
return engine.eval(script, bindings);
|
||||
} catch (Error e) {
|
||||
e.printStackTrace();
|
||||
throw new ScriptException(e.getMessage());
|
||||
@ -72,7 +71,6 @@ public class NashornCraftScriptEngine implements CraftScriptEngine {
|
||||
throw e;
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,15 +120,13 @@ public class RhinoScriptEngine extends AbstractScriptEngine {
|
||||
public ScriptEngineFactory getFactory() {
|
||||
if (factory != null) {
|
||||
return factory;
|
||||
} else {
|
||||
return new RhinoScriptEngineFactory();
|
||||
}
|
||||
return new RhinoScriptEngineFactory();
|
||||
}
|
||||
|
||||
private Scriptable setupScope(Context cx, ScriptContext context) {
|
||||
ScriptableObject scriptable = new ImporterTopLevel(cx);
|
||||
Scriptable scope = cx.initStandardObjects(scriptable);
|
||||
//ScriptableObject.putProperty(scope, "argv", Context.javaToJS(args, scope));
|
||||
return scope;
|
||||
return cx.initStandardObjects(scriptable);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user