From 3d16323e339ccd227d4202142849bd76a2b12853 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 9 Aug 2021 17:53:36 +0200 Subject: [PATCH 1/2] Patch execute command --- .../studio/CommandIrisStudioExecute.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java index f08d3e332..daac56cfe 100644 --- a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java +++ b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java @@ -30,7 +30,7 @@ import com.volmit.iris.util.plugin.VolmitSender; public class CommandIrisStudioExecute extends MortarCommand { public CommandIrisStudioExecute() { - super("execute", "ex"); + super("execute", "ex", "exec"); requiresPermission(Iris.perm.studio); setDescription("Execute a script"); setCategory("Studio"); @@ -44,12 +44,13 @@ public class CommandIrisStudioExecute extends MortarCommand { sender.sendMessage("Tab complete options only work for summons while in an Iris world."); } else if (args.length == 0) { list.add(data.getScriptLoader().getPossibleKeys()); - } else if (args.length == 1) { + } else { list.add(data.getScriptLoader().getPossibleKeys(args[0])); } } } + @SuppressWarnings("null") @Override public boolean handle(VolmitSender sender, String[] args) { if (!IrisSettings.get().isStudio()) { @@ -57,13 +58,17 @@ public class CommandIrisStudioExecute extends MortarCommand { return true; } - PlatformChunkGenerator a = IrisToolbelt.access(sender.player().getWorld()); - - if (a != null) { - a.getEngine().getExecution().execute(args[0]); - Iris.info("Executed. See script output in console."); + if (!sender.isPlayer() || !IrisToolbelt.isIrisWorld(sender.player().getWorld())){ + sender.sendMessage("To execute scripts you must be in an Iris world as a player"); } + Iris.info("Executing script: " + args[0] + ". See script output in console."); + try { + IrisToolbelt.access(sender.player().getWorld()).getEngine().getExecution().execute(args[0]); + } catch (Throwable e){ + Iris.reportError(e); + sender.sendMessage("Failed to execute script " + args[0] + "!"); + } return true; } From 838ad5ec1a008c7a4d260d8345c20f844fd37351 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 9 Aug 2021 18:04:15 +0200 Subject: [PATCH 2/2] More patches --- .../core/command/studio/CommandIrisStudioExecute.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java index daac56cfe..46462ae46 100644 --- a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java +++ b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioExecute.java @@ -47,6 +47,8 @@ public class CommandIrisStudioExecute extends MortarCommand { } else { list.add(data.getScriptLoader().getPossibleKeys(args[0])); } + } else { + sender.sendMessage("You must be in an Iris world as a player to run scripts!"); } } @@ -60,7 +62,14 @@ public class CommandIrisStudioExecute extends MortarCommand { if (!sender.isPlayer() || !IrisToolbelt.isIrisWorld(sender.player().getWorld())){ sender.sendMessage("To execute scripts you must be in an Iris world as a player"); + return true; } + + if (args.length == 0){ + sender.sendMessage("You need to specify a script name (use auto-completions to see which are available)"); + return true; + } + Iris.info("Executing script: " + args[0] + ". See script output in console."); try {