diff --git a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java index 452297be6..d263c26c8 100644 --- a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java +++ b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectPaste.java @@ -21,6 +21,7 @@ package com.volmit.iris.core.command.object; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.loader.IrisData; +import com.volmit.iris.core.service.ObjectSVC; import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.WandSVC; import com.volmit.iris.core.tools.IrisToolbelt; 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 5976f97fe..057580bef 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecIris.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecIris.java @@ -136,8 +136,9 @@ public class DecIris implements DecreeExecutor { @Param(name = "on", description = "Whether or not debug should be on", defaultValue = "other") Boolean on ) { - IrisSettings.get().getGeneral().setDebug(Objects.requireNonNullElseGet(on, () -> !IrisSettings.get().getGeneral().isDebug())); - sender().sendMessage(); + boolean to = on == null ? !IrisSettings.get().getGeneral().isDebug() : on; + IrisSettings.get().getGeneral().setDebug(to); + sender().sendMessage(C.GREEN + "Set debug to: " + to); } @Decree(description = "Download a project.", aliases = "dl") diff --git a/src/main/java/com/volmit/iris/core/decrees/DecObject.java b/src/main/java/com/volmit/iris/core/decrees/DecObject.java index f6f658b1b..3da95e599 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecObject.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecObject.java @@ -1,7 +1,9 @@ package com.volmit.iris.core.decrees; -import com.volmit.iris.core.command.object.CommandIrisObjectUndo; +import com.volmit.iris.Iris; import com.volmit.iris.core.loader.IrisData; +import com.volmit.iris.core.service.ObjectSVC; +import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.WandSVC; import com.volmit.iris.engine.object.common.IObjectPlacer; import com.volmit.iris.engine.object.dimensional.IrisDimension; @@ -26,6 +28,7 @@ import org.bukkit.block.BlockState; import org.bukkit.block.TileState; import org.bukkit.block.data.BlockData; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; import java.io.File; import java.io.IOException; @@ -188,7 +191,7 @@ public class DecObject implements DecreeExecutor { private static final Set skipBlocks = Set.of(Material.GRASS, Material.SNOW, Material.VINE, Material.TORCH, Material.DEAD_BUSH, Material.POPPY, Material.DANDELION); - @Decree(description = "Paste an object") + @Decree(description = "Paste an object", sync = true) public void paste( @Param(description = "The object to paste", customHandler = ObjectHandler.class) String object, @@ -382,4 +385,95 @@ public class DecObject implements DecreeExecutor { service.revertChanges(actualReverts); sender().sendMessage("Reverted " + actualReverts + " pastes!"); } + + @Decree(description = "Get an object wand", sync = true) + public void wand() { + player().getInventory().addItem(WandSVC.createWand()); + sender().playSound(Sound.ITEM_ARMOR_EQUIP_NETHERITE, 1f, 1.5f); + sender().sendMessage(C.GREEN + "Poof! Good luck building!"); + } + + @Decree(name = "x&y", description = "Autoselect up, down & out", sync = true) + public void xay(){ + if (!WandSVC.isHoldingWand(player())){ + sender().sendMessage(C.YELLOW + "Hold your wand!"); + return; + } + + Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand()); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Location a1x = b[0].clone(); + Location a2x = b[1].clone(); + Cuboid cursor = new Cuboid(a1, a2); + Cuboid cursorx = new Cuboid(a1, a2); + + while (!cursor.containsOnly(Material.AIR)) { + a1.add(new org.bukkit.util.Vector(0, 1, 0)); + a2.add(new org.bukkit.util.Vector(0, 1, 0)); + cursor = new Cuboid(a1, a2); + } + + a1.add(new org.bukkit.util.Vector(0, -1, 0)); + a2.add(new org.bukkit.util.Vector(0, -1, 0)); + + while (!cursorx.containsOnly(Material.AIR)) { + a1x.add(new org.bukkit.util.Vector(0, -1, 0)); + a2x.add(new org.bukkit.util.Vector(0, -1, 0)); + cursorx = new Cuboid(a1x, a2x); + } + + a1x.add(new org.bukkit.util.Vector(0, 1, 0)); + a2x.add(new Vector(0, 1, 0)); + b[0] = a1; + b[1] = a2x; + cursor = new Cuboid(b[0], b[1]); + cursor = cursor.contract(Cuboid.CuboidDirection.North); + cursor = cursor.contract(Cuboid.CuboidDirection.South); + cursor = cursor.contract(Cuboid.CuboidDirection.East); + cursor = cursor.contract(Cuboid.CuboidDirection.West); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + player().getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1])); + player().updateInventory(); + sender().playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f); + sender().sendMessage(C.GREEN + "Auto-select complete!"); + } + + @Decree(name = "x+y", description = "Autoselect up & out", sync = true) + public void xpy() { + if (!WandSVC.isHoldingWand(player())) { + sender().sendMessage(C.YELLOW + "Hold your wand!"); + return; + } + + Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand()); + b[0].add(new Vector(0, 1, 0)); + b[1].add(new Vector(0, 1, 0)); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Cuboid cursor = new Cuboid(a1, a2); + + while (!cursor.containsOnly(Material.AIR)) { + a1.add(new Vector(0, 1, 0)); + a2.add(new Vector(0, 1, 0)); + cursor = new Cuboid(a1, a2); + } + + a1.add(new Vector(0, -1, 0)); + a2.add(new Vector(0, -1, 0)); + b[0] = a1; + a2 = b[1]; + cursor = new Cuboid(a1, a2); + cursor = cursor.contract(Cuboid.CuboidDirection.North); + cursor = cursor.contract(Cuboid.CuboidDirection.South); + cursor = cursor.contract(Cuboid.CuboidDirection.East); + cursor = cursor.contract(Cuboid.CuboidDirection.West); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + player().getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1])); + player().updateInventory(); + sender().playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f); + sender().sendMessage(C.GREEN + "Auto-select complete!"); + } } 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 00d9505aa..b117652e8 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecStudio.java @@ -92,7 +92,16 @@ public class DecStudio implements DecreeExecutor { Iris.service(StudioSVC.class).open(sender(), seed, dimension.getLoadKey()); } - @Decree(description = "Close an open studio project", aliases = "x", sync = true) + @Decree(description = "Open VSCode for a dimension", aliases = {"vsc", "edit"}) + public void vscode( + @Param(defaultValue = "overworld", description = "The dimension to open VSCode for", aliases = "dim") + IrisDimension dimension + ) { + sender().sendMessage(C.GREEN + "Opening VSCode for the \"" + dimension.getName() + "\" pack"); + Iris.service(StudioSVC.class).openVSCode(sender(), dimension.getLoadKey()); + } + + @Decree(description = "Close an open studio project", aliases = {"x", "c"}, sync = true) public void close() { if (!Iris.service(StudioSVC.class).isProjectOpen()) { sender().sendMessage(C.RED + "No open studio projects."); @@ -317,9 +326,9 @@ public class DecStudio implements DecreeExecutor { @Decree(description = "Find any biome or region", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER) public void find( - @Param(description = "The biome to find", contextual = true) + @Param(description = "The biome or region to find", defaultValue = "null") IrisBiome biome, - @Param(description = "The region to find", contextual = true) + @Param(description = "The region to find", defaultValue = "null") IrisRegion region ) { if (!IrisToolbelt.isIrisWorld(world())) { @@ -328,35 +337,45 @@ public class DecStudio implements DecreeExecutor { } if (biome == null && region == null) { - sender().sendMessage(C.RED + "You must specify a biome or region!"); + sender().sendMessage(C.RED + "You must specify a biome= or region=!"); return; } - IrisPosition l = null; + IrisPosition regionPosition = 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) { + regionPosition = 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 (regionPosition == 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) { + IrisPosition biomePosition = null; + if (biome != null) { + biomePosition = 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 (biomePosition == 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 + "Could not find the region and / or biome you specified."); - return; + if (regionPosition == null && region != null) { + sender().sendMessage(C.RED + "Could not find the region you specified."); + } else if (regionPosition != null){ + sender().sendMessage(C.GREEN + "Found the region at: " + regionPosition.toString()); + } + if (biomePosition == null && biome != null) { + sender().sendMessage(C.RED + "Could not find the biome you specified."); + } else if (biomePosition != null){ + sender().sendMessage(C.GREEN + "Found the biome at: " + biomePosition.toString()); } - final IrisPosition finalL = l; + final IrisPosition finalL = regionPosition == null ? biomePosition : regionPosition; + if (finalL == null) { + return; + } J.s(() -> player().teleport(finalL.toLocation(world()))); } @@ -365,6 +384,7 @@ public class DecStudio implements DecreeExecutor { if (noStudio()) return; access().hotload(); + sender().sendMessage(C.GREEN + "Hotloaded"); } @Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER, sync = true) @@ -681,8 +701,17 @@ public class DecStudio implements DecreeExecutor { @Param(description = "Whether or not to show information about the block you are holding", defaultValue = "true") boolean hand ) { + if (engine() == null) { + sender().sendMessage(C.RED + "You must be in an Iris world!"); + return; + } // Data - BlockData handHeld = player().getInventory().getItemInMainHand().getType().createBlockData(); + BlockData handHeld = null; + try { + handHeld = player().getInventory().getItemInMainHand().getType().createBlockData(); + } catch (Throwable e) { + sender().sendMessage("Could not get data for hand-held item"); + } Block targetBlock = player().getTargetBlockExact(128, FluidCollisionMode.NEVER); BlockData targetBlockData; if (targetBlock == null) { @@ -744,6 +773,9 @@ public class DecStudio implements DecreeExecutor { } // Hand-held + if (handHeld == null){ + return; + } if (!handHeld.getMaterial().equals(Material.AIR)) { sender().sendMessage(C.YELLOW + "No block held"); } else if (hand) { diff --git a/src/main/java/com/volmit/iris/core/decrees/DecWhat.java b/src/main/java/com/volmit/iris/core/decrees/DecWhat.java index 7401f85f4..2349ab703 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecWhat.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecWhat.java @@ -16,6 +16,7 @@ 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.decree.annotations.Param; import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.Form; import com.volmit.iris.util.json.JSONObject; @@ -44,66 +45,6 @@ import java.util.Objects; @Decree(name = "what", aliases = "?", description = "Find information on the world around you", origin = DecreeOrigin.PLAYER) public class DecWhat implements DecreeExecutor { - @Decree(description = "Get information about the biome your are currently in") - public void biome() { - if (IrisToolbelt.isIrisWorld(player().getWorld())) { - IrisBiome b = engine().getBiome(player().getLocation()); - sender().sendMessage(C.GREEN + "IrisBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")"); - } else { - sender().sendMessage(C.YELLOW + "Non-Iris Biome: " + player().getLocation().getBlock().getBiome().name()); - if (player().getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) { - try { - sender().sendMessage(C.YELLOW + "Data Pack Biome: " + INMS.get().getTrueBiomeBaseKey(player().getLocation()) + " (ID: " + INMS.get().getTrueBiomeBaseId(INMS.get().getTrueBiomeBase(player().getLocation())) + ")"); - } catch (Throwable ee) { - Iris.reportError(ee); - } - } - } - } - - @Decree(description = "Get information about the block you are looking at") - public void block() { - Block target = player().getTargetBlockExact(128, FluidCollisionMode.NEVER); - if (target == null) { - sender().sendMessage(C.YELLOW + "Please look at a block, not at the sky"); - return; - } - - BlockData bd = target.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"); - } - } - @Decree(aliases = "nf", description = "Get the noise feature data in your chunk") public void features() { @@ -119,18 +60,20 @@ public class DecWhat implements DecreeExecutor { } } - @Decree(description = "Get information about the item you are holding", sync = true) - public void hand() { - BlockData bd = player().getInventory().getItemInMainHand().getType().createBlockData(); - - if (bd.getMaterial().equals(Material.AIR)){ - sender().sendMessage(C.YELLOW + "Please hold a block/item"); - return; - } - - sender().sendMessage("Material: " + C.GREEN + bd.getMaterial().name()); - sender().sendMessage("Full: " + C.WHITE + bd.getAsString(true)); - + @Decree(description = "Get information about the world around you", aliases = "location", studio = true) + public void me( + @Param(description = "Whether or not to show dimension information", defaultValue = "true") + boolean dimension, + @Param(description = "Whether or not to show region information", defaultValue = "true") + boolean region, + @Param(description = "Whether or not to show biome information", defaultValue = "true") + boolean biome, + @Param(description = "Whether or not to show information about the block you are looking at", defaultValue = "true") + boolean look, + @Param(description = "Whether or not to show information about the block you are holding", defaultValue = "true") + boolean hand + ) { + new DecStudio().what(dimension, region, biome, look, hand); } @Decree(aliases = "capture", description = "Get information about nearby structures") diff --git a/src/main/java/com/volmit/iris/core/project/IrisProject.java b/src/main/java/com/volmit/iris/core/project/IrisProject.java index 654cbd0bc..1ee3f5b0a 100644 --- a/src/main/java/com/volmit/iris/core/project/IrisProject.java +++ b/src/main/java/com/volmit/iris/core/project/IrisProject.java @@ -106,25 +106,9 @@ public class IrisProject { }); } - public void open(VolmitSender sender, long seed, Consumer onDone) throws IrisException { - if (isOpen()) { - close(); - } - - boolean hasError = false; - - if (hasError) { - return; - } + public void openVSCode(VolmitSender sender) { IrisDimension d = IrisData.loadAnyDimension(getName()); - if (d == null) { - sender.sendMessage("Can't find dimension: " + getName()); - return; - } else if (sender.isPlayer()) { - sender.player().setGameMode(GameMode.SPECTATOR); - } - J.attemptAsync(() -> { try { @@ -171,6 +155,28 @@ public class IrisProject { e.printStackTrace(); } }); + } + + public void open(VolmitSender sender, long seed, Consumer onDone) throws IrisException { + if (isOpen()) { + close(); + } + + boolean hasError = false; + + if (hasError) { + return; + } + + IrisDimension d = IrisData.loadAnyDimension(getName()); + if (d == null) { + sender.sendMessage("Can't find dimension: " + getName()); + return; + } else if (sender.isPlayer()) { + sender.player().setGameMode(GameMode.SPECTATOR); + } + + openVSCode(sender); J.a(() -> { diff --git a/src/main/java/com/volmit/iris/core/service/StudioSVC.java b/src/main/java/com/volmit/iris/core/service/StudioSVC.java index aad2a367e..0e67227c2 100644 --- a/src/main/java/com/volmit/iris/core/service/StudioSVC.java +++ b/src/main/java/com/volmit/iris/core/service/StudioSVC.java @@ -323,8 +323,7 @@ public class StudioSVC implements IrisService { public void open(VolmitSender sender, long seed, String dimm) { try { - open(sender, seed, dimm, (w) -> { - }); + open(sender, seed, dimm, (w) -> {}); } catch (Exception e) { Iris.reportError(e); sender.sendMessage("Error when creating studio world:"); @@ -342,6 +341,10 @@ public class StudioSVC implements IrisService { project.open(sender, seed, onDone); } + public void openVSCode(VolmitSender sender, String dim) { + new IrisProject(new File(getWorkspaceFolder(), dim)).openVSCode(sender); + } + public File getWorkspaceFolder(String... sub) { return Iris.instance.getDataFolderList(WORKSPACE_NAME, sub); } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java index d142cea4d..1f03ae93f 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/BiomeHandler.java @@ -56,6 +56,9 @@ public class BiomeHandler implements DecreeParameterHandler { @Override public IrisBiome parse(String in) throws DecreeParsingException, DecreeWhichException { + if (in.equals("null")) { + return null; + } try { KList options = getPossibilities(in); diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java index 8f205af9a..36e80a83b 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/RegionHandler.java @@ -56,6 +56,9 @@ public class RegionHandler implements DecreeParameterHandler { @Override public IrisRegion parse(String in) throws DecreeParsingException, DecreeWhichException { + if (in.equals("null")) { + return null; + } try { KList options = getPossibilities(in); diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java index de7438c5e..1f79f4248 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/WorldHandler.java @@ -28,7 +28,13 @@ import org.bukkit.World; public class WorldHandler implements DecreeParameterHandler { @Override public KList getPossibilities() { - return new KList<>(Bukkit.getWorlds()); + KList options = new KList<>(); + for (World world : Bukkit.getWorlds()) { + if (!world.getName().toLowerCase().startsWith("iris/")){ + options.add(world); + } + } + return options; } @Override