From 85fbaa2b976dc267ef888e19f91bbb61cab3b8cc Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Mon, 16 Aug 2021 23:17:17 +0200 Subject: [PATCH] Iris What --- .../command/what/CommandIrisWhatBlock.java | 29 ------ .../volmit/iris/core/decrees/DecStudio.java | 91 +++++++++++++++++++ .../com/volmit/iris/core/decrees/DecWhat.java | 59 ------------ 3 files changed, 91 insertions(+), 88 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/core/decrees/DecWhat.java diff --git a/src/main/java/com/volmit/iris/core/command/what/CommandIrisWhatBlock.java b/src/main/java/com/volmit/iris/core/command/what/CommandIrisWhatBlock.java index 818d1ecb3..703356f31 100644 --- a/src/main/java/com/volmit/iris/core/command/what/CommandIrisWhatBlock.java +++ b/src/main/java/com/volmit/iris/core/command/what/CommandIrisWhatBlock.java @@ -55,36 +55,7 @@ public class CommandIrisWhatBlock extends MortarCommand { } if (bd != null) { - 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"); - } } } else { sender.sendMessage("Players only."); 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 b53006d20..aa326ea9e 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecStudio.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecStudio.java @@ -41,6 +41,7 @@ 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; +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; @@ -64,7 +65,11 @@ import com.volmit.iris.util.scheduling.jobs.JobCollection; import com.volmit.iris.util.scheduling.jobs.QueueJob; import com.volmit.iris.util.scheduling.jobs.SingleJob; import org.bukkit.Bukkit; +import org.bukkit.FluidCollisionMode; import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; @@ -663,6 +668,92 @@ public class DecStudio implements DecreeExecutor { } } + @Decree(description = "Get information about the world around you", origin = DecreeOrigin.PLAYER) + public void what( + @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 + ){ + // Data + BlockData handHeld = player().getInventory().getItemInMainHand().getType().createBlockData(); + Block targetBlock = player().getTargetBlockExact(128, FluidCollisionMode.NEVER); + BlockData targetBlockData; + if (targetBlock == null) { + targetBlockData = null; + } else { + targetBlockData = targetBlock.getBlockData(); + } + IrisBiome currentBiome = engine().getBiome(player().getLocation()); + IrisRegion currentRegion = engine().getRegion(player().getLocation()); + IrisDimension currentDimension = engine().getDimension(); + + // Biome, region & dimension + if (dimension) { + sender().sendMessage(C.GREEN + "" + C.BOLD + "Current dimension:" + C.RESET + "" + C.WHITE + currentDimension.getName()); + } + if (region) { + sender().sendMessage(C.GREEN + "" + C.BOLD + "Current region:" + C.RESET + "" + C.WHITE + currentRegion.getName()); + } + if (biome) { + sender().sendMessage(C.GREEN + "" + C.BOLD + "Current biome:" + C.RESET + "" + C.WHITE + currentBiome.getName()); + } + + // Target + if (targetBlockData == null){ + sender().sendMessage(C.RED + "Not looking at any block"); + } else if (look) { + sender().sendMessage(C.GREEN + "" + C.BOLD + "Looked-at block information"); + + sender().sendMessage("Material: " + C.GREEN + targetBlockData.getMaterial().name()); + sender().sendMessage("Full: " + C.WHITE + targetBlockData.getAsString(true)); + + if (B.isStorage(targetBlockData)) { + sender().sendMessage(C.YELLOW + "* Storage Block (Loot Capable)"); + } + + if (B.isLit(targetBlockData)) { + sender().sendMessage(C.YELLOW + "* Lit Block (Light Capable)"); + } + + if (B.isFoliage(targetBlockData)) { + sender().sendMessage(C.YELLOW + "* Foliage Block"); + } + + if (B.isDecorant(targetBlockData)) { + sender().sendMessage(C.YELLOW + "* Decorant Block"); + } + + if (B.isFluid(targetBlockData)) { + sender().sendMessage(C.YELLOW + "* Fluid Block"); + } + + if (B.isFoliagePlantable(targetBlockData)) { + sender().sendMessage(C.YELLOW + "* Plantable Foliage Block"); + } + + if (B.isSolid(targetBlockData)) { + sender().sendMessage(C.YELLOW + "* Solid Block"); + } + } + + // Hand-held + if (!handHeld.getMaterial().equals(Material.AIR)) { + sender().sendMessage(C.YELLOW + "No block held"); + } else if (hand) { + sender().sendMessage(C.GREEN + "" + C.BOLD + "Hand-held block information"); + + sender().sendMessage("Material: " + C.GREEN + handHeld.getMaterial().name()); + sender().sendMessage("Full: " + C.WHITE + handHeld.getAsString(true)); + } + } + /** * @return true if server GUIs are not enabled */ diff --git a/src/main/java/com/volmit/iris/core/decrees/DecWhat.java b/src/main/java/com/volmit/iris/core/decrees/DecWhat.java deleted file mode 100644 index 50e5815e8..000000000 --- a/src/main/java/com/volmit/iris/core/decrees/DecWhat.java +++ /dev/null @@ -1,59 +0,0 @@ -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"); - } - } -}