From 0e0bd942513b8c680e5e1c5333922bbd5783258f Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 12:06:04 +0200 Subject: [PATCH 01/15] Remove aliases that *should* be interpretable by the processor --- .../iris/core/decrees/DecIrisStudio.java | 89 ++++++++++--------- 1 file changed, 47 insertions(+), 42 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 514236ea3..61feec631 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -285,15 +285,15 @@ public class DecIrisStudio implements DecreeExecutor { } } - @Decree(description = "Get the version of a pack", aliases = {"v", "ver"}) + @Decree(description = "Get the version of a pack") public void version( - @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim") + @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of") IrisDimension dimension ) { sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); } - @Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv") + @Decree(description = "Convert objects in the \"convert\" folder") public void convert() { Iris.convert.check(sender()); } @@ -312,9 +312,9 @@ public class DecIrisStudio implements DecreeExecutor { } } - @Decree(description = "Execute a script", aliases = {"ex", "exec", "run"}, origin = DecreeOrigin.PLAYER) + @Decree(description = "Execute a script", aliases = "run", origin = DecreeOrigin.PLAYER) public void execute( - @Param(name = "script", description = "The script to run", aliases = {"s", "scr"}) + @Param(name = "script", description = "The script to run") IrisScript script ) { engine().getExecution().execute(script.getLoadKey()); @@ -330,9 +330,9 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Preview noise gens (External GUI)", aliases = {"generator", "gen"}) public void explore( - @Param(name = "generator", description = "The generator to explore", aliases = {"gen", "g"}) + @Param(name = "generator", description = "The generator to explore") IrisGenerator generator, - @Param(name = "seed", description = "The seed to generate with", aliases = "s", defaultValue = "12345") + @Param(name = "seed", description = "The seed to generate with", defaultValue = "12345") long seed ){ if (noGUI()) return; @@ -349,29 +349,11 @@ public class DecIrisStudio implements DecreeExecutor { NoiseExplorerGUI.launch(l, "Custom Generator"); } - @Decree(description = "Find any biome", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) + @Decree(description = "Find any biome or region", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) public void find( - @Param(name = "biome", description = "The biome to find", aliases = "b") - IrisBiome biome - ){ - if (!IrisToolbelt.isIrisWorld(world())){ - sender().sendMessage(C.RED + "You must be in an Iris world to use this command!"); - return; - } - - 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(C.RED + "Couldn't find " + biome.getName() + "."); - } else { - sender().sendMessage(C.GREEN + "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") + @Param(name = "biome", description = "The biome to find") + IrisBiome biome, + @Param(name = "region", description = "The region to find") IrisRegion region ){ if (!IrisToolbelt.isIrisWorld(world())){ @@ -379,17 +361,40 @@ public class DecIrisStudio implements DecreeExecutor { return; } - 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 (biome == null && region == null){ + sender().sendMessage(C.RED + "You must specify a biome or region!"); + return; + } + + IrisPosition l = null; + if (region != null) { + l = engine().lookForRegion(region, 10000, (v) -> sender().sendMessage("Looking for the " + C.BOLD + C.WHITE + region.getName() + C.RESET + C.GRAY + " region: Checked " + Form.f(v) + " Places")); + if (l == null) { + sender().sendMessage(C.YELLOW + "Couldn't find the " + region.getName() + " region."); + } else { + sender().sendMessage(C.GREEN + "Found the " + region.getName() + " region!."); + } + } + + if (l == null && biome != null) { + l = engine().lookForBiome(biome, 10000, (v) -> sender().sendMessage("Looking for the " + C.BOLD + C.WHITE + biome.getName() + C.RESET + C.GRAY + " biome: Checked " + Form.f(v) + " Places")); + if (l == null) { + sender().sendMessage(C.YELLOW + "Couldn't find the " + biome.getName() + " biome."); + } else { + sender().sendMessage(C.GREEN + "Found the " + biome.getName() + " biome!."); + } + } if (l == null) { - sender().sendMessage(C.RED + "Couldn't find " + region.getName() + "."); - } else { - sender().sendMessage(C.GREEN + "Found " + region.getName() + "!"); - J.s(() -> player().teleport(l.toLocation(world()))); + sender().sendMessage(C.RED + "Could not find the region and / or biome you specified."); + return; } + + final IrisPosition finalL = l; + J.s(() -> player().teleport(finalL.toLocation(world()))); } - @Decree(description = "Hotload a studio", aliases = {"hot", "h", "reload"}, origin = DecreeOrigin.PLAYER) + @Decree(description = "Hotload a studio", aliases = "reload", origin = DecreeOrigin.PLAYER) public void hotload() { if (noStudio()) return; @@ -452,11 +457,11 @@ public class DecIrisStudio implements DecreeExecutor { @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") + @Param(name = "dimension", description = "The dimension pack to compress") IrisDimension dimension, - @Param(name = "obfuscate", aliases = "o", description = "Whether or not to obfuscate the pack", defaultValue = "false") + @Param(name = "obfuscate", 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") + @Param(name = "minify", description = "Whether or not to minify the pack", defaultValue = "true") boolean minify ){ Iris.proj.compilePackage(sender(), dimension.getLoadKey(), obfuscate, minify); @@ -464,7 +469,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Profiles a dimension's performance", origin = DecreeOrigin.PLAYER) public void profile( - @Param(name = "dimension", aliases = {"d", "dim"}, description = "The dimension to profile") + @Param(name = "dimension", description = "The dimension to profile") IrisDimension dimension ){ File pack = dimension.getLoadFile().getParentFile().getParentFile(); @@ -652,7 +657,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER) public void summon( - @Param(description = "The Iris Entity to spawn", aliases = "e", name = "entity") + @Param(description = "The Iris Entity to spawn", name = "entity") IrisEntity entity ) { if (noStudio()){ @@ -679,9 +684,9 @@ public class DecIrisStudio implements DecreeExecutor { player().setGameMode(GameMode.SPECTATOR); } - @Decree(description = "Update your dimension project", aliases = {"upd", "u"}) + @Decree(description = "Update your dimension project") public void update( - @Param(name = "dimension", aliases = {"d", "dim"}, description = "The dimension to update the workspace of") + @Param(name = "dimension", description = "The dimension to update the workspace of") IrisDimension dimension ){ if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) { From 7c5d8721c0d02ddd0d0372303da28f73aa9c8d2a Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 13:17:14 +0200 Subject: [PATCH 02/15] Studio command patches & generator context Generator context is pretty poorly implemented --- .../iris/core/decrees/DecIrisStudio.java | 33 +++++++++++-------- .../context/GeneratorContextHandler.java | 27 +++++++++++++++ 2 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/volmit/iris/util/decree/context/GeneratorContextHandler.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 61feec631..faf4ab6e2 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -102,7 +102,7 @@ public class DecIrisStudio implements DecreeExecutor { public void create( @Param(name = "name", description = "The name of this new Iris Project.") String name, - @Param(name = "template", description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.") + @Param(name = "template", description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.", contextual = true) IrisDimension template) { if (template != null) { @@ -114,7 +114,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Clean an Iris Project, optionally beautifying JSON & fixing block ids with missing keys. Also rebuilds the vscode schemas. ") public void clean( - @Param(name = "project", description = "The project to update") + @Param(name = "project", description = "The project to update", contextual = true) IrisDimension project, @Param(name = "beautify", defaultValue = "true", description = "Filters all valid JSON files with a beautifier (indentation: 4)") @@ -287,7 +287,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Get the version of a pack") public void version( - @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of") + @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim", contextual = true) IrisDimension dimension ) { sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); @@ -300,12 +300,14 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Edit the biome you're currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER) - public void editbiome() { - + public void editbiome( + @Param(name = "biome", contextual = true, description = "The biome to edit") + IrisBiome biome + ) { if (noStudio()) return; try { - Desktop.getDesktop().open(Iris.proj.getActiveProject().getActiveProvider().getEngine().getBiome(sender().player().getLocation()).getLoadFile()); + Desktop.getDesktop().open(biome.getLoadFile()); } catch (Throwable e) { Iris.reportError(e); sender().sendMessage(C.RED + "Cant find the file. Unsure why this happened."); @@ -330,7 +332,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Preview noise gens (External GUI)", aliases = {"generator", "gen"}) public void explore( - @Param(name = "generator", description = "The generator to explore") + @Param(name = "generator", description = "The generator to explore", contextual = true) IrisGenerator generator, @Param(name = "seed", description = "The seed to generate with", defaultValue = "12345") long seed @@ -457,7 +459,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Package a dimension into a compressed format", aliases = "package") public void pkg( - @Param(name = "dimension", description = "The dimension pack to compress") + @Param(name = "dimension", description = "The dimension pack to compress", contextual = true) IrisDimension dimension, @Param(name = "obfuscate", description = "Whether or not to obfuscate the pack", defaultValue = "false") boolean obfuscate, @@ -469,7 +471,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Profiles a dimension's performance", origin = DecreeOrigin.PLAYER) public void profile( - @Param(name = "dimension", description = "The dimension to profile") + @Param(name = "dimension", description = "The dimension to profile", contextual = true) IrisDimension dimension ){ File pack = dimension.getLoadFile().getParentFile().getParentFile(); @@ -660,21 +662,26 @@ public class DecIrisStudio implements DecreeExecutor { @Param(description = "The Iris Entity to spawn", name = "entity") IrisEntity entity ) { - if (noStudio()){ + if (!sender().isPlayer()){ + 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; + } + if (IrisToolbelt.isIrisWorld(world())){ + sender().sendMessage(C.RED + "You can only spawn entities in Iris worlds!"); return; } 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) + @Decree(description = "Teleport to the active studio world", aliases = "stp", origin = DecreeOrigin.PLAYER, sync = true) public void tpstudio(){ if (!Iris.proj.isProjectOpen()){ sender().sendMessage(C.RED + "No studio world is open!"); return; } - if (engine().isStudio()){ + if (IrisToolbelt.isIrisWorld(world()) && engine().isStudio()){ sender().sendMessage(C.RED + "You are already in a studio world!"); return; } @@ -686,7 +693,7 @@ public class DecIrisStudio implements DecreeExecutor { @Decree(description = "Update your dimension project") public void update( - @Param(name = "dimension", description = "The dimension to update the workspace of") + @Param(name = "dimension", description = "The dimension to update the workspace of", contextual = true) IrisDimension dimension ){ if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) { diff --git a/src/main/java/com/volmit/iris/util/decree/context/GeneratorContextHandler.java b/src/main/java/com/volmit/iris/util/decree/context/GeneratorContextHandler.java new file mode 100644 index 000000000..0e23c0f62 --- /dev/null +++ b/src/main/java/com/volmit/iris/util/decree/context/GeneratorContextHandler.java @@ -0,0 +1,27 @@ +package com.volmit.iris.util.decree.context; + +import com.volmit.iris.core.tools.IrisToolbelt; +import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.object.noise.IrisGenerator; +import com.volmit.iris.util.decree.DecreeContextHandler; +import com.volmit.iris.util.plugin.VolmitSender; + +public class GeneratorContextHandler implements DecreeContextHandler { + @Override + public Class getType() { + return IrisGenerator.class; + } + + @Override + public IrisGenerator handle(VolmitSender sender) { + if(sender.isPlayer() + && IrisToolbelt.isIrisWorld(sender.player().getWorld()) + && IrisToolbelt.access(sender.player().getWorld()).getEngine() != null) + { + Engine engine = IrisToolbelt.access(sender.player().getWorld()).getEngine(); + return engine.getData().getGeneratorLoader().load(engine.getBiome(sender.player().getLocation()).getGenerators().getRandom().getGenerator()); + } + + return null; + } +} From 571e918ee06a2b3feb1024ce87065fbcb87861d2 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 18:13:57 +0200 Subject: [PATCH 03/15] aura --- .../com/volmit/iris/core/decrees/DecIris.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 9335c3eb5..3428761f2 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.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.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; @@ -32,4 +33,20 @@ public class DecIris implements DecreeExecutor public void version(){ sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); } + + @Decree(description = "Set aura spins") + public void aura( + @Param(name = "h", description = "The h color value") + int h, + @Param(name = "s", description = "The s color value") + int s, + @Param(name = "b", description = "The b color value") + int b + ){ + IrisSettings.get().getGeneral().setSpinh(h); + IrisSettings.get().getGeneral().setSpins(s); + IrisSettings.get().getGeneral().setSpinb(b); + IrisSettings.get().forceSave(); + sender().sendMessage("Aura Spins updated to " + h + " " + s + " " + b); + } } From 50ee2727a2d745aba7f9b47898407180e46f74da Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 18:23:13 +0200 Subject: [PATCH 04/15] bitwise --- .../com/volmit/iris/core/decrees/DecIris.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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 3428761f2..86991645c 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -23,6 +23,7 @@ import com.volmit.iris.core.IrisSettings; 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; @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") public class DecIris implements DecreeExecutor @@ -49,4 +50,31 @@ public class DecIris implements DecreeExecutor IrisSettings.get().forceSave(); sender().sendMessage("Aura Spins updated to " + h + " " + s + " " + b); } + + @Decree(description = "Bitwise calculations") + public void bitwise( + @Param(name = "value1", description = "The first value to run calculations on") + int val1, + @Param(name = "operator", description = "The operator: | & ^ >> << %") + String operator, + @Param(name = "value2", description = "The second value to run calculations on") + int val2 + ){ + Integer v = null; + switch(operator) { + case "|" -> v = val1 | val2; + case "&" -> v = val1 & val2; + case "^" -> v = val1 ^ val2; + case "%" -> v = val1 % val2; + case ">>" -> v = val1 >> val2; + case "<<" -> v = val1 << val2; + }; + if (v == null){ + sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!"); + return; + } + sender().sendMessage(C.GREEN + "" + val1 + " " + operator + " " + val2 + " => " + v); + } + + } From 209934235242e6861cefffb329ec7643c670f16e Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 18:30:53 +0200 Subject: [PATCH 05/15] debug --- .../java/com/volmit/iris/core/decrees/DecIris.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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 86991645c..0d22adb31 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -38,11 +38,11 @@ public class DecIris implements DecreeExecutor @Decree(description = "Set aura spins") public void aura( @Param(name = "h", description = "The h color value") - int h, + int h, @Param(name = "s", description = "The s color value") - int s, + int s, @Param(name = "b", description = "The b color value") - int b + int b ){ IrisSettings.get().getGeneral().setSpinh(h); IrisSettings.get().getGeneral().setSpins(s); @@ -76,5 +76,13 @@ public class DecIris implements DecreeExecutor sender().sendMessage(C.GREEN + "" + val1 + " " + operator + " " + val2 + " => " + v); } + @Decree(description = "Toggle debug") + public void debug( + @Param(name = "on", description = "Whether or not debug should be on", defaultValue = "true") + boolean on + ){ + IrisSettings.get().getGeneral().setDebug(on); + } + } From a18c4b64493f58765e771d7f7c350497060c0e61 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 18:48:42 +0200 Subject: [PATCH 06/15] Studio charge (no longer in debug) --- src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java | 4 ++++ 1 file changed, 4 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 faf4ab6e2..70bbb5418 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java @@ -329,6 +329,10 @@ public class DecIrisStudio implements DecreeExecutor { NoiseExplorerGUI.launch(); } + @Decree(description = "Charges all spawners in the area", aliases = "zzt", origin = DecreeOrigin.PLAYER) + public void charge() { + engine().getWorldManager().chargeEnergy(); + } @Decree(description = "Preview noise gens (External GUI)", aliases = {"generator", "gen"}) public void explore( From 714afabf3094a01d7f83fd2d167304cbea432cd1 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 19:04:07 +0200 Subject: [PATCH 07/15] Download --- .../java/com/volmit/iris/core/decrees/DecIris.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 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 0d22adb31..e57665908 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -84,5 +84,16 @@ public class DecIris implements DecreeExecutor IrisSettings.get().getGeneral().setDebug(on); } - + @Decree(description = "Download a project.") + public void download( + @Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project") + String pack, + @Param(name = "branch", description = "The branch to download from", defaultValue = "master") + String branch, + @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when you're going to edit)") + boolean trim + ){ + sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "")); + Iris.proj.downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim); + } } From e7a529257ab2acc031faa941d6a568e37c9a1712 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 20:38:46 +0200 Subject: [PATCH 08/15] Metrics --- .../com/volmit/iris/core/decrees/DecIris.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 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 e57665908..42389d74b 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -20,10 +20,13 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; +import com.volmit.iris.core.tools.IrisToolbelt; 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 org.bukkit.World; @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") public class DecIris implements DecreeExecutor @@ -43,7 +46,7 @@ public class DecIris implements DecreeExecutor int s, @Param(name = "b", description = "The b color value") int b - ){ + ) { IrisSettings.get().getGeneral().setSpinh(h); IrisSettings.get().getGeneral().setSpins(s); IrisSettings.get().getGeneral().setSpinb(b); @@ -59,7 +62,7 @@ public class DecIris implements DecreeExecutor String operator, @Param(name = "value2", description = "The second value to run calculations on") int val2 - ){ + ) { Integer v = null; switch(operator) { case "|" -> v = val1 | val2; @@ -80,7 +83,7 @@ public class DecIris implements DecreeExecutor public void debug( @Param(name = "on", description = "Whether or not debug should be on", defaultValue = "true") boolean on - ){ + ) { IrisSettings.get().getGeneral().setDebug(on); } @@ -92,8 +95,18 @@ public class DecIris implements DecreeExecutor String branch, @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when you're going to edit)") boolean trim - ){ + ) { sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "")); Iris.proj.downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim); } + + @Decree(description = "Get metrics for your world", aliases = "measure", origin = DecreeOrigin.PLAYER) + public void metrics() { + if (!IrisToolbelt.isIrisWorld(world())){ + sender().sendMessage(C.RED + "You must be in an Iris world"); + return; + } + sender().sendMessage(C.GREEN + "Sending metrics..."); + engine().printMetrics(sender()); + } } From a3d6776c021a950f07e29a346a1e66118cb76a50 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 20:44:42 +0200 Subject: [PATCH 09/15] Merge pack overwrite with download (under param) --- .../java/com/volmit/iris/core/decrees/DecIris.java | 13 +++++++++++-- 1 file changed, 11 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 42389d74b..7ece29f6a 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -94,10 +94,12 @@ public class DecIris implements DecreeExecutor @Param(name = "branch", description = "The branch to download from", defaultValue = "master") String branch, @Param(name = "trim", description = "Whether or not to download a trimmed version (do not enable when you're going to edit)") - boolean trim + boolean trim, + @Param(name = "overwrite", description = "Whether or not to overwrite the pack with the downloaded one", aliases = "force", defaultValue = "false") + boolean overwrite ) { sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "")); - Iris.proj.downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim); + Iris.proj.downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite); } @Decree(description = "Get metrics for your world", aliases = "measure", origin = DecreeOrigin.PLAYER) @@ -109,4 +111,11 @@ public class DecIris implements DecreeExecutor sender().sendMessage(C.GREEN + "Sending metrics..."); engine().printMetrics(sender()); } + + @Decree(description = "Reload configuration file (this is also done automatically)") + public void reload() { + IrisSettings.invalidate(); + IrisSettings.get(); + sender().sendMessage(C.GREEN + "Hotloaded settings"); + } } From 15721f1279763b83934990d8755bc366295d5e29 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 21:37:53 +0200 Subject: [PATCH 10/15] Pregen & create --- .../com/volmit/iris/core/decrees/DecIris.java | 45 ++++++++++++++ .../iris/core/decrees/DecIrisPregen.java | 59 +++++++++++++++++++ .../com/volmit/iris/util/math/Position2.java | 6 ++ 3 files changed, 110 insertions(+) create mode 100644 src/main/java/com/volmit/iris/core/decrees/DecIrisPregen.java 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 7ece29f6a..ddc026966 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -21,18 +21,63 @@ package com.volmit.iris.core.decrees; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.tools.IrisToolbelt; +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.exceptions.IrisException; import com.volmit.iris.util.format.C; import org.bukkit.World; +import java.io.File; +import java.util.Objects; + @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") public class DecIris implements DecreeExecutor { private DecIrisStudio studio; + private DecIrisPregen pregen; + + @Decree(description = "Create a new world", aliases = "+") + public void create( + @Param(name = "name", aliases = "worldName", description = "The name of the world to create", defaultValue = "IrisWorld") + String name, + @Param(name = "type", aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") + IrisDimension type, + @Param(name = "seed", description = "The seed to generate the world with", defaultValue = "1337") + long seed + ){ + if (name.equals("iris")) { + sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds."); + sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?"); + return; + } + + if (new File(name).exists()){ + sender().sendMessage(C.RED + "That folder already exists!"); + return; + } + + try { + IrisToolbelt.createWorld() + .dimension(type.getLoadKey()) + .name(name) + .seed(seed) + .sender(sender()) + .studio(false) + .create(); + } catch (Throwable e){ + sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details."); + Iris.error("Exception raised during world creation: " + e.getMessage()); + Iris.reportError(e); + return; + } + + sender().sendMessage(C.GREEN + "Successfully created your world!"); + } + @Decree(description = "Print version information") public void version(){ sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software"); diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIrisPregen.java b/src/main/java/com/volmit/iris/core/decrees/DecIrisPregen.java new file mode 100644 index 000000000..0e9021029 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisPregen.java @@ -0,0 +1,59 @@ +package com.volmit.iris.core.decrees; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.gui.PregeneratorJob; +import com.volmit.iris.core.pregenerator.PregenTask; +import com.volmit.iris.core.tools.IrisToolbelt; +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.math.Position2; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.util.Vector; + +@Decree(name = "pregen", aliases = "pregenerate", description = "Pregenerate your Iris worlds!") +public class DecIrisPregen implements DecreeExecutor { + @Decree(description = "Pregenerate a world") + public void start( + @Param(name = "world", description = "The world to pregen", contextual = true) + World world, + @Param(name = "radius", description = "The radius of the pregen in blocks", aliases = "size") + int radius, + @Param(name = "center", aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0") + Vector center + ) { + try { + IrisToolbelt.pregenerate(PregenTask + .builder() + .center(new Position2(center)) + .width((radius >> 9 + 1) * 2) + .height((radius >> 9 + 1) * 2) + .build(), world); + sender().sendMessage(C.GREEN + "Successfully started the pregeneration task!"); + } catch (Throwable e) { + sender().sendMessage(C.RED + "Epic fail"); + Iris.reportError(e); + e.printStackTrace(); + } + } + + @Decree(description = "Stop the active pregeneration task", aliases = "x") + public void stop(){ + if (PregeneratorJob.shutdownInstance()) { + sender().sendMessage(C.GREEN + "Stopped pregeneration task"); + } else { + sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop"); + } + } + + @Decree(description = "Pause / continue the active pregeneration task", aliases = {"t", "resume", "unpause"}) + public void pause() { + if (PregeneratorJob.pauseResume()) { + sender().sendMessage(C.GREEN + "Paused/unpaused pregeneration task, now: " + (PregeneratorJob.isPaused() ? "Paused" : "Running") + "."); + } else { + sender().sendMessage(C.YELLOW + "No active pregeneration tasks to pause/unpause."); + } + } +} diff --git a/src/main/java/com/volmit/iris/util/math/Position2.java b/src/main/java/com/volmit/iris/util/math/Position2.java index c1cc093dc..560a254df 100644 --- a/src/main/java/com/volmit/iris/util/math/Position2.java +++ b/src/main/java/com/volmit/iris/util/math/Position2.java @@ -19,6 +19,7 @@ package com.volmit.iris.util.math; import com.volmit.iris.engine.object.basic.IrisPosition; +import org.bukkit.util.Vector; public class Position2 { private int x; @@ -29,6 +30,11 @@ public class Position2 { this.z = z; } + public Position2(Vector center) { + this.x = center.getBlockX(); + this.z = center.getBlockZ(); + } + public int getX() { return x; } From f1376be2e06c520f46da37b2a41882f77d5c3dd1 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 21:42:12 +0200 Subject: [PATCH 11/15] No mow wegen --- .../core/command/world/CommandIrisRegen.java | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/core/command/world/CommandIrisRegen.java diff --git a/src/main/java/com/volmit/iris/core/command/world/CommandIrisRegen.java b/src/main/java/com/volmit/iris/core/command/world/CommandIrisRegen.java deleted file mode 100644 index f90c6ac55..000000000 --- a/src/main/java/com/volmit/iris/core/command/world/CommandIrisRegen.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2021 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.volmit.iris.core.command.world; - -import com.volmit.iris.Iris; -import com.volmit.iris.util.collection.KList; -import com.volmit.iris.util.plugin.MortarCommand; -import com.volmit.iris.util.plugin.VolmitSender; - -public class CommandIrisRegen extends MortarCommand { - public CommandIrisRegen() { - super("regen"); - setDescription("Regenerate chunks around you (iris worlds only)"); - requiresPermission(Iris.perm.studio); - setCategory("Regen"); - } - - @Override - public void addTabOptions(VolmitSender sender, String[] args, KList list) { - - } - - @Override - public boolean handle(VolmitSender sender, String[] args) { - sender.sendMessage("Iris' /regen command is currently disabled due to maintenance. Apologies."); - return true; - /* This is commented yes - try - { - if(args.length == 0) - { - IrisWorlds.access(sender.player().getWorld()).regenerate( - sender.player().getLocation().getChunk().getX(), - sender.player().getLocation().getChunk().getZ()); - sender.sendMessage("Regenerated your current chunk"); - } - - else - { - try - { - int vx = sender.player().getLocation().getChunk().getX(); - int vz = sender.player().getLocation().getChunk().getZ(); - int rad = Integer.valueOf(args[0]); - int m = (int) Math.pow(rad, 2); - new Spiraler(rad, rad*2, (x,z) -> { - IrisWorlds.access(sender.player().getWorld()).regenerate( - vx + x, - vz + z); - }).drain(); - - sender.sendMessage("Regenerated " + m + " chunks"); - } - - catch(NumberFormatException e) - { - sender.sendMessage(args[0] + " is not a number."); - } - } - } - - catch(Throwable e1) - { - sender.sendMessage("You must be in a regen-capable iris world!"); - } - - return true; - */ - } - - @Override - protected String getArgsUsage() { - return "[size]"; - } -} From 376477767b6e33c6a3f25d9323ff87a22c40bbf5 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 21:46:39 +0200 Subject: [PATCH 12/15] no instance --- .../java/com/volmit/iris/core/command/world/CommandLocate.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/command/world/CommandLocate.java b/src/main/java/com/volmit/iris/core/command/world/CommandLocate.java index e290b2428..e88d436d4 100644 --- a/src/main/java/com/volmit/iris/core/command/world/CommandLocate.java +++ b/src/main/java/com/volmit/iris/core/command/world/CommandLocate.java @@ -31,7 +31,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import java.util.Arrays; public class CommandLocate extends MortarCommand implements Listener { - final CommandLocate instance; @EventHandler public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) { @@ -52,7 +51,6 @@ public class CommandLocate extends MortarCommand implements Listener { public CommandLocate() { super("locate"); requiresPermission(Iris.perm); - this.instance = this; } @Override From 3a7c8d660c5e2a1a476b5210293c9a51c5664c72 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 21:51:17 +0200 Subject: [PATCH 13/15] DecIrisWhat --- .../java/com/volmit/iris/core/decrees/DecIris.java | 2 ++ .../java/com/volmit/iris/core/decrees/DecIrisWhat.java | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java 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 ddc026966..1e3d7a686 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -40,6 +40,8 @@ public class DecIris implements DecreeExecutor private DecIrisPregen pregen; + private DecIrisWhat what; + @Decree(description = "Create a new world", aliases = "+") public void create( @Param(name = "name", aliases = "worldName", description = "The name of the world to create", defaultValue = "IrisWorld") diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java b/src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java new file mode 100644 index 000000000..ce50fac35 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java @@ -0,0 +1,10 @@ +package com.volmit.iris.core.decrees; + +import com.volmit.iris.util.decree.DecreeExecutor; +import com.volmit.iris.util.decree.DecreeOrigin; +import com.volmit.iris.util.decree.annotations.Decree; + +@Decree(name = "what", aliases = "?", description = "Get information about the world around you", origin = DecreeOrigin.PLAYER) +public class DecIrisWhat implements DecreeExecutor { + +} From 1fa828ad1a5e0d8a2a49976e6a47500633e9676c Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 22:08:43 +0200 Subject: [PATCH 14/15] Move files add what patches --- .../com/volmit/iris/core/decrees/DecIris.java | 11 ++-- .../volmit/iris/core/decrees/DecIrisWhat.java | 10 ---- .../{DecIrisPregen.java => DecPregen.java} | 2 +- .../{DecIrisStudio.java => DecStudio.java} | 4 +- .../com/volmit/iris/core/decrees/DecWhat.java | 59 +++++++++++++++++++ 5 files changed, 66 insertions(+), 20 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java rename src/main/java/com/volmit/iris/core/decrees/{DecIrisPregen.java => DecPregen.java} (97%) rename src/main/java/com/volmit/iris/core/decrees/{DecIrisStudio.java => DecStudio.java} (99%) create mode 100644 src/main/java/com/volmit/iris/core/decrees/DecWhat.java 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 1e3d7a686..a3cad59a7 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -26,25 +26,22 @@ 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.exceptions.IrisException; import com.volmit.iris.util.format.C; -import org.bukkit.World; import java.io.File; -import java.util.Objects; @Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command") public class DecIris implements DecreeExecutor { - private DecIrisStudio studio; + private DecStudio studio; - private DecIrisPregen pregen; + private DecPregen pregen; - private DecIrisWhat what; + private DecWhat what; @Decree(description = "Create a new world", aliases = "+") public void create( - @Param(name = "name", aliases = "worldName", description = "The name of the world to create", defaultValue = "IrisWorld") + @Param(name = "name", aliases = "world-name", description = "The name of the world to create", defaultValue = "IrisWorld") String name, @Param(name = "type", aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") IrisDimension type, diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java b/src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java deleted file mode 100644 index ce50fac35..000000000 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisWhat.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.volmit.iris.core.decrees; - -import com.volmit.iris.util.decree.DecreeExecutor; -import com.volmit.iris.util.decree.DecreeOrigin; -import com.volmit.iris.util.decree.annotations.Decree; - -@Decree(name = "what", aliases = "?", description = "Get information about the world around you", origin = DecreeOrigin.PLAYER) -public class DecIrisWhat implements DecreeExecutor { - -} diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIrisPregen.java b/src/main/java/com/volmit/iris/core/decrees/DecPregen.java similarity index 97% rename from src/main/java/com/volmit/iris/core/decrees/DecIrisPregen.java rename to src/main/java/com/volmit/iris/core/decrees/DecPregen.java index 0e9021029..6c2b5695a 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisPregen.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecPregen.java @@ -14,7 +14,7 @@ import org.bukkit.World; import org.bukkit.util.Vector; @Decree(name = "pregen", aliases = "pregenerate", description = "Pregenerate your Iris worlds!") -public class DecIrisPregen implements DecreeExecutor { +public class DecPregen implements DecreeExecutor { @Decree(description = "Pregenerate a world") public void start( @Param(name = "world", description = "The world to pregen", contextual = true) diff --git a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java b/src/main/java/com/volmit/iris/core/decrees/DecStudio.java similarity index 99% rename from src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java rename to src/main/java/com/volmit/iris/core/decrees/DecStudio.java index 70bbb5418..ab0fabfd9 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIrisStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecStudio.java @@ -76,7 +76,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 { +public class DecStudio 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") @@ -123,7 +123,7 @@ public class DecIrisStudio implements DecreeExecutor { @Param(name = "fix-ids", defaultValue = "true", description = "Fixes any block ids used such as \"dirt\" will be converted to \"minecraft:dirt\"") boolean fixIds, - @Param(name = "rewriteObjects", defaultValue = "false", description = "Imports all objects and re-writes them cleaning up positions & block data in the process.") + @Param(name = "rewrite-objects", defaultValue = "false", description = "Imports all objects and re-writes them cleaning up positions & block data in the process.") boolean rewriteObjects ) { KList jobs = new KList<>(); diff --git a/src/main/java/com/volmit/iris/core/decrees/DecWhat.java b/src/main/java/com/volmit/iris/core/decrees/DecWhat.java new file mode 100644 index 000000000..50e5815e8 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/decrees/DecWhat.java @@ -0,0 +1,59 @@ +package com.volmit.iris.core.decrees; + +import com.volmit.iris.Iris; +import com.volmit.iris.util.data.B; +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.format.C; +import org.bukkit.FluidCollisionMode; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; + +@Decree(name = "what", aliases = "?", description = "Get information about the world around you", origin = DecreeOrigin.PLAYER) +public class DecWhat implements DecreeExecutor { + + @Decree(description = "Get information about the block you're looking at") + public void block(){ + + Block b = player().getTargetBlockExact(128, FluidCollisionMode.NEVER); + + if (b == null) { + sender().sendMessage("Please look at any block, not at the sky"); + return; + } + + BlockData bd = b.getBlockData(); + + sender().sendMessage("Material: " + C.GREEN + bd.getMaterial().name()); + sender().sendMessage("Full: " + C.WHITE + bd.getAsString(true)); + + if (B.isStorage(bd)) { + sender().sendMessage(C.YELLOW + "* Storage Block (Loot Capable)"); + } + + if (B.isLit(bd)) { + sender().sendMessage(C.YELLOW + "* Lit Block (Light Capable)"); + } + + if (B.isFoliage(bd)) { + sender().sendMessage(C.YELLOW + "* Foliage Block"); + } + + if (B.isDecorant(bd)) { + sender().sendMessage(C.YELLOW + "* Decorant Block"); + } + + if (B.isFluid(bd)) { + sender().sendMessage(C.YELLOW + "* Fluid Block"); + } + + if (B.isFoliagePlantable(bd)) { + sender().sendMessage(C.YELLOW + "* Plantable Foliage Block"); + } + + if (B.isSolid(bd)) { + sender().sendMessage(C.YELLOW + "* Solid Block"); + } + } +} From 92ba038af7032a7937d0b728eeb6b6411643c2e6 Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 22:17:54 +0200 Subject: [PATCH 15/15] Remove name = where not needed --- .../com/volmit/iris/core/decrees/DecIris.java | 36 ++--- .../volmit/iris/core/decrees/DecPregen.java | 6 +- .../volmit/iris/core/decrees/DecStudio.java | 131 +++++++++--------- 3 files changed, 87 insertions(+), 86 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 a3cad59a7..2820c75bb 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -41,11 +41,11 @@ public class DecIris implements DecreeExecutor @Decree(description = "Create a new world", aliases = "+") public void create( - @Param(name = "name", aliases = "world-name", description = "The name of the world to create", defaultValue = "IrisWorld") + @Param(aliases = "world-name", description = "The name of the world to create", defaultValue = "IrisWorld") String name, - @Param(name = "type", aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") + @Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") IrisDimension type, - @Param(name = "seed", description = "The seed to generate the world with", defaultValue = "1337") + @Param(description = "The seed to generate the world with", defaultValue = "1337") long seed ){ if (name.equals("iris")) { @@ -84,11 +84,11 @@ public class DecIris implements DecreeExecutor @Decree(description = "Set aura spins") public void aura( - @Param(name = "h", description = "The h color value") + @Param(description = "The h color value") int h, - @Param(name = "s", description = "The s color value") + @Param(description = "The s color value") int s, - @Param(name = "b", description = "The b color value") + @Param(description = "The b color value") int b ) { IrisSettings.get().getGeneral().setSpinh(h); @@ -100,27 +100,27 @@ public class DecIris implements DecreeExecutor @Decree(description = "Bitwise calculations") public void bitwise( - @Param(name = "value1", description = "The first value to run calculations on") - int val1, - @Param(name = "operator", description = "The operator: | & ^ >> << %") + @Param(description = "The first value to run calculations on") + int value1, + @Param(description = "The operator: | & ^ >> << %") String operator, - @Param(name = "value2", description = "The second value to run calculations on") - int val2 + @Param(description = "The second value to run calculations on") + int value2 ) { Integer v = null; switch(operator) { - case "|" -> v = val1 | val2; - case "&" -> v = val1 & val2; - case "^" -> v = val1 ^ val2; - case "%" -> v = val1 % val2; - case ">>" -> v = val1 >> val2; - case "<<" -> v = val1 << val2; + case "|" -> v = value1 | value2; + case "&" -> v = value1 & value2; + case "^" -> v = value1 ^ value2; + case "%" -> v = value1 % value2; + case ">>" -> v = value1 >> value2; + case "<<" -> v = value1 << value2; }; if (v == null){ sender().sendMessage(C.RED + "The operator you entered: (" + operator + ") is invalid!"); return; } - sender().sendMessage(C.GREEN + "" + val1 + " " + operator + " " + val2 + " => " + v); + sender().sendMessage(C.GREEN + "" + value1 + " " + operator + " " + value2 + " => " + v); } @Decree(description = "Toggle debug") diff --git a/src/main/java/com/volmit/iris/core/decrees/DecPregen.java b/src/main/java/com/volmit/iris/core/decrees/DecPregen.java index 6c2b5695a..1a97ed063 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecPregen.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecPregen.java @@ -17,11 +17,11 @@ import org.bukkit.util.Vector; public class DecPregen implements DecreeExecutor { @Decree(description = "Pregenerate a world") public void start( - @Param(name = "world", description = "The world to pregen", contextual = true) + @Param(description = "The world to pregen", contextual = true) World world, - @Param(name = "radius", description = "The radius of the pregen in blocks", aliases = "size") + @Param(description = "The radius of the pregen in blocks", aliases = "size") int radius, - @Param(name = "center", aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0") + @Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0") Vector center ) { try { diff --git a/src/main/java/com/volmit/iris/core/decrees/DecStudio.java b/src/main/java/com/volmit/iris/core/decrees/DecStudio.java index ab0fabfd9..b53006d20 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecStudio.java @@ -79,9 +79,9 @@ import java.util.function.Supplier; public class DecStudio 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") + @Param(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") + @Param(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()); @@ -100,9 +100,9 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Create a new studio project", aliases = "+", sync = true) public void create( - @Param(name = "name", description = "The name of this new Iris Project.") + @Param(description = "The name of this new Iris Project.") String name, - @Param(name = "template", description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.", contextual = true) + @Param(description = "Copy the contents of an existing project in your packs folder and use it as a template in this new project.", contextual = true) IrisDimension template) { if (template != null) { @@ -114,10 +114,10 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Clean an Iris Project, optionally beautifying JSON & fixing block ids with missing keys. Also rebuilds the vscode schemas. ") public void clean( - @Param(name = "project", description = "The project to update", contextual = true) + @Param(description = "The project to update", contextual = true) IrisDimension project, - @Param(name = "beautify", defaultValue = "true", description = "Filters all valid JSON files with a beautifier (indentation: 4)") + @Param(defaultValue = "true", description = "Filters all valid JSON files with a beautifier (indentation: 4)") boolean beautify, @Param(name = "fix-ids", defaultValue = "true", description = "Fixes any block ids used such as \"dirt\" will be converted to \"minecraft:dirt\"") @@ -241,53 +241,9 @@ public class DecStudio implements DecreeExecutor { new JobCollection("Cleaning", jobs).execute(sender()); } - public void files(File clean, KList files) - { - if (clean.isDirectory()) { - for (File i : clean.listFiles()) { - files(i, files); - } - } else if (clean.getName().endsWith(".json")) { - try { - files.add(clean); - } catch (Throwable e) { - Iris.reportError(e); - Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!"); - } - } - } - - private void fixBlocks(JSONObject obj) { - 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); - } - - if (o instanceof JSONObject) { - fixBlocks((JSONObject) o); - } else if (o instanceof JSONArray) { - fixBlocks((JSONArray) o); - } - } - } - - private void fixBlocks(JSONArray obj) { - for (int i = 0; i < obj.length(); i++) { - Object o = obj.get(i); - - if (o instanceof JSONObject) { - fixBlocks((JSONObject) o); - } else if (o instanceof JSONArray) { - fixBlocks((JSONArray) o); - } - } - } - @Decree(description = "Get the version of a pack") public void version( - @Param(name = "dimension", defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim", contextual = true) + @Param(defaultValue = "overworld", description = "The dimension get the version of", aliases = "dim", contextual = true) IrisDimension dimension ) { sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion()); @@ -299,9 +255,9 @@ public class DecStudio implements DecreeExecutor { } - @Decree(description = "Edit the biome you're currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER) + @Decree(description = "Edit the biome you are currently in", aliases = {"ebiome", "eb"}, origin = DecreeOrigin.PLAYER) public void editbiome( - @Param(name = "biome", contextual = true, description = "The biome to edit") + @Param(contextual = true, description = "The biome to edit") IrisBiome biome ) { if (noStudio()) return; @@ -316,7 +272,7 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Execute a script", aliases = "run", origin = DecreeOrigin.PLAYER) public void execute( - @Param(name = "script", description = "The script to run") + @Param(description = "The script to run") IrisScript script ) { engine().getExecution().execute(script.getLoadKey()); @@ -336,9 +292,9 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Preview noise gens (External GUI)", aliases = {"generator", "gen"}) public void explore( - @Param(name = "generator", description = "The generator to explore", contextual = true) + @Param(description = "The generator to explore", contextual = true) IrisGenerator generator, - @Param(name = "seed", description = "The seed to generate with", defaultValue = "12345") + @Param(description = "The seed to generate with", defaultValue = "12345") long seed ){ if (noGUI()) return; @@ -357,9 +313,9 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Find any biome or region", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) public void find( - @Param(name = "biome", description = "The biome to find") + @Param(description = "The biome to find") IrisBiome biome, - @Param(name = "region", description = "The region to find") + @Param(description = "The region to find") IrisRegion region ){ if (!IrisToolbelt.isIrisWorld(world())){ @@ -409,9 +365,9 @@ public class DecStudio implements DecreeExecutor { @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") + @Param(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") + @Param(description = "Whether or not to append to the inventory currently open (if false, clears opened inventory)", defaultValue = "true") boolean add ) { if (noStudio()) return; @@ -473,9 +429,9 @@ public class DecStudio implements DecreeExecutor { Iris.proj.compilePackage(sender(), dimension.getLoadKey(), obfuscate, minify); } - @Decree(description = "Profiles a dimension's performance", origin = DecreeOrigin.PLAYER) + @Decree(description = "Profiles the performance of a dimension", origin = DecreeOrigin.PLAYER) public void profile( - @Param(name = "dimension", description = "The dimension to profile", contextual = true) + @Param(description = "The dimension to profile", contextual = true) IrisDimension dimension ){ File pack = dimension.getLoadFile().getParentFile().getParentFile(); @@ -663,7 +619,7 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER) public void summon( - @Param(description = "The Iris Entity to spawn", name = "entity") + @Param(description = "The Iris Entity to spawn") IrisEntity entity ) { if (!sender().isPlayer()){ @@ -697,7 +653,7 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Update your dimension project") public void update( - @Param(name = "dimension", description = "The dimension to update the workspace of", contextual = true) + @Param(description = "The dimension to update the workspace of", contextual = true) IrisDimension dimension ){ if (new IrisProject(dimension.getLoadFile().getParentFile().getParentFile()).updateWorkspace()) { @@ -707,7 +663,6 @@ public class DecStudio implements DecreeExecutor { } } - /** * @return true if server GUIs are not enabled */ @@ -737,4 +692,50 @@ public class DecStudio implements DecreeExecutor { } return false; } + + + + public void files(File clean, KList files) + { + if (clean.isDirectory()) { + for (File i : clean.listFiles()) { + files(i, files); + } + } else if (clean.getName().endsWith(".json")) { + try { + files.add(clean); + } catch (Throwable e) { + Iris.reportError(e); + Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!"); + } + } + } + + private void fixBlocks(JSONObject obj) { + 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); + } + + if (o instanceof JSONObject) { + fixBlocks((JSONObject) o); + } else if (o instanceof JSONArray) { + fixBlocks((JSONArray) o); + } + } + } + + private void fixBlocks(JSONArray obj) { + for (int i = 0; i < obj.length(); i++) { + Object o = obj.get(i); + + if (o instanceof JSONObject) { + fixBlocks((JSONObject) o); + } else if (o instanceof JSONArray) { + fixBlocks((JSONArray) o); + } + } + } }