From e328bf616f96138d1c281e52c125eadcb55483ab Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 15:34:34 +0200 Subject: [PATCH] Utility function extension --- .../iris/core/decrees/DecIrisStudio.java | 32 +--------------- .../core/decrees/DecreeStudioExtension.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java index 2dfc8d308..c6618bd0d 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -48,7 +48,7 @@ import java.io.File; import java.util.function.Supplier; @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) -public class DecIrisStudio implements DecreeExecutor { +public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { @Decree(description = "Open a new studio world", aliases = "o", sync = true) public void open( @Param(name = "dimension", defaultValue = "overworld", description = "The dimension to open a studio for", aliases = "dim") @@ -227,34 +227,4 @@ public class DecIrisStudio implements DecreeExecutor { Iris.proj.compilePackage(sender(), dimension, obfuscate, minify); }); } - - /** - * @return true if server GUIs are not enabled - */ - private boolean noGUI() { - if (!IrisSettings.get().isUseServerLaunchedGuis()){ - error("You must have server launched GUIs enabled in the settings!"); - return true; - } - return false; - } - - /** - * @return true if no studio is open & the player - */ - private boolean noStudio(){ - if (!sender().isPlayer()){ - error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER)"); - return true; - } - if (!Iris.proj.isProjectOpen()){ - error("No studio world is open!"); - return true; - } - if (!engine().isStudio()){ - error("You must be in a studio world!"); - return true; - } - return false; - } } diff --git a/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java b/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java new file mode 100644 index 000000000..09c9e691c --- /dev/null +++ b/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java @@ -0,0 +1,38 @@ +package com.volmit.iris.core.decrees; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisSettings; +import com.volmit.iris.util.decree.DecreeExecutor; + +public interface DecreeStudioExtension extends DecreeExecutor { + + /** + * @return true if server GUIs are not enabled + */ + default boolean noGUI() { + if (!IrisSettings.get().isUseServerLaunchedGuis()){ + error("You must have server launched GUIs enabled in the settings!"); + return true; + } + return false; + } + + /** + * @return true if no studio is open & the player + */ + default boolean noStudio(){ + if (!sender().isPlayer()){ + error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER)"); + return true; + } + if (!Iris.proj.isProjectOpen()){ + error("No studio world is open!"); + return true; + } + if (!engine().isStudio()){ + error("You must be in a studio world!"); + return true; + } + return false; + } +}