mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Fix what command
This commit is contained in:
parent
63b5545502
commit
93f2c83c0e
@ -38,19 +38,17 @@ import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
|
||||
public class DecIris implements DecreeExecutor {
|
||||
private DecStudio studio;
|
||||
|
||||
private DecPregen pregen;
|
||||
|
||||
private DecSettings settings;
|
||||
|
||||
private DecObject object;
|
||||
private DecWhat what;
|
||||
|
||||
@Decree(description = "Create a new world", aliases = "+")
|
||||
public void create(
|
||||
@ -146,104 +144,6 @@ public class DecIris implements DecreeExecutor {
|
||||
sender().sendMessage(C.GREEN + "Set debug to: " + to);
|
||||
}
|
||||
|
||||
@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
|
||||
) {
|
||||
if (engine() == null) {
|
||||
sender().sendMessage(C.RED + "You must be in an Iris world!");
|
||||
return;
|
||||
}
|
||||
// Data
|
||||
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) {
|
||||
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 == null){
|
||||
return;
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "Download a project.", aliases = "dl")
|
||||
public void download(
|
||||
@Param(name = "pack", description = "The pack to download", defaultValue = "overworld", aliases = "project")
|
||||
|
150
src/main/java/com/volmit/iris/core/decrees/DecWhat.java
Normal file
150
src/main/java/com/volmit/iris/core/decrees/DecWhat.java
Normal file
@ -0,0 +1,150 @@
|
||||
package com.volmit.iris.core.decrees;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
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;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.common.IObjectPlacer;
|
||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.objects.IrisObject;
|
||||
import com.volmit.iris.engine.object.objects.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.object.objects.IrisObjectPlacementScaleInterpolator;
|
||||
import com.volmit.iris.engine.object.objects.IrisObjectRotation;
|
||||
import com.volmit.iris.engine.object.tile.TileData;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.data.Cuboid;
|
||||
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.decree.specialhandlers.ObjectHandler;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.math.Direction;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.Queue;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Decree(name = "what", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris What?")
|
||||
public class DecWhat implements DecreeExecutor {
|
||||
@Decree(description = "What is in my hand?", origin = DecreeOrigin.PLAYER)
|
||||
public void hand() {
|
||||
try {
|
||||
BlockData bd = player().getInventory().getItemInMainHand().getType().createBlockData();
|
||||
if (!bd.getMaterial().equals(Material.AIR)) {
|
||||
sender().sendMessage("Material: " + C.GREEN + bd.getMaterial().name());
|
||||
sender().sendMessage("Full: " + C.WHITE + bd.getAsString(true));
|
||||
} else {
|
||||
sender().sendMessage("Please hold a block/item");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Material bd = player().getInventory().getItemInMainHand().getType();
|
||||
if (!bd.equals(Material.AIR)) {
|
||||
sender().sendMessage("Material: " + C.GREEN + bd.name());
|
||||
} else {
|
||||
sender().sendMessage("Please hold a block/item");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "What biome am i in?", origin = DecreeOrigin.PLAYER)
|
||||
public void biome() {
|
||||
try {
|
||||
IrisBiome b = engine().getBiome(player().getLocation().getBlockX(), player().getLocation().getBlockY(), player().getLocation().getBlockZ());
|
||||
sender().sendMessage("IBiome: " + b.getLoadKey() + " (" + b.getDerivative().name() + ")");
|
||||
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
sender().sendMessage("Non-Iris Biome: " + player().getLocation().getBlock().getBiome().name());
|
||||
|
||||
if (player().getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) {
|
||||
try {
|
||||
sender().sendMessage("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 = "What block am i looking at?", origin = DecreeOrigin.PLAYER)
|
||||
public void block() {
|
||||
BlockData bd;
|
||||
try {
|
||||
bd = player().getTargetBlockExact(128, FluidCollisionMode.NEVER).getBlockData();
|
||||
} catch (NullPointerException e) {
|
||||
Iris.reportError(e);
|
||||
sender().sendMessage("Please look at any block, not at the sky");
|
||||
bd = null;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "What features am i near?", origin = DecreeOrigin.PLAYER)
|
||||
public void features() {
|
||||
Chunk c = player().getLocation().getChunk();
|
||||
|
||||
if (IrisToolbelt.isIrisWorld(c.getWorld())) {
|
||||
int m = 1;
|
||||
for (IrisFeaturePositional i : IrisToolbelt.access(c.getWorld()).getEngine().getMantle().forEachFeature(c)) {
|
||||
sender().sendMessage("#" + m++ + " " + new JSONObject(new Gson().toJson(i)).toString(4));
|
||||
}
|
||||
} else {
|
||||
sender().sendMessage("Iris worlds only.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user