WorldEdit: craftscript run from craftscript

Discussion in 'Programming' started by Harch, Mar 12, 2020.

  1. Hello!

    I want to run a script from a script (WE 1.7.0).

    My trying:

    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!

    P. S. Sorry for my english.
     
  2. I do it. Thank you.