Update Commands with patches

This commit is contained in:
CocoTheOwner 2021-08-28 17:59:56 +02:00
parent cf1f3677ae
commit 0465d047e7
10 changed files with 203 additions and 111 deletions

View File

@ -21,6 +21,7 @@ package com.volmit.iris.core.command.object;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.loader.IrisData; 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.StudioSVC;
import com.volmit.iris.core.service.WandSVC; import com.volmit.iris.core.service.WandSVC;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;

View File

@ -136,8 +136,9 @@ public class DecIris implements DecreeExecutor {
@Param(name = "on", description = "Whether or not debug should be on", defaultValue = "other") @Param(name = "on", description = "Whether or not debug should be on", defaultValue = "other")
Boolean on Boolean on
) { ) {
IrisSettings.get().getGeneral().setDebug(Objects.requireNonNullElseGet(on, () -> !IrisSettings.get().getGeneral().isDebug())); boolean to = on == null ? !IrisSettings.get().getGeneral().isDebug() : on;
sender().sendMessage(); IrisSettings.get().getGeneral().setDebug(to);
sender().sendMessage(C.GREEN + "Set debug to: " + to);
} }
@Decree(description = "Download a project.", aliases = "dl") @Decree(description = "Download a project.", aliases = "dl")

View File

@ -1,7 +1,9 @@
package com.volmit.iris.core.decrees; 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.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.service.WandSVC;
import com.volmit.iris.engine.object.common.IObjectPlacer; import com.volmit.iris.engine.object.common.IObjectPlacer;
import com.volmit.iris.engine.object.dimensional.IrisDimension; 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.TileState;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -188,7 +191,7 @@ public class DecObject implements DecreeExecutor {
private static final Set<Material> skipBlocks = Set.of(Material.GRASS, Material.SNOW, Material.VINE, Material.TORCH, Material.DEAD_BUSH, private static final Set<Material> skipBlocks = Set.of(Material.GRASS, Material.SNOW, Material.VINE, Material.TORCH, Material.DEAD_BUSH,
Material.POPPY, Material.DANDELION); Material.POPPY, Material.DANDELION);
@Decree(description = "Paste an object") @Decree(description = "Paste an object", sync = true)
public void paste( public void paste(
@Param(description = "The object to paste", customHandler = ObjectHandler.class) @Param(description = "The object to paste", customHandler = ObjectHandler.class)
String object, String object,
@ -382,4 +385,95 @@ public class DecObject implements DecreeExecutor {
service.revertChanges(actualReverts); service.revertChanges(actualReverts);
sender().sendMessage("Reverted " + actualReverts + " pastes!"); 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!");
}
} }

View File

@ -92,7 +92,16 @@ public class DecStudio implements DecreeExecutor {
Iris.service(StudioSVC.class).open(sender(), seed, dimension.getLoadKey()); 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() { public void close() {
if (!Iris.service(StudioSVC.class).isProjectOpen()) { if (!Iris.service(StudioSVC.class).isProjectOpen()) {
sender().sendMessage(C.RED + "No open studio projects."); 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) @Decree(description = "Find any biome or region", aliases = {"goto", "g"}, origin = DecreeOrigin.PLAYER)
public void find( public void find(
@Param(description = "The biome to find", contextual = true) @Param(description = "The biome or region to find", defaultValue = "null")
IrisBiome biome, IrisBiome biome,
@Param(description = "The region to find", contextual = true) @Param(description = "The region to find", defaultValue = "null")
IrisRegion region IrisRegion region
) { ) {
if (!IrisToolbelt.isIrisWorld(world())) { if (!IrisToolbelt.isIrisWorld(world())) {
@ -328,35 +337,45 @@ public class DecStudio implements DecreeExecutor {
} }
if (biome == null && region == null) { 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; return;
} }
IrisPosition l = null; IrisPosition regionPosition = null;
if (region != 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")); 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 (l == null) { if (regionPosition == null) {
sender().sendMessage(C.YELLOW + "Couldn't find the " + region.getName() + " region."); sender().sendMessage(C.YELLOW + "Couldn't find the " + region.getName() + " region.");
} else { } else {
sender().sendMessage(C.GREEN + "Found the " + region.getName() + " region!."); sender().sendMessage(C.GREEN + "Found the " + region.getName() + " region!.");
} }
} }
if (l == null && biome != null) { IrisPosition biomePosition = 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 (biome != null) {
if (l == 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."); sender().sendMessage(C.YELLOW + "Couldn't find the " + biome.getName() + " biome.");
} else { } else {
sender().sendMessage(C.GREEN + "Found the " + biome.getName() + " biome!."); sender().sendMessage(C.GREEN + "Found the " + biome.getName() + " biome!.");
} }
} }
if (l == null) { if (regionPosition == null && region != null) {
sender().sendMessage(C.RED + "Could not find the region and / or biome you specified."); sender().sendMessage(C.RED + "Could not find the region you specified.");
return; } 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()))); J.s(() -> player().teleport(finalL.toLocation(world())));
} }
@ -365,6 +384,7 @@ public class DecStudio implements DecreeExecutor {
if (noStudio()) return; if (noStudio()) return;
access().hotload(); access().hotload();
sender().sendMessage(C.GREEN + "Hotloaded");
} }
@Decree(description = "Show loot if a chest were right here", origin = DecreeOrigin.PLAYER, sync = true) @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") @Param(description = "Whether or not to show information about the block you are holding", defaultValue = "true")
boolean hand boolean hand
) { ) {
if (engine() == null) {
sender().sendMessage(C.RED + "You must be in an Iris world!");
return;
}
// Data // 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); Block targetBlock = player().getTargetBlockExact(128, FluidCollisionMode.NEVER);
BlockData targetBlockData; BlockData targetBlockData;
if (targetBlock == null) { if (targetBlock == null) {
@ -744,6 +773,9 @@ public class DecStudio implements DecreeExecutor {
} }
// Hand-held // Hand-held
if (handHeld == null){
return;
}
if (!handHeld.getMaterial().equals(Material.AIR)) { if (!handHeld.getMaterial().equals(Material.AIR)) {
sender().sendMessage(C.YELLOW + "No block held"); sender().sendMessage(C.YELLOW + "No block held");
} else if (hand) { } else if (hand) {

View File

@ -16,6 +16,7 @@ import com.volmit.iris.util.data.B;
import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeExecutor;
import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.DecreeOrigin;
import com.volmit.iris.util.decree.annotations.Decree; 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.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.json.JSONObject; 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) @Decree(name = "what", aliases = "?", description = "Find information on the world around you", origin = DecreeOrigin.PLAYER)
public class DecWhat implements DecreeExecutor { 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") @Decree(aliases = "nf", description = "Get the noise feature data in your chunk")
public void features() { public void features() {
@ -119,18 +60,20 @@ public class DecWhat implements DecreeExecutor {
} }
} }
@Decree(description = "Get information about the item you are holding", sync = true) @Decree(description = "Get information about the world around you", aliases = "location", studio = true)
public void hand() { public void me(
BlockData bd = player().getInventory().getItemInMainHand().getType().createBlockData(); @Param(description = "Whether or not to show dimension information", defaultValue = "true")
boolean dimension,
if (bd.getMaterial().equals(Material.AIR)){ @Param(description = "Whether or not to show region information", defaultValue = "true")
sender().sendMessage(C.YELLOW + "Please hold a block/item"); boolean region,
return; @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")
sender().sendMessage("Material: " + C.GREEN + bd.getMaterial().name()); boolean look,
sender().sendMessage("Full: " + C.WHITE + bd.getAsString(true)); @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") @Decree(aliases = "capture", description = "Get information about nearby structures")

View File

@ -106,25 +106,9 @@ public class IrisProject {
}); });
} }
public void open(VolmitSender sender, long seed, Consumer<World> onDone) throws IrisException { public void openVSCode(VolmitSender sender) {
if (isOpen()) {
close();
}
boolean hasError = false;
if (hasError) {
return;
}
IrisDimension d = IrisData.loadAnyDimension(getName()); 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(() -> J.attemptAsync(() ->
{ {
try { try {
@ -171,6 +155,28 @@ public class IrisProject {
e.printStackTrace(); e.printStackTrace();
} }
}); });
}
public void open(VolmitSender sender, long seed, Consumer<World> 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(() -> { J.a(() -> {

View File

@ -323,8 +323,7 @@ public class StudioSVC implements IrisService {
public void open(VolmitSender sender, long seed, String dimm) { public void open(VolmitSender sender, long seed, String dimm) {
try { try {
open(sender, seed, dimm, (w) -> { open(sender, seed, dimm, (w) -> {});
});
} catch (Exception e) { } catch (Exception e) {
Iris.reportError(e); Iris.reportError(e);
sender.sendMessage("Error when creating studio world:"); sender.sendMessage("Error when creating studio world:");
@ -342,6 +341,10 @@ public class StudioSVC implements IrisService {
project.open(sender, seed, onDone); 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) { public File getWorkspaceFolder(String... sub) {
return Iris.instance.getDataFolderList(WORKSPACE_NAME, sub); return Iris.instance.getDataFolderList(WORKSPACE_NAME, sub);
} }

View File

@ -56,6 +56,9 @@ public class BiomeHandler implements DecreeParameterHandler<IrisBiome> {
@Override @Override
public IrisBiome parse(String in) throws DecreeParsingException, DecreeWhichException { public IrisBiome parse(String in) throws DecreeParsingException, DecreeWhichException {
if (in.equals("null")) {
return null;
}
try { try {
KList<IrisBiome> options = getPossibilities(in); KList<IrisBiome> options = getPossibilities(in);

View File

@ -56,6 +56,9 @@ public class RegionHandler implements DecreeParameterHandler<IrisRegion> {
@Override @Override
public IrisRegion parse(String in) throws DecreeParsingException, DecreeWhichException { public IrisRegion parse(String in) throws DecreeParsingException, DecreeWhichException {
if (in.equals("null")) {
return null;
}
try { try {
KList<IrisRegion> options = getPossibilities(in); KList<IrisRegion> options = getPossibilities(in);

View File

@ -28,7 +28,13 @@ import org.bukkit.World;
public class WorldHandler implements DecreeParameterHandler<World> { public class WorldHandler implements DecreeParameterHandler<World> {
@Override @Override
public KList<World> getPossibilities() { public KList<World> getPossibilities() {
return new KList<>(Bukkit.getWorlds()); KList<World> options = new KList<>();
for (World world : Bukkit.getWorlds()) {
if (!world.getName().toLowerCase().startsWith("iris/")){
options.add(world);
}
}
return options;
} }
@Override @Override