From 22d215b2c725babff7c69e5395ed0ee482652b2b Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 21:18:15 +0200 Subject: [PATCH 01/45] Doc --- .../java/com/volmit/iris/util/decree/annotations/Decree.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java b/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java index 5d569ad1b..5406e2fb0 100644 --- a/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java +++ b/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java @@ -42,6 +42,10 @@ public @interface Decree { */ boolean studio() default false; + /** + * If the node's functions MUST be run in sync, set this to true.
+ * Defaults to false + */ boolean sync() default false; /** From 4215bfc6fe36f1cf5da393082820bda3b4dd86bc Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 21:22:22 +0200 Subject: [PATCH 02/45] CMD -> Dec + fixes --- src/main/java/com/volmit/iris/core/CommandManager.java | 4 ++-- .../volmit/iris/core/decrees/{CMDIris.java => DecIris.java} | 6 +++--- .../core/decrees/{CMDIrisStudio.java => DecIrisStudio.java} | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/com/volmit/iris/core/decrees/{CMDIris.java => DecIris.java} (87%) rename src/main/java/com/volmit/iris/core/decrees/{CMDIrisStudio.java => DecIrisStudio.java} (94%) diff --git a/src/main/java/com/volmit/iris/core/CommandManager.java b/src/main/java/com/volmit/iris/core/CommandManager.java index d20688aff..4c59f5df1 100644 --- a/src/main/java/com/volmit/iris/core/CommandManager.java +++ b/src/main/java/com/volmit/iris/core/CommandManager.java @@ -19,7 +19,7 @@ package com.volmit.iris.core; import com.volmit.iris.Iris; -import com.volmit.iris.core.decrees.CMDIris; +import com.volmit.iris.core.decrees.DecIris; import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.decree.DecreeSystem; @@ -37,7 +37,7 @@ public class CommandManager implements DecreeSystem { public VirtualDecreeCommand getRoot() { return commandCache.aquire(() -> { try { - return VirtualDecreeCommand.createRoot(new CMDIris()); + return VirtualDecreeCommand.createRoot(new DecIris()); } catch (Throwable e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/core/decrees/CMDIris.java b/src/main/java/com/volmit/iris/core/decrees/DecIris.java similarity index 87% rename from src/main/java/com/volmit/iris/core/decrees/CMDIris.java rename to src/main/java/com/volmit/iris/core/decrees/DecIris.java index 4c3cdda4b..d1daf9f5e 100644 --- a/src/main/java/com/volmit/iris/core/decrees/CMDIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -23,13 +23,13 @@ import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") -public class CMDIris implements DecreeExecutor +public class DecIris implements DecreeExecutor { - private CMDIrisStudio studio; + private DecIrisStudio studio; @Decree(description = "Ping self", aliases = "p") public void ping( - @Param(name = "message",defaultValue = "Pong", aliases = {"msg", "m"}) + @Param(name = "message", defaultValue = "Pong", aliases = {"msg", "m"}) String message) { sender().sendMessage(message + "!"); diff --git a/src/main/java/com/volmit/iris/core/decrees/CMDIrisStudio.java b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java similarity index 94% rename from src/main/java/com/volmit/iris/core/decrees/CMDIrisStudio.java rename to src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java index ed71b7620..4ed6f2baa 100644 --- a/src/main/java/com/volmit/iris/core/decrees/CMDIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -26,7 +26,7 @@ import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) -public class CMDIrisStudio implements DecreeExecutor +public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Open a new studio world", aliases = "o", sync = true) public void open( @@ -35,7 +35,7 @@ public class CMDIrisStudio implements DecreeExecutor @Param(name = "seed", defaultValue = "1337", aliases = "s") long seed) { - Iris.proj.open(sender(), dimension.getLoadKey()); + Iris.proj.open(sender(), seed, dimension.getLoadKey()); } @Decree(description = "Close an open studio project", aliases = "x", sync = true) From 1b941536d0ad4f2c77da2d3fa520a37e17364e28 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 21:32:41 +0200 Subject: [PATCH 03/45] Required = !hasDefault && constant --- .../java/com/volmit/iris/core/decrees/DecIrisStudio.java | 2 +- .../java/com/volmit/iris/util/decree/DecreeParameter.java | 6 +++--- .../java/com/volmit/iris/util/decree/annotations/Param.java | 6 +++--- .../iris/util/decree/virtual/VirtualDecreeCommand.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) 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 4ed6f2baa..8ade2ffb0 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -30,7 +30,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Open a new studio world", aliases = "o", sync = true) public void open( - @Param(name = "dimension", defaultValue = "overworld", aliases = "dim", required = true) + @Param(name = "dimension", defaultValue = "overworld", aliases = "dim") IrisDimension dimension, @Param(name = "seed", defaultValue = "1337", aliases = "s") long seed) diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java index 85376f295..0ec241f1b 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java @@ -57,7 +57,7 @@ public class DecreeParameter { } public boolean isRequired() { - return param.required(); + return !hasDefault(); } public KList getNames() { @@ -80,11 +80,11 @@ public class DecreeParameter { } public Object getDefaultValue() throws DecreeParsingException, DecreeWhichException { - return param.defaultValue().isEmpty() ? null : getHandler().parse(param.defaultValue()); + return param.defaultValue().equals(Param.REQUIRED) ? null : getHandler().parse(param.defaultValue()); } public boolean hasDefault() { - return !param.defaultValue().isEmpty(); + return !param.defaultValue().equals(Param.REQUIRED); } public String example() { diff --git a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java index dab1c9c83..529eb7266 100644 --- a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java +++ b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java @@ -28,6 +28,8 @@ import java.lang.annotation.Target; public @interface Param { String DEFAULT_DESCRIPTION = "No Description Provided"; + String REQUIRED = "Required"; + /** * The main name of this command.
* Required parameter.
@@ -35,8 +37,6 @@ public @interface Param { */ String name(); - boolean required() default false; - /** * The description of this parameter, used in help-popups in game.
* The default value is {@link #DEFAULT_DESCRIPTION} @@ -49,7 +49,7 @@ public @interface Param { * Which indicates the variable MUST be defined by the person running the command.
* If you define this, the variable automatically becomes non-required, but can still be set. */ - String defaultValue() default ""; + String defaultValue() default REQUIRED; /** * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))
diff --git a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java index 37b93c194..1e1a88211 100644 --- a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java +++ b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java @@ -327,7 +327,7 @@ public class VirtualDecreeCommand { try { - if(value == null && !i.getParam().defaultValue().trim().isEmpty()) + if(value == null && i.hasDefault()) { value = i.getDefaultValue(); } From fc60878c25feab44a82a89133a2428c8814bd547 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 21:58:02 +0200 Subject: [PATCH 04/45] why --- src/main/java/com/volmit/iris/core/ProjectManager.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/ProjectManager.java b/src/main/java/com/volmit/iris/core/ProjectManager.java index fb90ce471..9e7a9130a 100644 --- a/src/main/java/com/volmit/iris/core/ProjectManager.java +++ b/src/main/java/com/volmit/iris/core/ProjectManager.java @@ -329,11 +329,7 @@ public class ProjectManager { public void open(VolmitSender sender, long seed, String dimm) { try { - open(sender,seed, dimm, () -> - { - if (sender.isPlayer()) { - } - }); + open(sender,seed, dimm, () -> {}); } catch (Exception e) { Iris.reportError(e); sender.sendMessage("Error when creating studio world:"); From d0faaf2d5352b251a96b51040eaad8f7f529f87d Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 21:58:11 +0200 Subject: [PATCH 05/45] desc + bootify --- .../java/com/volmit/iris/core/decrees/DecIrisStudio.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 8ade2ffb0..659ded2e9 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -30,9 +30,9 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Open a new studio world", aliases = "o", sync = true) public void open( - @Param(name = "dimension", defaultValue = "overworld", aliases = "dim") + @Param(name = "dimension", defaultValue = "overworld", description = "The dimension to open a studio for", aliases = "dim") IrisDimension dimension, - @Param(name = "seed", defaultValue = "1337", aliases = "s") + @Param(name = "seed", defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") long seed) { Iris.proj.open(sender(), seed, dimension.getLoadKey()); @@ -46,8 +46,7 @@ public class DecIrisStudio implements DecreeExecutor return; } - Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().evacuate(); Iris.proj.close(); - sender().sendMessage(C.YELLOW + "Project Closed"); + sender().sendMessage(C.GREEN + "Project Closed."); } } From 7920d2225ce510f2fef261c96f99993f4be38f8b Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 22:22:07 +0200 Subject: [PATCH 06/45] version --- .../java/com/volmit/iris/core/decrees/DecIris.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIris.java b/src/main/java/com/volmit/iris/core/decrees/DecIris.java index d1daf9f5e..6bbe4d2da 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -18,6 +18,7 @@ package com.volmit.iris.core.decrees; +import com.volmit.iris.Iris; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; @@ -27,11 +28,16 @@ public class DecIris implements DecreeExecutor { private DecIrisStudio studio; - @Decree(description = "Ping self", aliases = "p") + @Decree(description = "Send a message to yourself", aliases = "p") public void ping( - @Param(name = "message", defaultValue = "Pong", aliases = {"msg", "m"}) + @Param(name = "message", description = "The message to send", defaultValue = "Pong", aliases = {"msg", "m"}) String message) { sender().sendMessage(message + "!"); } + + @Decree(description = "Print version information", aliases = {"v", "ver"}) + public void version(){ + sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); + } } From 1134cd778831eb47641f9e37eab266b4d84ae5e4 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 22:22:16 +0200 Subject: [PATCH 07/45] Notify user of opening studio --- src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java | 1 + 1 file changed, 1 insertion(+) 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 659ded2e9..a59564ce9 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -35,6 +35,7 @@ public class DecIrisStudio implements DecreeExecutor @Param(name = "seed", defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") long seed) { + sender().sendMessage(C.GREEN + "Opening studio for the " + dimension.getName() + " pack (seed: " + seed + ")"); Iris.proj.open(sender(), seed, dimension.getLoadKey()); } From ce36bcc9517e726cbdee561101b7eb7f147d8c04 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 22:41:25 +0200 Subject: [PATCH 08/45] JSON Cleaner in util & Decree tag & beatify DecreeCMD --- .../studio/CommandIrisStudioBeautify.java | 2 +- .../iris/core/decrees/DecIrisStudio.java | 36 +++++++++- .../volmit/iris/util/decree/DecreeSystem.java | 2 +- .../decree/virtual/VirtualDecreeCommand.java | 2 +- .../volmit/iris/util/json/JSONCleaner.java | 66 +++++++++++++++++++ 5 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/volmit/iris/util/json/JSONCleaner.java diff --git a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java index 16b465c3b..6c4fcd4a8 100644 --- a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java +++ b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java @@ -73,7 +73,6 @@ public class CommandIrisStudioBeautify extends MortarCommand { return true; } - private int clean(VolmitSender s, File clean) { int c = 0; if (clean.isDirectory()) { @@ -131,6 +130,7 @@ public class CommandIrisStudioBeautify extends MortarCommand { } + @Override protected String getArgsUsage() { return "[project]"; 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 a59564ce9..7563bb8b0 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -24,6 +24,14 @@ import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; +import com.volmit.iris.util.format.Form; +import com.volmit.iris.util.io.IO; +import com.volmit.iris.util.json.JSONCleaner; +import com.volmit.iris.util.json.JSONObject; +import com.volmit.iris.util.plugin.VolmitSender; + +import java.io.File; +import java.io.IOException; @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) public class DecIrisStudio implements DecreeExecutor @@ -35,7 +43,7 @@ public class DecIrisStudio implements DecreeExecutor @Param(name = "seed", defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") long seed) { - sender().sendMessage(C.GREEN + "Opening studio for the " + dimension.getName() + " pack (seed: " + seed + ")"); + sender().sendMessage(C.GREEN + "Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")"); Iris.proj.open(sender(), seed, dimension.getLoadKey()); } @@ -50,4 +58,30 @@ public class DecIrisStudio implements DecreeExecutor Iris.proj.close(); sender().sendMessage(C.GREEN + "Project Closed."); } + + @Decree(description = "Get the version of a pack", aliases = {"v", "ver"}) + public void version( + @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim") + IrisDimension dimension + ) + { + sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); + } + + @Decree(description = "Beatify a pack", aliases = {"beauty", "prettify"}) + public void beautify( + @Param(name = "dimension", defaultValue = "overworld", description = "The to-beautify dimension", aliases = "dim") + IrisDimension dimension + ) + { + File folder = dimension.getLoadFile(); + sender().sendMessage("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); + } + + @Decree(description = "Beatify a pack - must be in studio!", aliases = {"beauty", "prettify"}) + public void beautify() + { + File folder = Iris.proj.getActiveProject().getPath(); + sender().sendMessage("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); + } } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java b/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java index 341ef6009..6b177e455 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java @@ -53,7 +53,7 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { @Override default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { J.aBukkit(() -> { - if(!call(new VolmitSender(sender), args)) + if(!call(new VolmitSender(sender, Iris.instance.getTag()), args)) { sender.sendMessage(C.RED + "Unknown Iris Command"); } diff --git a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java index 1e1a88211..499363d0d 100644 --- a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java +++ b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java @@ -276,7 +276,7 @@ public class VirtualDecreeCommand { if(isStudio() && !IrisSettings.get().isStudio()) { sender.sendMessage(C.RED + "To use Iris Studio Commands, please enable studio in Iris/settings.json (settings auto-reload)"); - return false; + return true; // Must still return true because command exists but is not enabled } Iris.debug("@ " + getPath() + " with " + args.toString(", ")); diff --git a/src/main/java/com/volmit/iris/util/json/JSONCleaner.java b/src/main/java/com/volmit/iris/util/json/JSONCleaner.java new file mode 100644 index 000000000..d75b360e3 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/json/JSONCleaner.java @@ -0,0 +1,66 @@ +package com.volmit.iris.util.json; + +import com.volmit.iris.Iris; +import com.volmit.iris.util.io.IO; +import com.volmit.iris.util.plugin.VolmitSender; + +import java.io.File; +import java.io.IOException; + +public class JSONCleaner { + public static int clean(VolmitSender s, File clean) { + int c = 0; + if (clean.isDirectory()) { + for (File i : clean.listFiles()) { + c += clean(s, i); + } + } else if (clean.getName().endsWith(".json")) { + try { + clean(clean); + } catch (Throwable e) { + Iris.reportError(e); + Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!"); + } + + c++; + } + + return c; + } + + public static void clean(File clean) throws IOException { + JSONObject obj = new JSONObject(IO.readAll(clean)); + fixBlocks(obj, clean); + + IO.writeAll(clean, obj.toString(4)); + } + + public static void fixBlocks(JSONObject obj, File f) { + for (String i : obj.keySet()) { + Object o = obj.get(i); + + if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { + obj.put(i, "minecraft:" + o); + Iris.debug("Updated Block Key: " + o + " to " + obj.getString(i) + " in " + f.getPath()); + } + + if (o instanceof JSONObject) { + fixBlocks((JSONObject) o, f); + } else if (o instanceof JSONArray) { + fixBlocks((JSONArray) o, f); + } + } + } + + public static void fixBlocks(JSONArray obj, File f) { + for (int i = 0; i < obj.length(); i++) { + Object o = obj.get(i); + + if (o instanceof JSONObject) { + fixBlocks((JSONObject) o, f); + } else if (o instanceof JSONArray) { + fixBlocks((JSONArray) o, f); + } + } + } +} From c26c14227ca0715b2cf8c4fcc0af8250857a919a Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 22:43:48 +0200 Subject: [PATCH 09/45] convert --- .../java/com/volmit/iris/core/decrees/DecIrisStudio.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 7563bb8b0..46924e062 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -84,4 +84,12 @@ public class DecIrisStudio implements DecreeExecutor File folder = Iris.proj.getActiveProject().getPath(); sender().sendMessage("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } + + @Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv") + public void convert() + { + Iris.convert.check(sender()); + } + + } From b1278aff2e71bc16c890099a11a5af173a077ea7 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 22:48:14 +0200 Subject: [PATCH 10/45] editbiome --- .../iris/core/decrees/DecIrisStudio.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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 46924e062..432980fe4 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -21,6 +21,7 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; import com.volmit.iris.engine.object.dimensional.IrisDimension; import com.volmit.iris.util.decree.DecreeExecutor; +import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; @@ -30,6 +31,7 @@ import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.plugin.VolmitSender; +import java.awt.*; import java.io.File; import java.io.IOException; @@ -91,5 +93,30 @@ public class DecIrisStudio implements DecreeExecutor Iris.convert.check(sender()); } - + + @Decree(description = "Edit the biome you're currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER) + public void editbiome() + { + if (!Iris.proj.isProjectOpen()){ + sender().sendMessage(C.RED + "The is no studio currently open!"); + return; + } + + if (!Iris.proj.getActiveProject().getActiveProvider().getEngine().getWorld().realWorld().equals(sender().player().getWorld())){ + sender().sendMessage(C.RED + "You must be in a studio world to edit a biome!"); + return; + } + + + try { + File f = Iris.proj.getActiveProject().getActiveProvider().getEngine().getBiome( + sender().player().getLocation().getBlockX(), + sender().player().getLocation().getBlockY(), + sender().player().getLocation().getBlockZ()).getLoadFile(); + Desktop.getDesktop().open(f); + } catch (Throwable e) { + Iris.reportError(e); + sender().sendMessage("Cant find the file. Unsure why this happened."); + } + } } From e8ac971f9e68c4bbb60a31751a6ebee3b2ac8ba2 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Fri, 13 Aug 2021 22:57:02 +0200 Subject: [PATCH 11/45] Script. Please check this. This is probably wrong. --- .../com/volmit/iris/core/decrees/DecIrisStudio.java | 11 +++++++++++ .../volmit/iris/engine/IrisExecutionEnvironment.java | 9 +++++++-- .../engine/scripting/EngineExecutionEnvironment.java | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) 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 432980fe4..bb284fd6c 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -19,6 +19,8 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; +import com.volmit.iris.core.tools.IrisToolbelt; +import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeOrigin; @@ -119,4 +121,13 @@ public class DecIrisStudio implements DecreeExecutor sender().sendMessage("Cant find the file. Unsure why this happened."); } } + + @Decree(description = "Execute a script", aliases = {"ex", "exec", "run"}, origin = DecreeOrigin.PLAYER) + public void execute( + @Param(name = "script", description = "The script to run", aliases = {"s", "scr"}) + IrisScript script + ) + { + IrisToolbelt.access(sender().player().getWorld()).getEngine().getExecution().execute(script); + } } diff --git a/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java b/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java index 78a1c3ea9..be64f4d24 100644 --- a/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java +++ b/src/main/java/com/volmit/iris/engine/IrisExecutionEnvironment.java @@ -20,6 +20,7 @@ package com.volmit.iris.engine; import com.volmit.iris.Iris; import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.scripting.EngineExecutionEnvironment; import com.volmit.iris.engine.scripting.IrisScriptingAPI; import com.volmit.iris.util.format.C; @@ -54,9 +55,13 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment { } public void execute(String script) { - Iris.debug("Execute Script (void) " + C.DARK_GREEN + script); + execute(getEngine().getData().getScriptLoader().load(script)); + } + + public void execute(IrisScript script) { + Iris.debug("Execute Script (void) " + C.DARK_GREEN + script.getLoadKey()); try { - javaScriptEngine.exec("", 0, 0, getEngine().getData().getScriptLoader().load(script)); + javaScriptEngine.exec("", 0, 0, script); } catch (BSFException e) { e.printStackTrace(); } diff --git a/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java b/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java index 100279ece..f85c11736 100644 --- a/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java +++ b/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java @@ -19,6 +19,7 @@ package com.volmit.iris.engine.scripting; import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.object.common.IrisScript; import org.apache.bsf.BSFManager; public interface EngineExecutionEnvironment { @@ -30,6 +31,8 @@ public interface EngineExecutionEnvironment { void execute(String script); + void execute(IrisScript script); + Object evaluate(String script); default void close() { From 748227319cc36b161d8e615df5daf14e8cb50e49 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 11:14:17 +0200 Subject: [PATCH 12/45] Noise explorer --- .../volmit/iris/core/decrees/DecIrisStudio.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 bb284fd6c..daa4a4733 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -19,6 +19,8 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisSettings; +import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; @@ -130,4 +132,17 @@ public class DecIrisStudio implements DecreeExecutor { IrisToolbelt.access(sender().player().getWorld()).getEngine().getExecution().execute(script); } + + @Decree(description = "Open the noise explorer (must have a local server!)", aliases = "nmap") + public void noise() + { + if (!IrisSettings.get().isUseServerLaunchedGuis()){ + sender().sendMessage(C.RED + "To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); + return; + } + sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); + NoiseExplorerGUI.launch(); + } + + } From cf67d5823604e8b0650c1679b3df1936a808ac1f Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 11:20:32 +0200 Subject: [PATCH 13/45] Noise explorer --- .../iris/core/decrees/DecIrisStudio.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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 daa4a4733..d76612c1d 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -21,23 +21,28 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; +import com.volmit.iris.core.project.loader.IrisData; import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; +import com.volmit.iris.engine.object.noise.IrisGenerator; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; +import com.volmit.iris.util.function.Function2; import com.volmit.iris.util.io.IO; import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.json.JSONObject; +import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.plugin.VolmitSender; import java.awt.*; import java.io.File; import java.io.IOException; +import java.util.function.Supplier; @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) public class DecIrisStudio implements DecreeExecutor @@ -144,5 +149,27 @@ public class DecIrisStudio implements DecreeExecutor NoiseExplorerGUI.launch(); } - + + @Decree(description = "Preview created noise generators", aliases = {"generator", "gen"}) + public void explore( + @Param(name = "generator", description = "The generator to explore", aliases = {"gen", "g"}) + IrisGenerator generator, + @Param(name = "seed", description = "The seed to generate with", aliases = "s", defaultValue = "12345") + long seed) + { + if (!IrisSettings.get().isUseServerLaunchedGuis()){ + sender().sendMessage(C.RED + "To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); + return; + } + sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); + + Supplier> l = () -> { + + if (generator == null) { + return (x, z) -> 0D; + } + + return (x, z) -> generator.getHeight(x, z, new RNG(seed).nextParallelRNG(3245).lmax()); + }; + } } From 10b2593389448f05849702f5d15061eb64312892 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 11:29:24 +0200 Subject: [PATCH 14/45] Find + addition to DecreeExecutor Adds world() to the decree executor --- .../iris/core/decrees/DecIrisStudio.java | 42 +++++++++++++++++++ .../iris/util/decree/DecreeExecutor.java | 9 ++++ 2 files changed, 51 insertions(+) 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 d76612c1d..772ba17c9 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -23,9 +23,14 @@ import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.project.loader.IrisData; import com.volmit.iris.core.tools.IrisToolbelt; +import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.object.basic.IrisPosition; +import com.volmit.iris.engine.object.biome.IrisBiome; import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; +import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure; import com.volmit.iris.engine.object.noise.IrisGenerator; +import com.volmit.iris.engine.object.regional.IrisRegion; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.annotations.Decree; @@ -38,6 +43,7 @@ import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.plugin.VolmitSender; +import com.volmit.iris.util.scheduling.J; import java.awt.*; import java.io.File; @@ -172,4 +178,40 @@ public class DecIrisStudio implements DecreeExecutor return (x, z) -> generator.getHeight(x, z, new RNG(seed).nextParallelRNG(3245).lmax()); }; } + + @Decree(description = "Find any biome", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) + public void find( + @Param(name = "biome", description = "The biome to find", aliases = "b") + IrisBiome biome + ) + { + J.a(() -> { + IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> sender().sendMessage("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + + if (l == null) { + sender().sendMessage("Couldn't find " + biome.getName() + "."); + } else { + sender().sendMessage("Found " + biome.getName() + "!"); + J.s(() -> sender().player().teleport(l.toLocation(world()))); + } + }); + } + + @Decree(description = "Find any region", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) + public void find( + @Param(name = "region", description = "The region to find", aliases = "r") + IrisRegion region + ) + { + J.a(() -> { + IrisPosition l = engine().lookForRegion(region, 10000, (v) -> sender().sendMessage("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + + if (l == null) { + sender().sendMessage("Couldn't find " + region.getName() + "."); + } else { + sender().sendMessage("Found " + region.getName() + "!"); + J.s(() -> sender().player().teleport(l.toLocation(world()))); + } + }); + } } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java index 464c0f7cc..780a8668a 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java @@ -21,6 +21,7 @@ package com.volmit.iris.util.decree; import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.util.plugin.VolmitSender; +import org.bukkit.World; public interface DecreeExecutor { default VolmitSender sender() @@ -38,6 +39,14 @@ public interface DecreeExecutor { return null; } + default World world() + { + if (sender().isPlayer()){ + return sender().player().getWorld(); + } + return null; + } + default T get(T v, T ifUndefined) { return v == null ? ifUndefined : v; From 3af8f4772fd593803716c817fedac6f000ea6d4c Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 11:42:19 +0200 Subject: [PATCH 15/45] Simplify command usage + hotload --- .../iris/core/decrees/DecIrisStudio.java | 70 ++++++++++++------- .../iris/util/decree/DecreeExecutor.java | 39 +++++++++++ 2 files changed, 83 insertions(+), 26 deletions(-) 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 772ba17c9..529da40c0 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -60,7 +60,7 @@ public class DecIrisStudio implements DecreeExecutor @Param(name = "seed", defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") long seed) { - sender().sendMessage(C.GREEN + "Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")"); + success("Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")"); Iris.proj.open(sender(), seed, dimension.getLoadKey()); } @@ -68,12 +68,12 @@ public class DecIrisStudio implements DecreeExecutor public void close() { if (!Iris.proj.isProjectOpen()) { - sender().sendMessage(C.RED + "No open studio projects."); + error("No open studio projects."); return; } Iris.proj.close(); - sender().sendMessage(C.GREEN + "Project Closed."); + success("Project Closed."); } @Decree(description = "Get the version of a pack", aliases = {"v", "ver"}) @@ -82,7 +82,7 @@ public class DecIrisStudio implements DecreeExecutor IrisDimension dimension ) { - sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); + success("The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); } @Decree(description = "Beatify a pack", aliases = {"beauty", "prettify"}) @@ -92,14 +92,14 @@ public class DecIrisStudio implements DecreeExecutor ) { File folder = dimension.getLoadFile(); - sender().sendMessage("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); + success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @Decree(description = "Beatify a pack - must be in studio!", aliases = {"beauty", "prettify"}) public void beautify() { File folder = Iris.proj.getActiveProject().getPath(); - sender().sendMessage("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); + success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv") @@ -113,25 +113,25 @@ public class DecIrisStudio implements DecreeExecutor public void editbiome() { if (!Iris.proj.isProjectOpen()){ - sender().sendMessage(C.RED + "The is no studio currently open!"); + error("The is no studio currently open!"); return; } - if (!Iris.proj.getActiveProject().getActiveProvider().getEngine().getWorld().realWorld().equals(sender().player().getWorld())){ - sender().sendMessage(C.RED + "You must be in a studio world to edit a biome!"); + if (!Iris.proj.getActiveProject().getActiveProvider().getEngine().getWorld().realWorld().equals(player().getWorld())){ + error("You must be in a studio world to edit a biome!"); return; } try { File f = Iris.proj.getActiveProject().getActiveProvider().getEngine().getBiome( - sender().player().getLocation().getBlockX(), - sender().player().getLocation().getBlockY(), - sender().player().getLocation().getBlockZ()).getLoadFile(); + player().getLocation().getBlockX(), + player().getLocation().getBlockY(), + player().getLocation().getBlockZ()).getLoadFile(); Desktop.getDesktop().open(f); } catch (Throwable e) { Iris.reportError(e); - sender().sendMessage("Cant find the file. Unsure why this happened."); + error("Cant find the file. Unsure why this happened."); } } @@ -141,17 +141,17 @@ public class DecIrisStudio implements DecreeExecutor IrisScript script ) { - IrisToolbelt.access(sender().player().getWorld()).getEngine().getExecution().execute(script); + engine().getExecution().execute(script); } @Decree(description = "Open the noise explorer (must have a local server!)", aliases = "nmap") public void noise() { if (!IrisSettings.get().isUseServerLaunchedGuis()){ - sender().sendMessage(C.RED + "To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); + error("To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); return; } - sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); + success("Opening Noise Explorer!"); NoiseExplorerGUI.launch(); } @@ -164,10 +164,10 @@ public class DecIrisStudio implements DecreeExecutor long seed) { if (!IrisSettings.get().isUseServerLaunchedGuis()){ - sender().sendMessage(C.RED + "To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); + error("To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); return; } - sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); + success("Opening Noise Explorer!"); Supplier> l = () -> { @@ -186,13 +186,13 @@ public class DecIrisStudio implements DecreeExecutor ) { J.a(() -> { - IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> sender().sendMessage("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); if (l == null) { - sender().sendMessage("Couldn't find " + biome.getName() + "."); + error("Couldn't find " + biome.getName() + "."); } else { - sender().sendMessage("Found " + biome.getName() + "!"); - J.s(() -> sender().player().teleport(l.toLocation(world()))); + success("Found " + biome.getName() + "!"); + J.s(() -> player().teleport(l.toLocation(world()))); } }); } @@ -204,14 +204,32 @@ public class DecIrisStudio implements DecreeExecutor ) { J.a(() -> { - IrisPosition l = engine().lookForRegion(region, 10000, (v) -> sender().sendMessage("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + IrisPosition l = engine().lookForRegion(region, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); if (l == null) { - sender().sendMessage("Couldn't find " + region.getName() + "."); + error("Couldn't find " + region.getName() + "."); } else { - sender().sendMessage("Found " + region.getName() + "!"); - J.s(() -> sender().player().teleport(l.toLocation(world()))); + success("Found " + region.getName() + "!"); + J.s(() -> player().teleport(l.toLocation(world()))); } }); } + + @Decree(description = "Hotload a studio", aliases = {"hot", "h", "reload"}, origin = DecreeOrigin.PLAYER) + public void hotload() + { + if (!engine().isStudio()){ + error("You must be in an Iris Studio"); + return; + } + + if (access() == null){ + error("Could not gain access to the generator of your studio"); + return; + } + + access().hotload(); + } + + } diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java index 780a8668a..e7b0aae2b 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java @@ -20,8 +20,11 @@ package com.volmit.iris.util.decree; import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.platform.PlatformChunkGenerator; +import com.volmit.iris.util.format.C; import com.volmit.iris.util.plugin.VolmitSender; import org.bukkit.World; +import org.bukkit.entity.Player; public interface DecreeExecutor { default VolmitSender sender() @@ -29,6 +32,34 @@ public interface DecreeExecutor { return DecreeContext.get(); } + default Player player() + { + if (sender().isPlayer()) { + return sender().player(); + } + return null; + } + + default void message(String string) + { + sender().sendMessage(string); + } + + default void success(String string) + { + message(C.GREEN + string); + } + + default void error(String string) + { + message(C.RED + string); + } + + default void warn(String string) + { + message(C.YELLOW + string); + } + default Engine engine() { if(sender().isPlayer()) @@ -39,6 +70,14 @@ public interface DecreeExecutor { return null; } + default PlatformChunkGenerator access() + { + if(sender().isPlayer()) { + return IrisToolbelt.access(world()); + } + return null; + } + default World world() { if (sender().isPlayer()){ From 5c0c680f56f8b6d9505a8669ad329b4846d53528 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 11:53:24 +0200 Subject: [PATCH 16/45] simplify studio checks + ir s loot --- .../iris/core/decrees/DecIrisStudio.java | 116 +++++++++--------- 1 file changed, 59 insertions(+), 57 deletions(-) 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 529da40c0..b4b9fa86a 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -21,16 +21,14 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; -import com.volmit.iris.core.project.loader.IrisData; -import com.volmit.iris.core.tools.IrisToolbelt; -import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.object.basic.IrisPosition; import com.volmit.iris.engine.object.biome.IrisBiome; import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; -import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure; +import com.volmit.iris.engine.object.loot.IrisLootTable; import com.volmit.iris.engine.object.noise.IrisGenerator; import com.volmit.iris.engine.object.regional.IrisRegion; +import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.annotations.Decree; @@ -38,35 +36,30 @@ import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; import com.volmit.iris.util.function.Function2; -import com.volmit.iris.util.io.IO; import com.volmit.iris.util.json.JSONCleaner; -import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.math.RNG; -import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.scheduling.J; +import org.bukkit.Bukkit; +import org.bukkit.inventory.Inventory; import java.awt.*; import java.io.File; -import java.io.IOException; 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 { @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") IrisDimension dimension, @Param(name = "seed", defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") - long seed) - { + long seed) { success("Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")"); Iris.proj.open(sender(), seed, dimension.getLoadKey()); } @Decree(description = "Close an open studio project", aliases = "x", sync = true) - public void close() - { + public void close() { if (!Iris.proj.isProjectOpen()) { error("No open studio projects."); return; @@ -80,8 +73,7 @@ public class DecIrisStudio implements DecreeExecutor public void version( @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim") IrisDimension dimension - ) - { + ) { success("The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); } @@ -89,42 +81,35 @@ public class DecIrisStudio implements DecreeExecutor public void beautify( @Param(name = "dimension", defaultValue = "overworld", description = "The to-beautify dimension", aliases = "dim") IrisDimension dimension - ) - { + ) { File folder = dimension.getLoadFile(); success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @Decree(description = "Beatify a pack - must be in studio!", aliases = {"beauty", "prettify"}) - public void beautify() - { + public void beautify() { + if (noStudio()){ + return; + } File folder = Iris.proj.getActiveProject().getPath(); success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv") - public void convert() - { + public void convert() { Iris.convert.check(sender()); } @Decree(description = "Edit the biome you're currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER) - public void editbiome() - { - if (!Iris.proj.isProjectOpen()){ - error("The is no studio currently open!"); + public void editbiome() { + + if (noStudio()){ return; } - if (!Iris.proj.getActiveProject().getActiveProvider().getEngine().getWorld().realWorld().equals(player().getWorld())){ - error("You must be in a studio world to edit a biome!"); - return; - } - - try { - File f = Iris.proj.getActiveProject().getActiveProvider().getEngine().getBiome( + File f = engine().getBiome( player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ()).getLoadFile(); @@ -138,16 +123,14 @@ public class DecIrisStudio implements DecreeExecutor @Decree(description = "Execute a script", aliases = {"ex", "exec", "run"}, origin = DecreeOrigin.PLAYER) public void execute( @Param(name = "script", description = "The script to run", aliases = {"s", "scr"}) - IrisScript script - ) - { + IrisScript script + ) { engine().getExecution().execute(script); } @Decree(description = "Open the noise explorer (must have a local server!)", aliases = "nmap") - public void noise() - { - if (!IrisSettings.get().isUseServerLaunchedGuis()){ + public void noise() { + if (!IrisSettings.get().isUseServerLaunchedGuis()) { error("To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); return; } @@ -161,9 +144,8 @@ public class DecIrisStudio implements DecreeExecutor @Param(name = "generator", description = "The generator to explore", aliases = {"gen", "g"}) IrisGenerator generator, @Param(name = "seed", description = "The seed to generate with", aliases = "s", defaultValue = "12345") - long seed) - { - if (!IrisSettings.get().isUseServerLaunchedGuis()){ + long seed) { + if (!IrisSettings.get().isUseServerLaunchedGuis()) { error("To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); return; } @@ -182,9 +164,8 @@ public class DecIrisStudio implements DecreeExecutor @Decree(description = "Find any biome", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) public void find( @Param(name = "biome", description = "The biome to find", aliases = "b") - IrisBiome biome - ) - { + IrisBiome biome + ) { J.a(() -> { IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); @@ -201,8 +182,7 @@ public class DecIrisStudio implements DecreeExecutor public void find( @Param(name = "region", description = "The region to find", aliases = "r") IrisRegion region - ) - { + ) { J.a(() -> { IrisPosition l = engine().lookForRegion(region, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); @@ -216,20 +196,42 @@ public class DecIrisStudio implements DecreeExecutor } @Decree(description = "Hotload a studio", aliases = {"hot", "h", "reload"}, origin = DecreeOrigin.PLAYER) - public void hotload() - { - if (!engine().isStudio()){ - error("You must be in an Iris Studio"); - return; - } - - if (access() == null){ - error("Could not gain access to the generator of your studio"); + public void hotload() { + if (noStudio()){ return; } access().hotload(); } - + @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER) + public void loot() + { + if (noStudio()){ + return; + } + + KList tables = engine().getLootTables(RNG.r, player().getLocation().getBlock()); + Inventory inv = Bukkit.createInventory(null, 27 * 2); + + } + + /** + * @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; + } } From 3b6d3116bd80f66e7e3f934dd12ebf5b27a6b23f Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 12:01:03 +0200 Subject: [PATCH 17/45] Small patch (Forgot to launch) + simplify + compact + docs + ir s map --- .../iris/core/decrees/DecIrisStudio.java | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) 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 b4b9fa86a..f742413b3 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -21,6 +21,7 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; +import com.volmit.iris.core.gui.VisionGUI; import com.volmit.iris.engine.object.basic.IrisPosition; import com.volmit.iris.engine.object.biome.IrisBiome; import com.volmit.iris.engine.object.common.IrisScript; @@ -88,9 +89,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Beatify a pack - must be in studio!", aliases = {"beauty", "prettify"}) public void beautify() { - if (noStudio()){ - return; - } + if (noStudio()) return; File folder = Iris.proj.getActiveProject().getPath(); success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @@ -104,9 +103,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Edit the biome you're currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER) public void editbiome() { - if (noStudio()){ - return; - } + if (noStudio()) return; try { File f = engine().getBiome( @@ -128,27 +125,21 @@ public class DecIrisStudio implements DecreeExecutor { engine().getExecution().execute(script); } - @Decree(description = "Open the noise explorer (must have a local server!)", aliases = "nmap") + @Decree(description = "Open the noise explorer (External GUI)", aliases = "nmap") public void noise() { - if (!IrisSettings.get().isUseServerLaunchedGuis()) { - error("To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); - return; - } + if (noGUI()) return; success("Opening Noise Explorer!"); NoiseExplorerGUI.launch(); } - @Decree(description = "Preview created noise generators", aliases = {"generator", "gen"}) + @Decree(description = "Preview noise gens (External GUI)", aliases = {"generator", "gen"}) public void explore( @Param(name = "generator", description = "The generator to explore", aliases = {"gen", "g"}) IrisGenerator generator, @Param(name = "seed", description = "The seed to generate with", aliases = "s", defaultValue = "12345") long seed) { - if (!IrisSettings.get().isUseServerLaunchedGuis()) { - error("To use Iris noise GUIs, please enable serverLaunchedGUIs in the settings"); - return; - } + if (noGUI()) return; success("Opening Noise Explorer!"); Supplier> l = () -> { @@ -159,6 +150,7 @@ public class DecIrisStudio implements DecreeExecutor { return (x, z) -> generator.getHeight(x, z, new RNG(seed).nextParallelRNG(3245).lmax()); }; + NoiseExplorerGUI.launch(l, "Custom Generator"); } @Decree(description = "Find any biome", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) @@ -197,9 +189,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Hotload a studio", aliases = {"hot", "h", "reload"}, origin = DecreeOrigin.PLAYER) public void hotload() { - if (noStudio()){ - return; - } + if (noStudio()) return; access().hotload(); } @@ -207,13 +197,34 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER) public void loot() { - if (noStudio()){ - return; - } + if (noStudio()) return; KList tables = engine().getLootTables(RNG.r, player().getLocation().getBlock()); Inventory inv = Bukkit.createInventory(null, 27 * 2); + } + @Decree(description = "Render a world map (External GUI)", aliases = "render") + public void map() + { + if (noStudio()) return; + + if (noGUI()) return; + + VisionGUI.launch(engine(), 0); + success("Opening map!"); + } + + + + /** + * @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; } /** From a471bfec6aaa67ed617f730d73b235bf3371a7eb Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 12:14:36 +0200 Subject: [PATCH 18/45] BooleanHandler --- .../util/decree/handlers/BooleanHandler.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java new file mode 100644 index 000000000..184d1d1f3 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java @@ -0,0 +1,72 @@ +package com.volmit.iris.util.decree.handlers; + +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.decree.DecreeParameterHandler; +import com.volmit.iris.util.decree.exceptions.DecreeParsingException; +import com.volmit.iris.util.decree.exceptions.DecreeWhichException; + +public class BooleanHandler implements DecreeParameterHandler { + private static final KList trues = new KList<>( + "true", + "yes", + "t", + "1" + ); + private static final KList falses = new KList<>( + "false", + "no", + "f", + "0" + ); + + /** + * Should return the possible values for this type + * + * @return Possibilities for this type. + */ + @Override + public KList getPossibilities() { + return null; + } + + /** + * Converting the type back to a string (inverse of the {@link #parse(String) parse} method) + * + * @param aBoolean The input of the designated type to convert to a String + * @return The resulting string + */ + @Override + public String toString(Boolean aBoolean) { + return aBoolean.toString(); + } + + /** + * Should parse a String into the designated type + * + * @param in The string to parse + * @return The value extracted from the string, of the designated type + * @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this) + * @throws DecreeWhichException Thrown when multiple results are possible + */ + @Override + public Boolean parse(String in) throws DecreeParsingException, DecreeWhichException { + if (trues.contains(in)){ + return true; + } + if (falses.contains(in)){ + return false; + } + throw new DecreeParsingException("Cannot convert \"" + in + "\" to a boolean (" + trues.toString(", ") + " / " + falses.toString(", ") + ")"); + } + + /** + * Returns whether a certain type is supported by this handler
+ * + * @param type The type to check + * @return True if supported, false if not + */ + @Override + public boolean supports(Class type) { + return type.equals(boolean.class) || type.equals(Boolean.class); + } +} From 12b1016d6638601f642869b04db63c7a0a703a33 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 12:14:47 +0200 Subject: [PATCH 19/45] Package + function --- .../java/com/volmit/iris/core/ProjectManager.java | 4 ++++ .../volmit/iris/core/decrees/DecIrisStudio.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/core/ProjectManager.java b/src/main/java/com/volmit/iris/core/ProjectManager.java index 9e7a9130a..46ac24e22 100644 --- a/src/main/java/com/volmit/iris/core/ProjectManager.java +++ b/src/main/java/com/volmit/iris/core/ProjectManager.java @@ -363,6 +363,10 @@ public class ProjectManager { } } + public File compilePackage(VolmitSender sender, IrisDimension d, boolean obfuscate, boolean minify) { + return new IrisProject(new File(getWorkspaceFolder(), d.getName())).compilePackage(sender, obfuscate, minify); + } + public File compilePackage(VolmitSender sender, String d, boolean obfuscate, boolean minify) { return new IrisProject(new File(getWorkspaceFolder(), d)).compilePackage(sender, obfuscate, minify); } 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 f742413b3..2dfc8d308 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -214,7 +214,19 @@ public class DecIrisStudio implements DecreeExecutor { success("Opening map!"); } - + @Decree(description = "Package a dimension into a compressed format", aliases = "package") + public void pkg( + @Param(name = "dimension", aliases = {"d", "dim"}, description = "The dimension pack to compress") + IrisDimension dimension, + @Param(name = "obfuscate", aliases = "o", description = "Whether or not to obfuscate the pack", defaultValue = "false") + boolean obfuscate, + @Param(name = "minify", aliases = "m", description = "Whether or not to minify the pack", defaultValue = "true") + boolean minify + ){ + J.a(() -> { + Iris.proj.compilePackage(sender(), dimension, obfuscate, minify); + }); + } /** * @return true if server GUIs are not enabled From e328bf616f96138d1c281e52c125eadcb55483ab Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 15:34:34 +0200 Subject: [PATCH 20/45] 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; + } +} From 5b5622b4a76523b6a7a794654b1a7cfd2f967ea3 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 15:35:42 +0200 Subject: [PATCH 21/45] Polish --- .../com/volmit/iris/core/decrees/DecreeStudioExtension.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java b/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java index 09c9e691c..cb03f78cd 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java @@ -18,11 +18,11 @@ public interface DecreeStudioExtension extends DecreeExecutor { } /** - * @return true if no studio is open & the player + * @return true if no studio is open or the player is not in one */ default boolean noStudio(){ if (!sender().isPlayer()){ - error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER)"); + error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)"); return true; } if (!Iris.proj.isProjectOpen()){ From 263e6d5cca4e77011a6947150b6a8a607b4ec12c Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 15:48:33 +0200 Subject: [PATCH 22/45] lowercase matching --- .../volmit/iris/util/decree/handlers/BooleanHandler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java index 184d1d1f3..2f0bdc62f 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/BooleanHandler.java @@ -5,6 +5,8 @@ import com.volmit.iris.util.decree.DecreeParameterHandler; import com.volmit.iris.util.decree.exceptions.DecreeParsingException; import com.volmit.iris.util.decree.exceptions.DecreeWhichException; +import java.util.Locale; + public class BooleanHandler implements DecreeParameterHandler { private static final KList trues = new KList<>( "true", @@ -50,10 +52,10 @@ public class BooleanHandler implements DecreeParameterHandler { */ @Override public Boolean parse(String in) throws DecreeParsingException, DecreeWhichException { - if (trues.contains(in)){ + if (trues.contains(in.toLowerCase())){ return true; } - if (falses.contains(in)){ + if (falses.contains(in.toLowerCase())){ return false; } throw new DecreeParsingException("Cannot convert \"" + in + "\" to a boolean (" + trues.toString(", ") + " / " + falses.toString(", ") + ")"); From b42b6303ae51a77c2674ddbf2c20156856a5e32f Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 15:51:09 +0200 Subject: [PATCH 23/45] I skipped loot. Oops --- .../iris/core/decrees/DecIrisStudio.java | 92 +++++++++++++------ 1 file changed, 66 insertions(+), 26 deletions(-) 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 c6618bd0d..ae6aece58 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -27,6 +27,7 @@ import com.volmit.iris.engine.object.biome.IrisBiome; import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; import com.volmit.iris.engine.object.loot.IrisLootTable; +import com.volmit.iris.engine.object.meta.InventorySlotType; import com.volmit.iris.engine.object.noise.IrisGenerator; import com.volmit.iris.engine.object.regional.IrisRegion; import com.volmit.iris.util.collection.KList; @@ -40,7 +41,9 @@ import com.volmit.iris.util.function.Function2; import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.scheduling.J; +import com.volmit.iris.util.scheduling.O; import org.bukkit.Bukkit; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import java.awt.*; @@ -138,7 +141,8 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { @Param(name = "generator", description = "The generator to explore", aliases = {"gen", "g"}) IrisGenerator generator, @Param(name = "seed", description = "The seed to generate with", aliases = "s", defaultValue = "12345") - long seed) { + long seed + ){ if (noGUI()) return; success("Opening Noise Explorer!"); @@ -157,34 +161,30 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { public void find( @Param(name = "biome", description = "The biome to find", aliases = "b") IrisBiome biome - ) { - J.a(() -> { - IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + ){ + IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); - if (l == null) { - error("Couldn't find " + biome.getName() + "."); - } else { - success("Found " + biome.getName() + "!"); - J.s(() -> player().teleport(l.toLocation(world()))); - } - }); + if (l == null) { + error("Couldn't find " + biome.getName() + "."); + } else { + success("Found " + biome.getName() + "!"); + J.s(() -> player().teleport(l.toLocation(world()))); + } } @Decree(description = "Find any region", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) public void find( @Param(name = "region", description = "The region to find", aliases = "r") IrisRegion region - ) { - J.a(() -> { - IrisPosition l = engine().lookForRegion(region, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + ){ + IrisPosition l = engine().lookForRegion(region, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); - if (l == null) { - error("Couldn't find " + region.getName() + "."); - } else { - success("Found " + region.getName() + "!"); - J.s(() -> player().teleport(l.toLocation(world()))); - } - }); + if (l == null) { + error("Couldn't find " + region.getName() + "."); + } else { + success("Found " + region.getName() + "!"); + J.s(() -> player().teleport(l.toLocation(world()))); + } } @Decree(description = "Hotload a studio", aliases = {"hot", "h", "reload"}, origin = DecreeOrigin.PLAYER) @@ -195,12 +195,46 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { } @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER) - public void loot() - { + public void loot( + @Param(name = "fast", aliases = "f", description = "Fast insertion of items in virtual inventory (may cause performance drop)", defaultValue = "false") + boolean fast, + @Param(name = "add", aliases = "a", description = "Whether or not to append to the inventory currently open (if false, clears opened inventory)", defaultValue = "true") + boolean add + ) { if (noStudio()) return; KList tables = engine().getLootTables(RNG.r, player().getLocation().getBlock()); Inventory inv = Bukkit.createInventory(null, 27 * 2); + + try { + engine().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1); + } catch (Throwable e){ + Iris.reportError(e); + error("Cannot add items to virtual inventory because of: " + e.getMessage()); + return; + } + + + O ta = new O<>(); + ta.set(-1); + + ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> + { + if (!player().getOpenInventory().getType().equals(InventoryType.CHEST)) { + Bukkit.getScheduler().cancelTask(ta.get()); + success("Opened inventory!"); + return; + } + + if (!add) { + inv.clear(); + } + + engine().addItems(true, inv, new RNG(RNG.r.imax()), tables, InventorySlotType.STORAGE, player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1); + }, 0, fast ? 5 : 35)); + + success("Opening inventory now!"); + player().openInventory(inv); } @Decree(description = "Render a world map (External GUI)", aliases = "render") @@ -223,8 +257,14 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { @Param(name = "minify", aliases = "m", description = "Whether or not to minify the pack", defaultValue = "true") boolean minify ){ - J.a(() -> { - Iris.proj.compilePackage(sender(), dimension, obfuscate, minify); - }); + Iris.proj.compilePackage(sender(), dimension, obfuscate, minify); + } + + @Decree(description = "Profiles a dimension's performance") + public void profile( + @Param(name = "dimension", aliases = {"d", "dim"}, description = "The dimension to profile") + IrisDimension dimension + ){ + } } From 8dff3b55c9beaf57bf4081310d2d01681d3278b0 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 16:00:20 +0200 Subject: [PATCH 24/45] fix pack file getting from dimension & add profiler --- .../iris/core/decrees/DecIrisStudio.java | 198 +++++++++++++++++- 1 file changed, 195 insertions(+), 3 deletions(-) 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 ae6aece58..aeeca916c 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -19,18 +19,24 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; -import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.gui.VisionGUI; +import com.volmit.iris.core.project.IrisProject; +import com.volmit.iris.core.project.loader.IrisData; import com.volmit.iris.engine.object.basic.IrisPosition; import com.volmit.iris.engine.object.biome.IrisBiome; +import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer; import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; import com.volmit.iris.engine.object.loot.IrisLootTable; import com.volmit.iris.engine.object.meta.InventorySlotType; import com.volmit.iris.engine.object.noise.IrisGenerator; +import com.volmit.iris.engine.object.noise.IrisInterpolator; +import com.volmit.iris.engine.object.noise.IrisNoiseGenerator; +import com.volmit.iris.engine.object.noise.NoiseStyle; import com.volmit.iris.engine.object.regional.IrisRegion; import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.annotations.Decree; @@ -38,16 +44,22 @@ import com.volmit.iris.util.decree.annotations.Param; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; import com.volmit.iris.util.function.Function2; +import com.volmit.iris.util.function.NoiseProvider; +import com.volmit.iris.util.interpolation.InterpolationMethod; +import com.volmit.iris.util.io.IO; import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.math.RNG; +import com.volmit.iris.util.noise.CNG; import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.O; +import com.volmit.iris.util.scheduling.PrecisionStopwatch; import org.bukkit.Bukkit; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import java.awt.*; import java.io.File; +import java.io.IOException; import java.util.function.Supplier; @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) @@ -86,7 +98,7 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { @Param(name = "dimension", defaultValue = "overworld", description = "The to-beautify dimension", aliases = "dim") IrisDimension dimension ) { - File folder = dimension.getLoadFile(); + File folder = dimension.getLoadFile().getParentFile().getParentFile(); success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @@ -260,11 +272,191 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { Iris.proj.compilePackage(sender(), dimension, obfuscate, minify); } - @Decree(description = "Profiles a dimension's performance") + @Decree(description = "Profiles a dimension's performance", origin = DecreeOrigin.PLAYER) public void profile( @Param(name = "dimension", aliases = {"d", "dim"}, description = "The dimension to profile") IrisDimension dimension ){ + File pack = dimension.getLoadFile().getParentFile().getParentFile(); + File report = Iris.instance.getDataFile("profile.txt"); + IrisProject project = new IrisProject(pack); + IrisData data = new IrisData(pack); + KList fileText = new KList<>(); + + KMap styleTimings = new KMap<>(); + KMap interpolatorTimings = new KMap<>(); + KMap generatorTimings = new KMap<>(); + KMap biomeTimings = new KMap<>(); + KMap regionTimings = new KMap<>(); + + message("Calculating Performance Metrics for Noise generators"); + + for (NoiseStyle i : NoiseStyle.values()) { + CNG c = i.create(new RNG(i.hashCode())); + + for (int j = 0; j < 3000; j++) { + c.noise(j, j + 1000, j * j); + c.noise(j, -j); + } + + PrecisionStopwatch px = PrecisionStopwatch.start(); + + for (int j = 0; j < 100000; j++) { + c.noise(j, j + 1000, j * j); + c.noise(j, -j); + } + + styleTimings.put(i, px.getMilliseconds()); + } + + fileText.add("Noise Style Performance Impacts: "); + + for (NoiseStyle i : styleTimings.sortKNumber()) { + fileText.add(i.name() + ": " + styleTimings.get(i)); + } + + fileText.add(""); + + message("Calculating Interpolator Timings..."); + + for (InterpolationMethod i : InterpolationMethod.values()) { + IrisInterpolator in = new IrisInterpolator(); + in.setFunction(i); + in.setHorizontalScale(8); + + NoiseProvider np = (x, z) -> Math.random(); + + for (int j = 0; j < 3000; j++) { + in.interpolate(j, -j, np); + } + + PrecisionStopwatch px = PrecisionStopwatch.start(); + + for (int j = 0; j < 100000; j++) { + in.interpolate(j + 10000, -j - 100000, np); + } + + interpolatorTimings.put(i, px.getMilliseconds()); + } + + fileText.add("Noise Interpolator Performance Impacts: "); + + for (InterpolationMethod i : interpolatorTimings.sortKNumber()) { + fileText.add(i.name() + ": " + interpolatorTimings.get(i)); + } + + fileText.add(""); + + message("Processing Generator Scores: "); + + KMap> btx = new KMap<>(); + + for (String i : data.getGeneratorLoader().getPossibleKeys()) { + KList vv = new KList<>(); + IrisGenerator g = data.getGeneratorLoader().load(i); + KList composites = g.getAllComposites(); + double score = 0; + int m = 0; + for (IrisNoiseGenerator j : composites) { + m++; + score += styleTimings.get(j.getStyle().getStyle()); + vv.add("Composite Noise Style " + m + " " + j.getStyle().getStyle().name() + ": " + styleTimings.get(j.getStyle().getStyle())); + } + + score += interpolatorTimings.get(g.getInterpolator().getFunction()); + vv.add("Interpolator " + g.getInterpolator().getFunction().name() + ": " + interpolatorTimings.get(g.getInterpolator().getFunction())); + generatorTimings.put(i, score); + btx.put(i, vv); + } + + fileText.add("Project Generator Performance Impacts: "); + + for (String i : generatorTimings.sortKNumber()) { + fileText.add(i + ": " + generatorTimings.get(i)); + + btx.get(i).forEach((ii) -> fileText.add(" " + ii)); + } + + fileText.add(""); + + KMap> bt = new KMap<>(); + + for (String i : data.getBiomeLoader().getPossibleKeys()) { + KList vv = new KList<>(); + IrisBiome b = data.getBiomeLoader().load(i); + double score = 0; + + int m = 0; + for (IrisBiomePaletteLayer j : b.getLayers()) { + m++; + score += styleTimings.get(j.getStyle().getStyle()); + vv.add("Palette Layer " + m + ": " + styleTimings.get(j.getStyle().getStyle())); + } + + score += styleTimings.get(b.getBiomeStyle().getStyle()); + vv.add("Biome Style: " + styleTimings.get(b.getBiomeStyle().getStyle())); + score += styleTimings.get(b.getChildStyle().getStyle()); + vv.add("Child Style: " + styleTimings.get(b.getChildStyle().getStyle())); + biomeTimings.put(i, score); + bt.put(i, vv); + } + + fileText.add("Project Biome Performance Impacts: "); + + for (String i : biomeTimings.sortKNumber()) { + fileText.add(i + ": " + biomeTimings.get(i)); + + bt.get(i).forEach((ff) -> fileText.add(" " + ff)); + } + + fileText.add(""); + + for (String i : data.getRegionLoader().getPossibleKeys()) { + IrisRegion b = data.getRegionLoader().load(i); + double score = 0; + + score += styleTimings.get(b.getLakeStyle().getStyle()); + score += styleTimings.get(b.getRiverStyle().getStyle()); + regionTimings.put(i, score); + } + + fileText.add("Project Region Performance Impacts: "); + + for (String i : regionTimings.sortKNumber()) { + fileText.add(i + ": " + regionTimings.get(i)); + } + + fileText.add(""); + + double m = 0; + for (double i : biomeTimings.v()) { + m += i; + } + m /= biomeTimings.size(); + double mm = 0; + for (double i : generatorTimings.v()) { + mm += i; + } + mm /= generatorTimings.size(); + m += mm; + double mmm = 0; + for (double i : regionTimings.v()) { + mmm += i; + } + mmm /= regionTimings.size(); + m += mmm; + + fileText.add("Average Score: " + m); + message("Score: " + Form.duration(m, 0)); + + try { + IO.writeAll(report, fileText.toString("\n")); + } catch (IOException e) { + Iris.reportError(e); + e.printStackTrace(); + } + + success("Done! " + report.getPath()); } } From f2371d8735754968427076c361121156aa962572 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 16:07:23 +0200 Subject: [PATCH 25/45] Entity spawn --- .../volmit/iris/core/decrees/DecIrisStudio.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 aeeca916c..aa4037345 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -28,6 +28,7 @@ import com.volmit.iris.engine.object.biome.IrisBiome; import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer; import com.volmit.iris.engine.object.common.IrisScript; import com.volmit.iris.engine.object.dimensional.IrisDimension; +import com.volmit.iris.engine.object.entity.IrisEntity; import com.volmit.iris.engine.object.loot.IrisLootTable; import com.volmit.iris.engine.object.meta.InventorySlotType; import com.volmit.iris.engine.object.noise.IrisGenerator; @@ -459,4 +460,18 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { success("Done! " + report.getPath()); } + + @Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER) + public void summon( + @Param(description = "The Iris Entity to spawn", aliases = "e", name = "entity") + IrisEntity entity + ) { + if (noStudio()){ + return; + } + success("Spawning entity"); + entity.spawn(engine(), player().getLocation().clone().add(0, 2, 0)); + } + + } From 0352951d8cb3e36d2576bb8e18dcc0399e0484a3 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 16:25:45 +0200 Subject: [PATCH 26/45] ir s Update --- .../iris/core/decrees/DecIrisStudio.java | 77 ++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) 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 aa4037345..7d5ad4aad 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -19,6 +19,7 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.gui.VisionGUI; import com.volmit.iris.core.project.IrisProject; @@ -35,6 +36,7 @@ import com.volmit.iris.engine.object.noise.IrisGenerator; import com.volmit.iris.engine.object.noise.IrisInterpolator; import com.volmit.iris.engine.object.noise.IrisNoiseGenerator; import com.volmit.iris.engine.object.noise.NoiseStyle; +import com.volmit.iris.engine.object.objects.IrisObject; import com.volmit.iris.engine.object.regional.IrisRegion; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KMap; @@ -51,10 +53,14 @@ import com.volmit.iris.util.io.IO; import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.noise.CNG; +import com.volmit.iris.util.parallel.BurstExecutor; +import com.volmit.iris.util.parallel.MultiBurst; +import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.O; import com.volmit.iris.util.scheduling.PrecisionStopwatch; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; @@ -473,5 +479,74 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { entity.spawn(engine(), player().getLocation().clone().add(0, 2, 0)); } - + @Decree(description = "Teleport to the active studio world", aliases = {"tps", "stp", "tp"}, origin = DecreeOrigin.PLAYER) + public void tpstudio(){ + if (!Iris.proj.isProjectOpen()){ + error("No studio world is open!"); + return; + } + + if (engine().isStudio()){ + error("You are already in a studio world!"); + return; + } + + success("Sending you to the studio world!"); + player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().spawnLocation()); + player().setGameMode(GameMode.SPECTATOR); + } + + @Decree(description = "Update your dimension project", aliases = {"upd", "u"}) + public void update( + @Param(name = "dimension", aliases = {"d", "dim"}, description = "The dimension to update the workspace of") + IrisDimension dimension, + @Param(name = "objects", aliases = "o", description = "Whether or not to update your objects to the new object system") + boolean rewriteObject) + { + if (rewriteObject) { + IrisData data = dimension.getLoader(); + int t = data.getObjectLoader().getPossibleKeys().length; + ChronoLatch cl = new ChronoLatch(250, false); + MultiBurst bx = new MultiBurst("Object Rewriter", Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors()); + BurstExecutor b = bx.burst(); + int g = 0; + for (String f : data.getObjectLoader().getPossibleKeys()) { + int finalG1 = g; + b.queue(() -> { + + if (cl.flip()) { + Iris.info("Rewriting: " + Form.f(t - finalG1) + " Objects Left"); + } + File ff = data.getObjectLoader().findFile(f); + IrisObject oo = new IrisObject(0, 0, 0); + try { + oo.read(ff); + } catch (Throwable e) { + Iris.error("FAILER TO READ: " + f); + return; + } + + try { + oo.write(ff); + } catch (IOException e) { + Iris.error("FAILURE TO WRITE: " + oo.getLoadFile()); + } + }); + g++; + } + + int finalG = g; + message("Attempting object rewrite now..."); + b.complete(); + bx.shutdownNow(); + success("Done! Rewrote " + Form.f(finalG) + " Objects!"); + } + + + if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) { + success("Updated Code Workspace for " + dimension.getName()); + } else { + error("Invalid project: " + dimension.getName() + ". Try deleting the code-workspace file and try again."); + } + } } From 959ce3bc920bbe8c5055196f781817403aad61af Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 22:23:51 +0200 Subject: [PATCH 27/45] Idk what I did here but it's bad --- src/main/java/com/volmit/iris/Iris.java | 32 ++++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index fbe2762b2..5c3aebe7a 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -443,40 +443,38 @@ public class Iris extends VolmitPlugin implements Listener { @Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { - String dimension = IrisSettings.get().getGenerator().getDefaultWorldType(); - if (id != null && !id.isEmpty()) { - dimension = id; - Iris.info("Generator ID: " + id + " requested by bukkit/plugin. Assuming IrisDimension: " + id); + IrisDimension dim; + if (id == null || id.isEmpty()){ + dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType()); + } else { + dim = IrisData.loadAnyDimension(id); } + Iris.info("Generator ID: " + id + " requested by bukkit/plugin"); - IrisDimension d = IrisData.loadAnyDimension(dimension); - - if (d == null) { + if (dim == null) { Iris.warn("Unable to find dimension type " + id + " Looking for online packs..."); - d = IrisData.loadAnyDimension(dimension); - if (dimension == null) { - Iris.warn("Unable to find dimension type \"" + dimensionName + "\". Looking for online packs..."); - Iris.proj.downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), dimensionName, true); - dimension = IrisData.loadAnyDimension(dimensionName); - if (d == null) { - throw new RuntimeException("Can't find dimension " + dimension + "!"); + Iris.proj.downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true); + dim = IrisData.loadAnyDimension(id); + + if (dim == null) { + throw new RuntimeException("Can't find dimension " + id + "!"); } else { Iris.info("Resolved missing dimension, proceeding with generation."); } } + Iris.info("Assuming IrisDimension: " + dim.getName()); IrisWorld w = IrisWorld.builder() .name(worldName) .seed(RNG.r.lmax()) - .environment(d.getEnvironment()) + .environment(dim.getEnvironment()) .worldFolder(new File(worldName)) .minHeight(0) .maxHeight(256) .build(); - - return new BukkitChunkGenerator(w, false, new File(w.worldFolder(), "iris"), dimension); + return new BukkitChunkGenerator(w, false, new File(w.worldFolder(), "iris"), dim.getName()); } public static void msg(String string) { From 486e92dfc910e601154ef8ad9d5b34e283cca6d5 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 22:25:14 +0200 Subject: [PATCH 28/45] another I hate this --- src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java index 08bfcd096..1ff5c5bd9 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java @@ -21,10 +21,7 @@ package com.volmit.iris.util.decree; import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.platform.PlatformChunkGenerator; -<<<<<<< HEAD import com.volmit.iris.util.format.C; -======= ->>>>>>> master import com.volmit.iris.util.plugin.VolmitSender; import org.bukkit.World; import org.bukkit.entity.Player; From 5c541275c5f2a48724dd59602aa7fb1881fee808 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 22:28:31 +0200 Subject: [PATCH 29/45] override equals function for hashing lombok was complaining --- .../iris/util/decree/virtual/VirtualDecreeCommand.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java index b1ce36f89..ed7d4252a 100644 --- a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java +++ b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java @@ -617,6 +617,14 @@ public class VirtualDecreeCommand { return Objects.hash(getName(), getDescription(), getType(), getPath()); } + @Override + public boolean equals(Object obj){ + if (!(obj instanceof VirtualDecreeCommand)){ + return false; + } + return this.hashCode() == obj.hashCode(); + } + public boolean matches(String in) { KList a = getNames(); From 474b85127580e22d516b69bc3858d59dde51ab99 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 22:31:39 +0200 Subject: [PATCH 30/45] loadkey instead of name --- src/main/java/com/volmit/iris/Iris.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 5c3aebe7a..f806ae573 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -474,7 +474,7 @@ public class Iris extends VolmitPlugin implements Listener { .minHeight(0) .maxHeight(256) .build(); - return new BukkitChunkGenerator(w, false, new File(w.worldFolder(), "iris"), dim.getName()); + return new BukkitChunkGenerator(w, false, new File(w.worldFolder(), "iris"), dim.getLoadKey()); } public static void msg(String string) { From 20d26d4bcdbfb2f8141d659e6a36b964edae8f46 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sat, 14 Aug 2021 22:50:38 +0200 Subject: [PATCH 31/45] getLoadKey instead of getName --- src/main/java/com/volmit/iris/core/ProjectManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/core/ProjectManager.java b/src/main/java/com/volmit/iris/core/ProjectManager.java index 46ac24e22..66dc8fe2e 100644 --- a/src/main/java/com/volmit/iris/core/ProjectManager.java +++ b/src/main/java/com/volmit/iris/core/ProjectManager.java @@ -364,7 +364,7 @@ public class ProjectManager { } public File compilePackage(VolmitSender sender, IrisDimension d, boolean obfuscate, boolean minify) { - return new IrisProject(new File(getWorkspaceFolder(), d.getName())).compilePackage(sender, obfuscate, minify); + return new IrisProject(new File(getWorkspaceFolder(), d.getLoadKey())).compilePackage(sender, obfuscate, minify); } public File compilePackage(VolmitSender sender, String d, boolean obfuscate, boolean minify) { From c969f277ee61fe5b9a3f62aaa7c1d9540dcede5d Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 00:33:52 +0200 Subject: [PATCH 32/45] Add new handlers (Which don't work for no reason) I'm getting stuck help plz. All commands that require any IrisRegistrant, including the dimensions (of which I did not modify the handler), give an invocationtargetexception --- .../iris/util/decree/DecreeParameter.java | 1 - .../volmit/iris/util/decree/DecreeSystem.java | 6 +- .../util/decree/handlers/EntityHandler.java | 105 ++++++++++++++++++ .../decree/handlers/GeneratorHandler.java | 78 +++++++++++++ .../util/decree/handlers/ScriptHandler.java | 78 +++++++++++++ 5 files changed, 264 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java create mode 100644 src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java create mode 100644 src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java index 0ec241f1b..6fb356055 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java @@ -25,7 +25,6 @@ import com.volmit.iris.util.decree.exceptions.DecreeWhichException; import lombok.Data; import java.lang.reflect.Parameter; -import java.util.Arrays; @Data public class DecreeParameter { diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java b/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java index ea7cb4275..547b6cbd1 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeSystem.java @@ -61,7 +61,7 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { @Override default boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { J.aBukkit(() -> { - if(!call(new VolmitSender(sender, Iris.instance.getTag()), args)) + if(!call(new VolmitSender(sender), args)) { sender.sendMessage(C.RED + "Unknown Iris Command"); } @@ -174,8 +174,7 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { * @param type The type to handle * @return The corresponding {@link DecreeParameterHandler}, or null */ - static DecreeParameterHandler getHandler(Class type) - { + static DecreeParameterHandler getHandler(Class type) { for(DecreeParameterHandler i : handlers) { if(i.supports(type)) @@ -183,6 +182,7 @@ public interface DecreeSystem extends CommandExecutor, TabCompleter { return i; } } + Iris.error("Unhandled type in Decree Parameter: " + type.getName() + ". This is bad!"); return null; } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java new file mode 100644 index 000000000..ac4d35d56 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/handlers/EntityHandler.java @@ -0,0 +1,105 @@ +package com.volmit.iris.util.decree.handlers; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.project.loader.IrisData; +import com.volmit.iris.engine.object.dimensional.IrisDimension; +import com.volmit.iris.engine.object.entity.IrisEntity; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.collection.KMap; +import com.volmit.iris.util.decree.DecreeParameterHandler; +import com.volmit.iris.util.decree.exceptions.DecreeParsingException; +import com.volmit.iris.util.decree.exceptions.DecreeWhichException; + +import java.io.File; + +public class EntityHandler implements DecreeParameterHandler { + + /** + * Should return the possible values for this type + * + * @return Possibilities for this type. + */ + @Override + public KList getPossibilities() { + KMap p = new KMap<>(); + + //noinspection ConstantConditions + for(File i : Iris.instance.getDataFolder("packs").listFiles()) + { + if(i.isDirectory()) { + IrisData data = new IrisData(i, true); + for (IrisEntity j : data.getEntityLoader().loadAll(data.getEntityLoader().getPossibleKeys())) + { + p.putIfAbsent(j.getLoadKey(), j); + } + + data.close(); + } + } + + return p.v(); + } + + /** + * Converting the type back to a string (inverse of the {@link #parse(String) parse} method) + * + * @param entity The input of the designated type to convert to a String + * @return The resulting string + */ + @Override + public String toString(IrisEntity entity) { + return entity.getLoadKey(); + } + + /** + * Should parse a String into the designated type + * + * @param in The string to parse + * @return The value extracted from the string, of the designated type + * @throws DecreeParsingException Thrown when the parsing fails (ex: "oop" translated to an integer throws this) + * @throws DecreeWhichException Thrown when multiple results are possible + */ + @Override + public IrisEntity parse(String in) throws DecreeParsingException, DecreeWhichException { + try + { + KList options = getPossibilities(in); + + if(options.isEmpty()) + { + throw new DecreeParsingException("Unable to find Entity \"" + in + "\""); + } + + else if(options.size() > 1) + { + throw new DecreeWhichException(); + } + + return options.get(0); + } + catch(DecreeParsingException e){ + throw e; + } + catch(Throwable e) + { + throw new DecreeParsingException("Unable to find Entity \"" + in + "\" because of an uncaught exception: " + e); + } + } + + /** + * Returns whether a certain type is supported by this handler
+ * + * @param type The type to check + * @return True if supported, false if not + */ + @Override + public boolean supports(Class type) { + return type.equals(IrisEntity.class); + } + + @Override + public String getRandomDefault() + { + return "entity"; + } +} diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java new file mode 100644 index 000000000..62d0c2545 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/handlers/GeneratorHandler.java @@ -0,0 +1,78 @@ +package com.volmit.iris.util.decree.handlers; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.project.loader.IrisData; +import com.volmit.iris.engine.object.noise.IrisGenerator; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.collection.KMap; +import com.volmit.iris.util.decree.DecreeParameterHandler; +import com.volmit.iris.util.decree.exceptions.DecreeParsingException; +import com.volmit.iris.util.decree.exceptions.DecreeWhichException; + +import java.io.File; + +public class GeneratorHandler implements DecreeParameterHandler { + @Override + public KList getPossibilities() { + KMap p = new KMap<>(); + + //noinspection ConstantConditions + for(File i : Iris.instance.getDataFolder("packs").listFiles()) + { + if(i.isDirectory()) { + IrisData data = new IrisData(i, true); + for (IrisGenerator j : data.getGeneratorLoader().loadAll(data.getGeneratorLoader().getPossibleKeys())) + { + p.putIfAbsent(j.getLoadKey(), j); + } + + data.close(); + } + } + + return p.v(); + } + + @Override + public String toString(IrisGenerator gen) { + return gen.getLoadKey(); + } + + @Override + public IrisGenerator parse(String in) throws DecreeParsingException, DecreeWhichException { + try + { + KList options = getPossibilities(in); + + if(options.isEmpty()) + { + throw new DecreeParsingException("Unable to find Generator \"" + in + "\""); + } + + else if(options.size() > 1) + { + throw new DecreeWhichException(); + } + + return options.get(0); + } + catch(DecreeParsingException e){ + throw e; + } + catch(Throwable e) + { + throw new DecreeParsingException("Unable to find Generator \"" + in + "\" because of an uncaught exception: " + e); + } + } + + @Override + public boolean supports(Class type) { + return type.equals(IrisGenerator.class); + } + + @Override + public String getRandomDefault() + { + return "generator"; + } +} diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java new file mode 100644 index 000000000..3e8315d0c --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/handlers/ScriptHandler.java @@ -0,0 +1,78 @@ +package com.volmit.iris.util.decree.handlers; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.project.loader.IrisData; +import com.volmit.iris.engine.object.common.IrisScript; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.collection.KMap; +import com.volmit.iris.util.decree.DecreeParameterHandler; +import com.volmit.iris.util.decree.exceptions.DecreeParsingException; +import com.volmit.iris.util.decree.exceptions.DecreeWhichException; + +import java.io.File; + +public class ScriptHandler implements DecreeParameterHandler { + @Override + public KList getPossibilities() { + KMap p = new KMap<>(); + + //noinspection ConstantConditions + for(File i : Iris.instance.getDataFolder("packs").listFiles()) + { + if(i.isDirectory()) { + IrisData data = new IrisData(i, true); + for (IrisScript j : data.getScriptLoader().loadAll(data.getScriptLoader().getPossibleKeys())) + { + p.putIfAbsent(j.getLoadKey(), j); + } + + data.close(); + } + } + + return p.v(); + } + + @Override + public String toString(IrisScript script) { + return script.getLoadKey(); + } + + @Override + public IrisScript parse(String in) throws DecreeParsingException, DecreeWhichException { + try + { + KList options = getPossibilities(in); + + if(options.isEmpty()) + { + throw new DecreeParsingException("Unable to find Script \"" + in + "\""); + } + + else if(options.size() > 1) + { + throw new DecreeWhichException(); + } + + return options.get(0); + } + catch(DecreeParsingException e){ + throw e; + } + catch(Throwable e) + { + throw new DecreeParsingException("Unable to find Script \"" + in + "\" because of an uncaught exception: " + e); + } + } + + @Override + public boolean supports(Class type) { + return type.equals(IrisScript.class); + } + + @Override + public String getRandomDefault() + { + return "script"; + } +} From d20d1488de6d8fc681d385b9f568544a74a98a6c Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 13:35:36 +0200 Subject: [PATCH 33/45] /ir s Find error --- .../com/volmit/iris/core/decrees/DecIrisStudio.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 9d41dc9d9..6a2f67480 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -23,6 +23,7 @@ import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.gui.VisionGUI; import com.volmit.iris.core.project.IrisProject; import com.volmit.iris.core.project.loader.IrisData; +import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.engine.object.basic.IrisPosition; import com.volmit.iris.engine.object.biome.IrisBiome; import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer; @@ -371,6 +372,11 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { @Param(name = "biome", description = "The biome to find", aliases = "b") IrisBiome biome ){ + if (!IrisToolbelt.isIrisWorld(world())){ + error("You must be in an Iris world to use this command!") + return; + } + IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); if (l == null) { @@ -386,6 +392,11 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { @Param(name = "region", description = "The region to find", aliases = "r") IrisRegion region ){ + if (!IrisToolbelt.isIrisWorld(world())){ + error("You must be in an Iris world to use this command!") + return; + } + IrisPosition l = engine().lookForRegion(region, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); if (l == null) { From 1c4778790ab2a23c041aaa5105b42097b0680c6f Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 13:36:06 +0200 Subject: [PATCH 34/45] scolon --- .../java/com/volmit/iris/core/decrees/DecIrisStudio.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 6a2f67480..23191a546 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -373,7 +373,7 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { IrisBiome biome ){ if (!IrisToolbelt.isIrisWorld(world())){ - error("You must be in an Iris world to use this command!") + error("You must be in an Iris world to use this command!"); return; } @@ -393,10 +393,10 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { IrisRegion region ){ if (!IrisToolbelt.isIrisWorld(world())){ - error("You must be in an Iris world to use this command!") + error("You must be in an Iris world to use this command!"); return; } - + IrisPosition l = engine().lookForRegion(region, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); if (l == null) { From 89b171db36945e0fd37ef838c82c8d6e7333d506 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 13:48:23 +0200 Subject: [PATCH 35/45] sync loot opener since InvOpenEv must be sync --- src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 23191a546..f39a93e7a 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -414,7 +414,7 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { access().hotload(); } - @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER) + @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER, sync = true) public void loot( @Param(name = "fast", aliases = "f", description = "Fast insertion of items in virtual inventory (may cause performance drop)", defaultValue = "false") boolean fast, From 9d98641a9433bbfc007fadfaa6d9a0413c706d09 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 21:45:34 +0200 Subject: [PATCH 36/45] One - remove dupe function --- src/main/java/com/volmit/iris/core/ProjectManager.java | 4 ---- src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/ProjectManager.java b/src/main/java/com/volmit/iris/core/ProjectManager.java index 66dc8fe2e..9e7a9130a 100644 --- a/src/main/java/com/volmit/iris/core/ProjectManager.java +++ b/src/main/java/com/volmit/iris/core/ProjectManager.java @@ -363,10 +363,6 @@ public class ProjectManager { } } - public File compilePackage(VolmitSender sender, IrisDimension d, boolean obfuscate, boolean minify) { - return new IrisProject(new File(getWorkspaceFolder(), d.getLoadKey())).compilePackage(sender, obfuscate, minify); - } - public File compilePackage(VolmitSender sender, String d, boolean obfuscate, boolean minify) { return new IrisProject(new File(getWorkspaceFolder(), d)).compilePackage(sender, obfuscate, minify); } 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 f39a93e7a..557a0e751 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -477,7 +477,7 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { @Param(name = "minify", aliases = "m", description = "Whether or not to minify the pack", defaultValue = "true") boolean minify ){ - Iris.proj.compilePackage(sender(), dimension, obfuscate, minify); + Iris.proj.compilePackage(sender(), dimension.getLoadKey(), obfuscate, minify); } @Decree(description = "Profiles a dimension's performance", origin = DecreeOrigin.PLAYER) From a8449de7313453cb19af0a4d7f38c5942ce6628c Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 21:45:54 +0200 Subject: [PATCH 37/45] Two - remove test --- src/main/java/com/volmit/iris/core/decrees/DecIris.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIris.java b/src/main/java/com/volmit/iris/core/decrees/DecIris.java index 6bbe4d2da..b512e592d 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -28,14 +28,6 @@ public class DecIris implements DecreeExecutor { private DecIrisStudio studio; - @Decree(description = "Send a message to yourself", aliases = "p") - public void ping( - @Param(name = "message", description = "The message to send", defaultValue = "Pong", aliases = {"msg", "m"}) - String message) - { - sender().sendMessage(message + "!"); - } - @Decree(description = "Print version information", aliases = {"v", "ver"}) public void version(){ sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); From aaccfdee44bfd3b6cda02619a0b6f95c07f2e903 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 21:47:50 +0200 Subject: [PATCH 38/45] Three --- .../java/com/volmit/iris/util/decree/DecreeParameter.java | 4 ++-- .../java/com/volmit/iris/util/decree/annotations/Param.java | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java index 6fb356055..4bf5291ae 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeParameter.java @@ -79,11 +79,11 @@ public class DecreeParameter { } public Object getDefaultValue() throws DecreeParsingException, DecreeWhichException { - return param.defaultValue().equals(Param.REQUIRED) ? null : getHandler().parse(param.defaultValue()); + return param.defaultValue().trim().isEmpty() ? null : getHandler().parse(param.defaultValue().trim()); } public boolean hasDefault() { - return !param.defaultValue().equals(Param.REQUIRED); + return !param.defaultValue().trim().isEmpty(); } public String example() { diff --git a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java index 529eb7266..aba076a73 100644 --- a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java +++ b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java @@ -28,8 +28,6 @@ import java.lang.annotation.Target; public @interface Param { String DEFAULT_DESCRIPTION = "No Description Provided"; - String REQUIRED = "Required"; - /** * The main name of this command.
* Required parameter.
@@ -49,7 +47,7 @@ public @interface Param { * Which indicates the variable MUST be defined by the person running the command.
* If you define this, the variable automatically becomes non-required, but can still be set. */ - String defaultValue() default REQUIRED; + String defaultValue() default ""; /** * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))
From 91cf10541bdf8c1a083edf3f089474bd972cdd59 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 21:49:03 +0200 Subject: [PATCH 39/45] Four - remove decreeExtension --- .../iris/core/decrees/DecIrisStudio.java | 36 ++++++++++++++++-- .../core/decrees/DecreeStudioExtension.java | 38 ------------------- 2 files changed, 33 insertions(+), 41 deletions(-) delete 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 557a0e751..0b551c4bf 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -19,6 +19,7 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.gui.NoiseExplorerGUI; import com.volmit.iris.core.gui.VisionGUI; import com.volmit.iris.core.project.IrisProject; @@ -55,9 +56,7 @@ import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.noise.CNG; -import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.parallel.MultiBurst; -import com.volmit.iris.util.scheduling.ChronoLatch; import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.O; import com.volmit.iris.util.scheduling.PrecisionStopwatch; @@ -78,7 +77,7 @@ import java.util.concurrent.ExecutionException; import java.util.function.Supplier; @Decree(name = "studio", aliases = {"std", "s"}, description = "Studio Commands", studio = true) -public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { +public class DecIrisStudio implements DecreeExecutor { @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") @@ -708,4 +707,35 @@ public class DecIrisStudio implements DecreeExecutor, DecreeStudioExtension { error("Invalid project: " + dimension.getName() + ". Try deleting the code-workspace file and try again."); } } + + + /** + * @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 or the player is not in one + */ + private boolean noStudio(){ + if (!sender().isPlayer()){ + error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)"); + 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 deleted file mode 100644 index cb03f78cd..000000000 --- a/src/main/java/com/volmit/iris/core/decrees/DecreeStudioExtension.java +++ /dev/null @@ -1,38 +0,0 @@ -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 or the player is not in one - */ - default boolean noStudio(){ - if (!sender().isPlayer()){ - error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)"); - 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; - } -} From 80893f2592fa962debf4e683acd92d085d1d94c3 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 21:50:34 +0200 Subject: [PATCH 40/45] Five - Remove player check --- .../java/com/volmit/iris/util/decree/DecreeExecutor.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java index 1ff5c5bd9..6d9d3a81b 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java @@ -34,10 +34,7 @@ public interface DecreeExecutor { default Player player() { - if (sender().isPlayer()) { - return sender().player(); - } - return null; + return sender().player(); } default void message(String string) From 0df2dd3ce277b739f59ee432cc5dc48c766fca60 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 21:53:28 +0200 Subject: [PATCH 41/45] Six - true is not false. bad --- .../volmit/iris/util/decree/virtual/VirtualDecreeCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java index ed7d4252a..a2d732ee9 100644 --- a/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java +++ b/src/main/java/com/volmit/iris/util/decree/virtual/VirtualDecreeCommand.java @@ -411,7 +411,7 @@ public class VirtualDecreeCommand { if(isStudio() && !IrisSettings.get().isStudio()) { sender.sendMessage(C.RED + "To use Iris Studio Commands, please enable studio in Iris/settings.json (settings auto-reload)"); - return true; // Must still return true because command exists but is not enabled + return false; } Iris.debug("@ " + getPath() + " with " + args.toString(", ")); From 8fa9977617197b998be586d0686f7a23fdb089af Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 22:04:14 +0200 Subject: [PATCH 42/45] Seven - getloadkey --- src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java | 2 +- .../iris/engine/scripting/EngineExecutionEnvironment.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) 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 0b551c4bf..4dfa43cd0 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -334,7 +334,7 @@ public class DecIrisStudio implements DecreeExecutor { @Param(name = "script", description = "The script to run", aliases = {"s", "scr"}) IrisScript script ) { - engine().getExecution().execute(script); + engine().getExecution().execute(script.getLoadKey()); } @Decree(description = "Open the noise explorer (External GUI)", aliases = "nmap") diff --git a/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java b/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java index f85c11736..b91e02ebb 100644 --- a/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java +++ b/src/main/java/com/volmit/iris/engine/scripting/EngineExecutionEnvironment.java @@ -31,8 +31,6 @@ public interface EngineExecutionEnvironment { void execute(String script); - void execute(IrisScript script); - Object evaluate(String script); default void close() { From 5fe5ba78da716edf6686fb0faf6f12b8da496479 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 22:12:51 +0200 Subject: [PATCH 43/45] Eight - remove technical debt --- .../iris/core/decrees/DecIrisStudio.java | 72 +++++++++---------- .../iris/util/decree/DecreeExecutor.java | 20 ------ 2 files changed, 36 insertions(+), 56 deletions(-) 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 4dfa43cd0..f07fea473 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -84,19 +84,19 @@ public class DecIrisStudio implements DecreeExecutor { IrisDimension dimension, @Param(name = "seed", defaultValue = "1337", description = "The seed to generate the studio with", aliases = "s") long seed) { - success("Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")"); + sender().sendMessage(C.GREEN + "Opening studio for the \"" + dimension.getName() + "\" pack (seed: " + seed + ")"); Iris.proj.open(sender(), seed, dimension.getLoadKey()); } @Decree(description = "Close an open studio project", aliases = "x", sync = true) public void close() { if (!Iris.proj.isProjectOpen()) { - error("No open studio projects."); + sender().sendMessage(C.RED + "No open studio projects."); return; } Iris.proj.close(); - success("Project Closed."); + sender().sendMessage(C.GREEN + "Project Closed."); } @Decree(description = "Create a new studio project", aliases = "+", sync = true) @@ -291,7 +291,7 @@ public class DecIrisStudio implements DecreeExecutor { @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim") IrisDimension dimension ) { - success("The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); + sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); } @Decree(description = "Beatify a pack", aliases = {"beauty", "prettify"}) @@ -300,14 +300,14 @@ public class DecIrisStudio implements DecreeExecutor { IrisDimension dimension ) { File folder = dimension.getLoadFile().getParentFile().getParentFile(); - success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); + sender().sendMessage(C.GREEN + "Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @Decree(description = "Beatify a pack - must be in studio!", aliases = {"beauty", "prettify"}) public void beautify() { if (noStudio()) return; File folder = Iris.proj.getActiveProject().getPath(); - success("Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); + sender().sendMessage(C.GREEN + "Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); } @Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv") @@ -325,7 +325,7 @@ public class DecIrisStudio implements DecreeExecutor { Desktop.getDesktop().open(Iris.proj.getActiveProject().getActiveProvider().getEngine().getBiome(sender().player().getLocation()).getLoadFile()); } catch (Throwable e) { Iris.reportError(e); - error("Cant find the file. Unsure why this happened."); + sender().sendMessage(C.RED + "Cant find the file. Unsure why this happened."); } } @@ -340,7 +340,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Open the noise explorer (External GUI)", aliases = "nmap") public void noise() { if (noGUI()) return; - success("Opening Noise Explorer!"); + sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); NoiseExplorerGUI.launch(); } @@ -353,7 +353,7 @@ public class DecIrisStudio implements DecreeExecutor { long seed ){ if (noGUI()) return; - success("Opening Noise Explorer!"); + sender().sendMessage(C.GREEN + "Opening Noise Explorer!"); Supplier> l = () -> { @@ -372,16 +372,16 @@ public class DecIrisStudio implements DecreeExecutor { IrisBiome biome ){ if (!IrisToolbelt.isIrisWorld(world())){ - error("You must be in an Iris world to use this command!"); + sender().sendMessage(C.RED + "You must be in an Iris world to use this command!"); return; } - IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + IrisPosition l = engine().lookForBiome(biome, 10000, (v) -> sender().sendMessage("Looking for " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); if (l == null) { - error("Couldn't find " + biome.getName() + "."); + sender().sendMessage(C.RED + "Couldn't find " + biome.getName() + "."); } else { - success("Found " + biome.getName() + "!"); + sender().sendMessage(C.GREEN + "Found " + biome.getName() + "!"); J.s(() -> player().teleport(l.toLocation(world()))); } } @@ -392,16 +392,16 @@ public class DecIrisStudio implements DecreeExecutor { IrisRegion region ){ if (!IrisToolbelt.isIrisWorld(world())){ - error("You must be in an Iris world to use this command!"); + sender().sendMessage(C.RED + "You must be in an Iris world to use this command!"); return; } - IrisPosition l = engine().lookForRegion(region, 10000, (v) -> message("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); + IrisPosition l = engine().lookForRegion(region, 10000, (v) -> sender().sendMessage("Looking for " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + ": Checked " + Form.f(v) + " Places")); if (l == null) { - error("Couldn't find " + region.getName() + "."); + sender().sendMessage(C.RED + "Couldn't find " + region.getName() + "."); } else { - success("Found " + region.getName() + "!"); + sender().sendMessage(C.GREEN + "Found " + region.getName() + "!"); J.s(() -> player().teleport(l.toLocation(world()))); } } @@ -429,7 +429,7 @@ public class DecIrisStudio implements DecreeExecutor { engine().addItems(true, inv, RNG.r, tables, InventorySlotType.STORAGE, player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1); } catch (Throwable e){ Iris.reportError(e); - error("Cannot add items to virtual inventory because of: " + e.getMessage()); + sender().sendMessage(C.RED + "Cannot add items to virtual inventory because of: " + e.getMessage()); return; } @@ -441,7 +441,7 @@ public class DecIrisStudio implements DecreeExecutor { { if (!player().getOpenInventory().getType().equals(InventoryType.CHEST)) { Bukkit.getScheduler().cancelTask(ta.get()); - success("Opened inventory!"); + sender().sendMessage(C.GREEN + "Opened inventory!"); return; } @@ -452,7 +452,7 @@ public class DecIrisStudio implements DecreeExecutor { engine().addItems(true, inv, new RNG(RNG.r.imax()), tables, InventorySlotType.STORAGE, player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ(), 1); }, 0, fast ? 5 : 35)); - success("Opening inventory now!"); + sender().sendMessage(C.GREEN + "Opening inventory now!"); player().openInventory(inv); } @@ -464,7 +464,7 @@ public class DecIrisStudio implements DecreeExecutor { if (noGUI()) return; VisionGUI.launch(engine(), 0); - success("Opening map!"); + sender().sendMessage(C.GREEN + "Opening map!"); } @Decree(description = "Package a dimension into a compressed format", aliases = "package") @@ -497,7 +497,7 @@ public class DecIrisStudio implements DecreeExecutor { KMap biomeTimings = new KMap<>(); KMap regionTimings = new KMap<>(); - message("Calculating Performance Metrics for Noise generators"); + sender().sendMessage("Calculating Performance Metrics for Noise generators"); for (NoiseStyle i : NoiseStyle.values()) { CNG c = i.create(new RNG(i.hashCode())); @@ -525,7 +525,7 @@ public class DecIrisStudio implements DecreeExecutor { fileText.add(""); - message("Calculating Interpolator Timings..."); + sender().sendMessage("Calculating Interpolator Timings..."); for (InterpolationMethod i : InterpolationMethod.values()) { IrisInterpolator in = new IrisInterpolator(); @@ -555,7 +555,7 @@ public class DecIrisStudio implements DecreeExecutor { fileText.add(""); - message("Processing Generator Scores: "); + sender().sendMessage("Processing Generator Scores: "); KMap> btx = new KMap<>(); @@ -655,7 +655,7 @@ public class DecIrisStudio implements DecreeExecutor { m += mmm; fileText.add("Average Score: " + m); - message("Score: " + Form.duration(m, 0)); + sender().sendMessage("Score: " + Form.duration(m, 0)); try { IO.writeAll(report, fileText.toString("\n")); @@ -664,7 +664,7 @@ public class DecIrisStudio implements DecreeExecutor { e.printStackTrace(); } - success("Done! " + report.getPath()); + sender().sendMessage(C.GREEN + "Done! " + report.getPath()); } @Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER) @@ -675,23 +675,23 @@ public class DecIrisStudio implements DecreeExecutor { if (noStudio()){ return; } - success("Spawning entity"); + sender().sendMessage(C.GREEN + "Spawning entity"); entity.spawn(engine(), player().getLocation().clone().add(0, 2, 0)); } @Decree(description = "Teleport to the active studio world", aliases = {"tps", "stp", "tp"}, origin = DecreeOrigin.PLAYER) public void tpstudio(){ if (!Iris.proj.isProjectOpen()){ - error("No studio world is open!"); + sender().sendMessage(C.RED + "No studio world is open!"); return; } if (engine().isStudio()){ - error("You are already in a studio world!"); + sender().sendMessage(C.RED + "You are already in a studio world!"); return; } - success("Sending you to the studio world!"); + sender().sendMessage(C.GREEN + "Sending you to the studio world!"); player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().spawnLocation()); player().setGameMode(GameMode.SPECTATOR); } @@ -702,9 +702,9 @@ public class DecIrisStudio implements DecreeExecutor { IrisDimension dimension ){ if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) { - success("Updated Code Workspace for " + dimension.getName()); + sender().sendMessage(C.GREEN + "Updated Code Workspace for " + dimension.getName()); } else { - error("Invalid project: " + dimension.getName() + ". Try deleting the code-workspace file and try again."); + sender().sendMessage(C.RED + "Invalid project: " + dimension.getName() + ". Try deleting the code-workspace file and try again."); } } @@ -714,7 +714,7 @@ public class DecIrisStudio implements DecreeExecutor { */ private boolean noGUI() { if (!IrisSettings.get().isUseServerLaunchedGuis()){ - error("You must have server launched GUIs enabled in the settings!"); + sender().sendMessage(C.RED + "You must have server launched GUIs enabled in the settings!"); return true; } return false; @@ -725,15 +725,15 @@ public class DecIrisStudio implements DecreeExecutor { */ private boolean noStudio(){ if (!sender().isPlayer()){ - error("Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)"); + sender().sendMessage(C.RED + "Players only (this is a config error. Ask support to add DecreeOrigin.PLAYER to the command you tried to run)"); return true; } if (!Iris.proj.isProjectOpen()){ - error("No studio world is open!"); + sender().sendMessage(C.RED + "No studio world is open!"); return true; } if (!engine().isStudio()){ - error("You must be in a studio world!"); + sender().sendMessage(C.RED + "You must be in a studio world!"); return true; } return false; diff --git a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java index 6d9d3a81b..5c27073f4 100644 --- a/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java +++ b/src/main/java/com/volmit/iris/util/decree/DecreeExecutor.java @@ -37,26 +37,6 @@ public interface DecreeExecutor { return sender().player(); } - default void message(String string) - { - sender().sendMessage(string); - } - - default void success(String string) - { - message(C.GREEN + string); - } - - default void error(String string) - { - message(C.RED + string); - } - - default void warn(String string) - { - message(C.YELLOW + string); - } - default Engine engine() { if(sender().isPlayer() && IrisToolbelt.access(sender().player().getWorld()) != null) From f8336d6adbae1dfef6b11c715793ab3e8c97ed01 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 22:46:22 +0200 Subject: [PATCH 44/45] Nine - remove aliases --- src/main/java/com/volmit/iris/core/decrees/DecIris.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIris.java b/src/main/java/com/volmit/iris/core/decrees/DecIris.java index b512e592d..9335c3eb5 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -28,7 +28,7 @@ public class DecIris implements DecreeExecutor { private DecIrisStudio studio; - @Decree(description = "Print version information", aliases = {"v", "ver"}) + @Decree(description = "Print version information") public void version(){ sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); } From 64bb6714a30461f09985c9c8f6417341bd032865 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Sun, 15 Aug 2021 22:49:28 +0200 Subject: [PATCH 45/45] Ten - Remove beautify in favour of clean --- .../iris/core/decrees/DecIrisStudio.java | 17 ----- .../volmit/iris/util/json/JSONCleaner.java | 66 ------------------- 2 files changed, 83 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/util/json/JSONCleaner.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 f07fea473..514236ea3 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -52,7 +52,6 @@ import com.volmit.iris.util.function.NoiseProvider; import com.volmit.iris.util.interpolation.InterpolationMethod; import com.volmit.iris.util.io.IO; import com.volmit.iris.util.json.JSONArray; -import com.volmit.iris.util.json.JSONCleaner; import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.noise.CNG; @@ -294,22 +293,6 @@ public class DecIrisStudio implements DecreeExecutor { sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); } - @Decree(description = "Beatify a pack", aliases = {"beauty", "prettify"}) - public void beautify( - @Param(name = "dimension", defaultValue = "overworld", description = "The to-beautify dimension", aliases = "dim") - IrisDimension dimension - ) { - File folder = dimension.getLoadFile().getParentFile().getParentFile(); - sender().sendMessage(C.GREEN + "Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); - } - - @Decree(description = "Beatify a pack - must be in studio!", aliases = {"beauty", "prettify"}) - public void beautify() { - if (noStudio()) return; - File folder = Iris.proj.getActiveProject().getPath(); - sender().sendMessage(C.GREEN + "Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files"); - } - @Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv") public void convert() { Iris.convert.check(sender()); diff --git a/src/main/java/com/volmit/iris/util/json/JSONCleaner.java b/src/main/java/com/volmit/iris/util/json/JSONCleaner.java deleted file mode 100644 index d75b360e3..000000000 --- a/src/main/java/com/volmit/iris/util/json/JSONCleaner.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.volmit.iris.util.json; - -import com.volmit.iris.Iris; -import com.volmit.iris.util.io.IO; -import com.volmit.iris.util.plugin.VolmitSender; - -import java.io.File; -import java.io.IOException; - -public class JSONCleaner { - public static int clean(VolmitSender s, File clean) { - int c = 0; - if (clean.isDirectory()) { - for (File i : clean.listFiles()) { - c += clean(s, i); - } - } else if (clean.getName().endsWith(".json")) { - try { - clean(clean); - } catch (Throwable e) { - Iris.reportError(e); - Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!"); - } - - c++; - } - - return c; - } - - public static void clean(File clean) throws IOException { - JSONObject obj = new JSONObject(IO.readAll(clean)); - fixBlocks(obj, clean); - - IO.writeAll(clean, obj.toString(4)); - } - - public static void fixBlocks(JSONObject obj, File f) { - for (String i : obj.keySet()) { - Object o = obj.get(i); - - if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { - obj.put(i, "minecraft:" + o); - Iris.debug("Updated Block Key: " + o + " to " + obj.getString(i) + " in " + f.getPath()); - } - - if (o instanceof JSONObject) { - fixBlocks((JSONObject) o, f); - } else if (o instanceof JSONArray) { - fixBlocks((JSONArray) o, f); - } - } - } - - public static void fixBlocks(JSONArray obj, File f) { - for (int i = 0; i < obj.length(); i++) { - Object o = obj.get(i); - - if (o instanceof JSONObject) { - fixBlocks((JSONObject) o, f); - } else if (o instanceof JSONArray) { - fixBlocks((JSONArray) o, f); - } - } - } -}