WorldEdit

WorldEdit

43M Downloads

Run another script from a script

Harchvertelol opened this issue ยท 1 comments

commented

Question for WE 6.1.1 and 7.1.0.

How can I run another script from a script (craft script) in the same context? I need the functions from another script file to become available in my script without manually pasting the code of the second script into the first.

My trying in 7.1.0:

function include1(strfilename)
{
csc = new RhinoCraftScriptEngine();
csc.setTimeLimit(context.getConfiguration().scriptTimeout);
arvtmp = argv;

vars = new HashMap();
vars.put("argv", argvtmp);
vars.put("context", context);
vars.put("player", player);
csc.evaluate("", strfilename, player);
}

function include(strfilename)
{
filescript = context.getSafeOpenFile("craftscripts", strfilename, "js");
WorldEdit.getInstance().runScript(context.getPlayer(), filescript, argv);
}

Both function not working with errors (after this trying me should reload plugin, else all scripts not working):

[02:17:25] [Server thread/WARN]: Failed to execute script
java.lang.SecurityException: Cannot overwrite existing ClassShutter object
at org.mozilla.javascript.Context.setClassShutter(Context.java:1968) ~[?:?]
at com.sk89q.worldedit.scripting.RhinoCraftScriptEngine.evaluate(RhinoCraftScriptEngine.java:53) ~[?:?]
at com.sk89q.worldedit.WorldEdit.runScript(WorldEdit.java:698) ~[?:?]
at com.sk89q.worldedit.command.ScriptingCommands.execute(ScriptingCommands.java:80) ~[?:?]
at com.sk89q.worldedit.command.ScriptingCommandsRegistration.cmd$cs(ScriptingCommandsRegistration.java:113) ~[?:?]
at org.enginehub.piston.CommandManager.execute(CommandManager.java:158) ~[?:?]
at com.sk89q.worldedit.extension.platform.PlatformCommandManager.handleCommand(PlatformCommandManager.java:486) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_241]
at com.sk89q.worldedit.util.eventbus.MethodEventHandler.dispatch(MethodEventHandler.java:58) ~[?:?]
at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:73) ~[?:?]
at com.sk89q.worldedit.util.eventbus.EventBus.dispatch(EventBus.java:193) ~[?:?]
at com.sk89q.worldedit.util.eventbus.EventBus.post(EventBus.java:181) ~[?:?]
at com.sk89q.worldedit.bukkit.WorldEditPlugin.onCommand(WorldEditPlugin.java:348) ~[?:?]
at com.sk89q.bukkit.util.DynamicPluginCommand.execute(DynamicPluginCommand.java:55) ~[?:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:711) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.PlayerConnection.handleCommand(PlayerConnection.java:1657) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1497) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:918) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:911) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:895) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:828) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]

How I can do this? Thank you so much!

commented

Please ask questions on the EngineHub Discord