mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
commit
d54fdf5452
@ -86,73 +86,7 @@ public class CommandIrisObjectAnalyze extends MortarCommand {
|
||||
Player p = sender.player();
|
||||
|
||||
J.a(() -> {
|
||||
IrisObject obj = IrisData.loadAnyObject(args[0]);
|
||||
|
||||
if (obj == null || obj.getLoadFile() == null) {
|
||||
sender.sendMessage("Can't find " + args[0] + " in the " + StudioSVC.WORKSPACE_NAME + " folder");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Object Size: " + obj.getW() + " * " + obj.getH() + " * " + obj.getD() + "");
|
||||
sender.sendMessage("Blocks Used: " + NumberFormat.getIntegerInstance().format(obj.getBlocks().size()));
|
||||
|
||||
Queue<BlockData> queue = obj.getBlocks().enqueueValues();
|
||||
Map<Material, Set<BlockData>> unsorted = new HashMap<>();
|
||||
Map<BlockData, Integer> amounts = new HashMap<>();
|
||||
Map<Material, Integer> materials = new HashMap<>();
|
||||
while (queue.hasNext()) {
|
||||
BlockData block = queue.next();
|
||||
|
||||
//unsorted.put(block.getMaterial(), block);
|
||||
|
||||
if (!amounts.containsKey(block)) {
|
||||
amounts.put(block, 1);
|
||||
|
||||
|
||||
} else
|
||||
amounts.put(block, amounts.get(block) + 1);
|
||||
|
||||
if (!materials.containsKey(block.getMaterial())) {
|
||||
materials.put(block.getMaterial(), 1);
|
||||
unsorted.put(block.getMaterial(), new HashSet<>());
|
||||
unsorted.get(block.getMaterial()).add(block);
|
||||
} else {
|
||||
materials.put(block.getMaterial(), materials.get(block.getMaterial()) + 1);
|
||||
unsorted.get(block.getMaterial()).add(block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<Material> sortedMatsList = amounts.keySet().stream().map(BlockData::getMaterial)
|
||||
.sorted().collect(Collectors.toList());
|
||||
Set<Material> sortedMats = new TreeSet<>(Comparator.comparingInt(materials::get).reversed());
|
||||
sortedMats.addAll(sortedMatsList);
|
||||
sender.sendMessage("== Blocks in object ==");
|
||||
|
||||
int n = 0;
|
||||
for (Material mat : sortedMats) {
|
||||
int amount = materials.get(mat);
|
||||
List<BlockData> set = new ArrayList<>(unsorted.get(mat));
|
||||
set.sort(Comparator.comparingInt(amounts::get).reversed());
|
||||
BlockData data = set.get(0);
|
||||
int dataAmount = amounts.get(data);
|
||||
|
||||
String string = " - " + mat.toString() + "*" + amount;
|
||||
if (data.getAsString(true).contains("[")) {
|
||||
string = string + " --> [" + data.getAsString(true).split("\\[")[1]
|
||||
.replaceAll("true", ChatColor.GREEN + "true" + ChatColor.GRAY)
|
||||
.replaceAll("false", ChatColor.RED + "false" + ChatColor.GRAY) + "*" + dataAmount;
|
||||
}
|
||||
|
||||
sender.sendMessage(string);
|
||||
|
||||
n++;
|
||||
|
||||
if (n >= 10) {
|
||||
sender.sendMessage(" + " + (sortedMats.size() - n) + " other block types");
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
|
@ -74,7 +74,7 @@ public class CommandIrisObjectContract extends MortarCommand {
|
||||
b[1] = cursor.getUpperSW();
|
||||
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
|
||||
p.updateInventory();
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class CommandIrisObjectDust extends MortarCommand {
|
||||
}
|
||||
|
||||
sender.player().getInventory().addItem(WandSVC.createDust());
|
||||
sender.player().playSound(sender.player().getLocation(), Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f);
|
||||
sender.playSound(Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class CommandIrisObjectExpand extends MortarCommand {
|
||||
b[1] = cursor.getUpperSW();
|
||||
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
|
||||
p.updateInventory();
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class CommandIrisObjectPaste extends MortarCommand {
|
||||
|
||||
Iris.debug("Loaded object for placement: " + "objects/" + args[0] + ".iob");
|
||||
|
||||
sender.player().getWorld().playSound(sender.player().getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
sender.playSound(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
|
||||
Set<Material> skipBlocks = Set.of(Material.GRASS, Material.SNOW, Material.VINE, Material.TORCH, Material.DEAD_BUSH,
|
||||
Material.POPPY, Material.DANDELION);
|
||||
|
@ -88,7 +88,7 @@ public class CommandIrisObjectSave extends MortarCommand {
|
||||
|
||||
o.write(file);
|
||||
sender.sendMessage("Saved " + args[1]);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
sender.playSound(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
sender.sendMessage("Failed to save " + args[1] + ". Are you holding your wand?");
|
||||
|
@ -88,7 +88,7 @@ public class CommandIrisObjectSaveMatter extends MortarCommand {
|
||||
|
||||
o.write(file);
|
||||
sender.sendMessage("Saved " + args[1]);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
sender.playSound(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
sender.sendMessage("Failed to save " + args[1] + ". Are you holding your wand?");
|
||||
|
@ -75,7 +75,7 @@ public class CommandIrisObjectShift extends MortarCommand {
|
||||
b[1] = cursor.getUpperSW();
|
||||
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
|
||||
p.updateInventory();
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class CommandIrisObjectWand extends MortarCommand {
|
||||
}
|
||||
|
||||
sender.player().getInventory().addItem(WandSVC.createWand());
|
||||
sender.player().playSound(sender.player().getLocation(), Sound.ITEM_ARMOR_EQUIP_NETHERITE, 1f, 1.5f);
|
||||
sender.playSound(Sound.ITEM_ARMOR_EQUIP_NETHERITE, 1f, 1.5f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class CommandIrisObjectXAY extends MortarCommand {
|
||||
b[1] = cursor.getUpperSW();
|
||||
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
|
||||
p.updateInventory();
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class CommandIrisObjectXPY extends MortarCommand {
|
||||
b[1] = cursor.getUpperSW();
|
||||
p.getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1]));
|
||||
p.updateInventory();
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,72 +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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.core.command.world;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.plugin.MortarCommand;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CommandLocate extends MortarCommand implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {
|
||||
if (IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
|
||||
|
||||
// Make sure the command starts with /locate and does not locate stronghold
|
||||
if (event.getMessage().contains("/locate") && event.getMessage().contains("stronghold")) {
|
||||
return;
|
||||
}
|
||||
if (event.getMessage().contains("/locate")) {
|
||||
event.setCancelled(true); // Cancel the vanilla command process
|
||||
String command = event.getMessage().replace("/locate", "ir std goto");
|
||||
Bukkit.dispatchCommand(event.getPlayer(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CommandLocate() {
|
||||
super("locate");
|
||||
requiresPermission(Iris.perm);
|
||||
Iris.instance.registerListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(VolmitSender sender, String[] args) {
|
||||
Bukkit.dispatchCommand(sender, "/ir std goto " + Arrays.toString(args));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTabOptions(VolmitSender sender, String[] args, KList<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage() {
|
||||
return "[biome/region/structure]";
|
||||
}
|
||||
}
|
@ -42,6 +42,10 @@ public class DecIris implements DecreeExecutor {
|
||||
|
||||
private DecPregen pregen;
|
||||
|
||||
private DecSettings settings;
|
||||
|
||||
private DecObject object;
|
||||
|
||||
@Decree(description = "Create a new world", aliases = "+")
|
||||
public void create(
|
||||
@Param(aliases = "world-name", description = "The name of the world to create", defaultValue = "IrisWorld")
|
||||
@ -118,12 +122,12 @@ public class DecIris implements DecreeExecutor {
|
||||
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 + "" + value1 + " " + operator + " " + value2 + " => " + v);
|
||||
sender().sendMessage(C.GREEN + "" + value1 + " " + C.GREEN + operator.replaceAll("<", "≺").replaceAll(">", "≻") + " " + C.GREEN + value2 + C.GREEN + " returns " + C.GREEN + v);
|
||||
}
|
||||
|
||||
@Decree(description = "Toggle debug")
|
||||
@ -145,7 +149,7 @@ public class DecIris implements DecreeExecutor {
|
||||
@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" : ""));
|
||||
sender().sendMessage(C.GREEN + "Downloading pack: " + pack + "/" + branch + (trim ? " trimmed" : "") + (overwrite ? " overwriting" : ""));
|
||||
Iris.service(StudioSVC.class).downloadSearch(sender(), "IrisDimensions/" + pack + "/" + branch, trim, overwrite);
|
||||
}
|
||||
|
||||
|
305
src/main/java/com/volmit/iris/core/decrees/DecObject.java
Normal file
305
src/main/java/com/volmit/iris/core/decrees/DecObject.java
Normal file
@ -0,0 +1,305 @@
|
||||
package com.volmit.iris.core.decrees;
|
||||
|
||||
import com.volmit.iris.core.command.object.CommandIrisObjectUndo;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.core.service.WandSVC;
|
||||
import com.volmit.iris.engine.object.common.IObjectPlacer;
|
||||
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.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.format.C;
|
||||
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.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 java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Decree(name = "object", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris object manipulation")
|
||||
public class DecObject implements DecreeExecutor {
|
||||
|
||||
@Decree(description = "Check the composition of an object")
|
||||
public void analyze(
|
||||
@Param(description = "The object to analyze")
|
||||
IrisObject object
|
||||
) {
|
||||
sender().sendMessage("Object Size: " + object.getW() + " * " + object.getH() + " * " + object.getD() + "");
|
||||
sender().sendMessage("Blocks Used: " + NumberFormat.getIntegerInstance().format(object.getBlocks().size()));
|
||||
|
||||
Queue<BlockData> queue = object.getBlocks().enqueueValues();
|
||||
Map<Material, Set<BlockData>> unsorted = new HashMap<>();
|
||||
Map<BlockData, Integer> amounts = new HashMap<>();
|
||||
Map<Material, Integer> materials = new HashMap<>();
|
||||
while (queue.hasNext()) {
|
||||
BlockData block = queue.next();
|
||||
|
||||
//unsorted.put(block.getMaterial(), block);
|
||||
|
||||
if (!amounts.containsKey(block)) {
|
||||
amounts.put(block, 1);
|
||||
|
||||
|
||||
} else
|
||||
amounts.put(block, amounts.get(block) + 1);
|
||||
|
||||
if (!materials.containsKey(block.getMaterial())) {
|
||||
materials.put(block.getMaterial(), 1);
|
||||
unsorted.put(block.getMaterial(), new HashSet<>());
|
||||
unsorted.get(block.getMaterial()).add(block);
|
||||
} else {
|
||||
materials.put(block.getMaterial(), materials.get(block.getMaterial()) + 1);
|
||||
unsorted.get(block.getMaterial()).add(block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<Material> sortedMatsList = amounts.keySet().stream().map(BlockData::getMaterial)
|
||||
.sorted().collect(Collectors.toList());
|
||||
Set<Material> sortedMats = new TreeSet<>(Comparator.comparingInt(materials::get).reversed());
|
||||
sortedMats.addAll(sortedMatsList);
|
||||
sender().sendMessage("== Blocks in object ==");
|
||||
|
||||
int n = 0;
|
||||
for (Material mat : sortedMats) {
|
||||
int amount = materials.get(mat);
|
||||
List<BlockData> set = new ArrayList<>(unsorted.get(mat));
|
||||
set.sort(Comparator.comparingInt(amounts::get).reversed());
|
||||
BlockData data = set.get(0);
|
||||
int dataAmount = amounts.get(data);
|
||||
|
||||
String string = " - " + mat.toString() + "*" + amount;
|
||||
if (data.getAsString(true).contains("[")) {
|
||||
string = string + " --> [" + data.getAsString(true).split("\\[")[1]
|
||||
.replaceAll("true", ChatColor.GREEN + "true" + ChatColor.GRAY)
|
||||
.replaceAll("false", ChatColor.RED + "false" + ChatColor.GRAY) + "*" + dataAmount;
|
||||
}
|
||||
|
||||
sender().sendMessage(string);
|
||||
|
||||
n++;
|
||||
|
||||
if (n >= 10) {
|
||||
sender().sendMessage(" + " + (sortedMats.size() - n) + " other block types");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "Get a powder that reveals objects", studio = true)
|
||||
public void dust() {
|
||||
player().getInventory().addItem(WandSVC.createDust());
|
||||
sender().playSound(Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f);
|
||||
}
|
||||
|
||||
@Decree(description = "Contract a selection based on your looking direction", aliases = "-")
|
||||
public void contract(
|
||||
@Param(description = "The amount to inset by", defaultValue = "1")
|
||||
int amount
|
||||
){
|
||||
if (!WandSVC.isHoldingWand(player())) {
|
||||
sender().sendMessage("Hold your wand.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
|
||||
Location a1 = b[0].clone();
|
||||
Location a2 = b[1].clone();
|
||||
Cuboid cursor = new Cuboid(a1, a2);
|
||||
Direction d = Direction.closest(player().getLocation().getDirection()).reverse();
|
||||
assert d != null;
|
||||
cursor = cursor.expand(d, -amount);
|
||||
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);
|
||||
}
|
||||
|
||||
@Decree(description = "Set point 1 to look", aliases = "p1")
|
||||
public void position1(
|
||||
@Param(description = "Whether to use your current position, or where you look", defaultValue = "true")
|
||||
boolean here
|
||||
){
|
||||
if (!WandSVC.isHoldingWand(player())) {
|
||||
sender().sendMessage("Ready your Wand.");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack wand = player().getInventory().getItemInMainHand();
|
||||
|
||||
if (WandSVC.isWand(wand)) {
|
||||
Location[] g = WandSVC.getCuboid(wand);
|
||||
|
||||
if (!here) {
|
||||
// TODO: WARNING HEIGHT
|
||||
g[1] = player().getTargetBlock(null, 256).getLocation().clone();
|
||||
} else {
|
||||
g[1] = player().getLocation().getBlock().getLocation().clone().add(0, -1, 0);
|
||||
}
|
||||
player().setItemInHand(WandSVC.createWand(g[0], g[1]));
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "Set point 2 to look", aliases = "p2")
|
||||
public void position2(
|
||||
@Param(description = "Whether to use your current position, or where you look", defaultValue = "true")
|
||||
boolean here
|
||||
){
|
||||
if (!WandSVC.isHoldingWand(player())) {
|
||||
sender().sendMessage("Ready your Wand.");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack wand = player().getInventory().getItemInMainHand();
|
||||
|
||||
if (WandSVC.isWand(wand)) {
|
||||
Location[] g = WandSVC.getCuboid(wand);
|
||||
|
||||
if (!here) {
|
||||
// TODO: WARNING HEIGHT
|
||||
g[0] = player().getTargetBlock(null, 256).getLocation().clone();
|
||||
} else {
|
||||
g[0] = player().getLocation().getBlock().getLocation().clone().add(0, -1, 0);
|
||||
}
|
||||
player().setItemInHand(WandSVC.createWand(g[0], g[1]));
|
||||
}
|
||||
}
|
||||
private static final Set<Material> skipBlocks = Set.of(Material.GRASS, Material.SNOW, Material.VINE, Material.TORCH, Material.DEAD_BUSH,
|
||||
Material.POPPY, Material.DANDELION);
|
||||
@Decree(description = "Paste an object")
|
||||
public void paste(
|
||||
@Param(description = "The object to paste")
|
||||
IrisObject object,
|
||||
@Param(description = "Whether or not to edit the object (need to hold wand)", defaultValue = "false")
|
||||
boolean edit,
|
||||
@Param(description = "The amount of degrees to rotate by", defaultValue = "0")
|
||||
int rotate,
|
||||
@Param(description = "The factor by which to scale the object placement", defaultValue = "1")
|
||||
double scale,
|
||||
@Param(description = "The scale interpolator to use", defaultValue = "none")
|
||||
IrisObjectPlacementScaleInterpolator interpolator
|
||||
){
|
||||
double maxScale = Double.max(10 - object.getBlocks().size() / 10000d, 1);
|
||||
if (scale < maxScale){
|
||||
sender().sendMessage(C.YELLOW + "Indicated scale exceeds maximum. Downscaled to maximum: " + maxScale);
|
||||
scale = maxScale;
|
||||
}
|
||||
|
||||
sender().playSound(Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f);
|
||||
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setRotation(IrisObjectRotation.of(0, rotate, 0));
|
||||
|
||||
ItemStack wand = player().getInventory().getItemInMainHand();
|
||||
Location block = player().getTargetBlock(skipBlocks, 256).getLocation().clone().add(0, 1, 0);
|
||||
|
||||
Map<Block, BlockData> futureChanges = new HashMap<>();
|
||||
|
||||
object = object.scaled(scale, interpolator);
|
||||
object.place(block.getBlockX(), block.getBlockY() + (int) object.getCenter().getY(), block.getBlockZ(), createPlacer(block.getWorld(), futureChanges), placement, new RNG(), null);
|
||||
|
||||
CommandIrisObjectUndo.addChanges(player(), futureChanges);
|
||||
|
||||
if (edit) {
|
||||
ItemStack newWand = WandSVC.createWand(block.clone().subtract(object.getCenter()).add(object.getW() - 1,
|
||||
object.getH() + object.getCenter().clone().getY() - 1, object.getD() - 1), block.clone().subtract(object.getCenter().clone().setY(0)));
|
||||
if (WandSVC.isWand(wand)) {
|
||||
wand = newWand;
|
||||
player().getInventory().setItemInMainHand(wand);
|
||||
sender().sendMessage("Updated wand for " + "objects/" + object.getLoadKey() + ".iob");
|
||||
} else {
|
||||
int slot = WandSVC.findWand(player().getInventory());
|
||||
if (slot == -1) {
|
||||
player().getInventory().addItem(newWand);
|
||||
sender().sendMessage("Given new wand for " + "objects/" + object.getLoadKey() + ".iob");
|
||||
} else {
|
||||
player().getInventory().setItem(slot, newWand);
|
||||
sender().sendMessage("Updated wand for " + "objects/" + object.getLoadKey() + ".iob");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender().sendMessage("Placed " + "objects/" + object.getLoadKey() + ".iob");
|
||||
}
|
||||
}
|
||||
|
||||
public static IObjectPlacer createPlacer(World world, Map<Block, BlockData> futureBlockChanges) {
|
||||
|
||||
return new IObjectPlacer() {
|
||||
@Override
|
||||
public int getHighest(int x, int z, IrisData data) {
|
||||
return world.getHighestBlockYAt(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
|
||||
return world.getHighestBlockYAt(x, z, ignoreFluid ? HeightMap.OCEAN_FLOOR : HeightMap.MOTION_BLOCKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, BlockData d) {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
|
||||
//Prevent blocks being set in or bellow bedrock
|
||||
if (y <= world.getMinHeight() || block.getType() == Material.BEDROCK) return;
|
||||
|
||||
futureBlockChanges.put(block, block.getBlockData());
|
||||
|
||||
block.setBlockData(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData get(int x, int y, int z) {
|
||||
return world.getBlockAt(x, y, z).getBlockData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPreventingDecay() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolid(int x, int y, int z) {
|
||||
return world.getBlockAt(x, y, z).getType().isSolid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderwater(int x, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidHeight() {
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugSmartBore() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTile(int xx, int yy, int zz, TileData<? extends TileState> tile) {
|
||||
BlockState state = world.getBlockAt(xx, yy, zz).getState();
|
||||
tile.toBukkitTry(state);
|
||||
state.update();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -66,14 +66,12 @@ import com.volmit.iris.util.scheduling.jobs.Job;
|
||||
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.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
@ -622,7 +620,9 @@ public class DecStudio implements DecreeExecutor {
|
||||
@Decree(description = "Summon an Iris Entity", origin = DecreeOrigin.PLAYER)
|
||||
public void summon(
|
||||
@Param(description = "The Iris Entity to spawn")
|
||||
IrisEntity entity
|
||||
IrisEntity entity,
|
||||
@Param(description = "The location at which to spawn the entity", defaultValue = "self")
|
||||
Vector location
|
||||
) {
|
||||
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)");
|
||||
@ -633,7 +633,7 @@ public class DecStudio implements DecreeExecutor {
|
||||
return;
|
||||
}
|
||||
sender().sendMessage(C.GREEN + "Spawning entity");
|
||||
entity.spawn(engine(), player().getLocation().clone().add(0, 2, 0));
|
||||
entity.spawn(engine(), new Location(world(), location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
|
||||
@Decree(description = "Teleport to the active studio world", aliases = "stp", origin = DecreeOrigin.PLAYER, sync = true)
|
||||
|
33
src/main/java/com/volmit/iris/core/service/LocateSVC.java
Normal file
33
src/main/java/com/volmit/iris/core/service/LocateSVC.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.volmit.iris.core.service;
|
||||
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class LocateSVC implements IrisService {
|
||||
|
||||
@EventHandler
|
||||
public void on(final PlayerCommandPreprocessEvent event) {
|
||||
if (IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
|
||||
VolmitSender sender = new VolmitSender(event.getPlayer());
|
||||
sender.sendMessage(C.YELLOW + "You cannot locate structures in Iris worlds through vanilla commands");
|
||||
sender.sendMessage("You can use:");
|
||||
// TODO: Convert this to have the correct command prefix
|
||||
Bukkit.dispatchCommand(event.getPlayer(), "/ird studio find");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.volmit.iris.util.decree.handlers;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.objects.IrisObject;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.decree.DecreeParameterHandler;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
||||
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ObjectHandler implements DecreeParameterHandler<IrisObject> {
|
||||
@Override
|
||||
public KList<IrisObject> getPossibilities() {
|
||||
KMap<String, IrisObject> p = new KMap<>();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
for (File i : Iris.instance.getDataFolder("packs").listFiles()) {
|
||||
if (i.isDirectory()) {
|
||||
IrisData data = new IrisData(i, true);
|
||||
for (IrisObject j : data.getObjectLoader().loadAll(data.getObjectLoader().getPossibleKeys())) {
|
||||
p.putIfAbsent(j.getLoadKey(), j);
|
||||
}
|
||||
|
||||
data.close();
|
||||
}
|
||||
}
|
||||
|
||||
return p.v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(IrisObject irisObject) {
|
||||
return irisObject.getLoadKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject parse(String in) throws DecreeParsingException, DecreeWhichException {
|
||||
try {
|
||||
KList<IrisObject> options = getPossibilities(in);
|
||||
|
||||
if (options.isEmpty()) {
|
||||
throw new DecreeParsingException("Unable to find Object \"" + in + "\"");
|
||||
} else if (options.size() > 1) {
|
||||
throw new DecreeWhichException();
|
||||
}
|
||||
|
||||
return options.get(0);
|
||||
} catch (DecreeParsingException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
throw new DecreeParsingException("Unable to find Object \"" + in + "\" because of an uncaught exception: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> type) {
|
||||
return type.equals(IrisObject.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRandomDefault() {
|
||||
return "object";
|
||||
}
|
||||
}
|
@ -33,6 +33,15 @@ import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
|
||||
private static final KList<String> randoms = new KList<>(
|
||||
"here",
|
||||
"0,0,0",
|
||||
"0,0",
|
||||
"look",
|
||||
"player:<name>"
|
||||
);
|
||||
|
||||
@Override
|
||||
public KList<Vector> getPossibilities() {
|
||||
KList<Vector> vx = new KList<>();
|
||||
@ -107,6 +116,6 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
|
||||
@Override
|
||||
public String getRandomDefault() {
|
||||
return M.r(0.5) ? "0,0" : "0,0,0";
|
||||
return randoms.getRandom();
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public abstract class MortarCommand implements ICommand {
|
||||
}
|
||||
|
||||
if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
sender.player().playSound(sender.player().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f);
|
||||
sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f);
|
||||
}
|
||||
|
||||
return v;
|
||||
@ -100,8 +100,8 @@ public abstract class MortarCommand implements ICommand {
|
||||
}
|
||||
|
||||
if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) {
|
||||
sender.player().getWorld().playSound(sender.player().getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 0.28f, 1.4f);
|
||||
sender.player().getWorld().playSound(sender.player().getLocation(), Sound.ITEM_AXE_STRIP, 0.35f, 1.7f);
|
||||
sender.playSound(Sound.ITEM_BOOK_PAGE_TURN, 0.28f, 1.4f);
|
||||
sender.playSound(Sound.ITEM_AXE_STRIP, 0.35f, 1.7f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@ -413,60 +414,70 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
for (VirtualDecreeCommand i : v.getNodes()) {
|
||||
if (isPlayer()) {
|
||||
//@builder
|
||||
String s = (
|
||||
"<hover:show_text:'" +
|
||||
i.getNames().copy().reverse().convert((f) -> "<#42ecf5>" + f).toString(", ") + "\n"
|
||||
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + i.getDescription() + "<reset>\n"
|
||||
+ "<#bbe03f>✒ <#a8e0a2>" + (i.isNode()
|
||||
? ((i.getNode().getParameters().isEmpty()
|
||||
? "<font:minecraft:uniform>There are no parameters.<reset>"
|
||||
: "<font:minecraft:uniform>Hover over all of the parameters to learn more.<reset>") + "\n")
|
||||
: "<font:minecraft:uniform>This is a command category. Run <reset><#98eda5>" + i.getPath())
|
||||
+ (i.isNode()
|
||||
? (i.getNode().getParameters().isNotEmpty())
|
||||
? "<#aebef2>✦ <#5ef288><font:minecraft:uniform>"
|
||||
+ i.getParentPath()
|
||||
+ " <#42ecf5>"
|
||||
+ i.getName() + " "
|
||||
+ i.getNode().getParameters().convert((f)
|
||||
-> "<#d665f0>" + f.example())
|
||||
.toString(" ") + "\n"
|
||||
: ""
|
||||
: "")
|
||||
+ (i.isNode() ? "<font:minecraft:uniform>" + pickRandoms(Math.min(i.getNode().getParameters().size() + 1, 5), i) + "<reset>" : "")
|
||||
+ "'><click:" + (i.isNode() ? "suggest_command" : "run_command") + ":" + i.getPath() + " >"
|
||||
+ "<#46826a>⇀<gradient:#42ecf5:#428df5> " + i.getName() + "</click></hover>"
|
||||
+ (i.isNode() ?
|
||||
" " + i.getNode().getParameters().convert((f)
|
||||
-> "<hover:show_text:'"
|
||||
+ f.getNames().convert((ff) -> "<#d665f0>" + ff).toString(", ") + "\n"
|
||||
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + f.getDescription() + "<reset>\n"
|
||||
+ (f.isRequired()
|
||||
? "<#db4321>⚠ <#faa796><font:minecraft:uniform>This parameter is required."
|
||||
: (f.hasDefault()
|
||||
? "<#2181db>✔ <#78dcf0><font:minecraft:uniform>Defaults to \"" + f.getParam().defaultValue() + "\" if undefined."
|
||||
: "<#a73abd>✔ <#78dcf0><font:minecraft:uniform>This parameter is optional.")) + "<reset>\n"
|
||||
+ (f.isContextual() ? "<#ff9900>➱ <#ffcc00><font:minecraft:uniform>The value may be derived from environment context <reset>\n" : "")
|
||||
+ "<#cc00ff>✢ <#ff33cc><font:minecraft:uniform>This parameter is of type " + f.getType().getSimpleName() + "<reset>\n"
|
||||
+ "'>"
|
||||
+ (f.isRequired() ? "<red>[" : "")
|
||||
+ "<gradient:#d665f0:#a37feb>" + f.getName()
|
||||
+ (f.isRequired() ? "<red>]<gray>" : "")
|
||||
+ "</hover>").toString(" ")
|
||||
: "<gradient:#afe3d3:#a2dae0> - Category of Commands"
|
||||
)
|
||||
);
|
||||
//@done
|
||||
sendMessageRaw(s);
|
||||
System.out.println(s);
|
||||
} else {
|
||||
sendMessage(i.getPath() + "()");
|
||||
}
|
||||
sendDecreeHelpNode(i);
|
||||
}
|
||||
} else {
|
||||
sendMessage(C.RED + "There are no subcommands in this group! Contact support, this is a command design issue!");
|
||||
}
|
||||
}
|
||||
|
||||
public void sendDecreeHelpNode(VirtualDecreeCommand i){
|
||||
if (isPlayer()) {
|
||||
//@builder
|
||||
String s = (
|
||||
"<hover:show_text:'"+
|
||||
i.getNames().copy().reverse().convert((f) -> "<#42ecf5>" + f).toString(", ") + "\n"
|
||||
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + i.getDescription() + "<reset>\n"
|
||||
+ "<#bbe03f>✒ <#a8e0a2>" + (i.isNode()
|
||||
? ((i.getNode().getParameters().isEmpty()
|
||||
? "<font:minecraft:uniform>There are no parameters.<reset>"
|
||||
: "<font:minecraft:uniform>Hover over all of the parameters to learn more.<reset>" + "\n"))
|
||||
: "<font:minecraft:uniform>This is a command category. Run <reset><#98eda5>" + i.getPath())
|
||||
+ (i.isNode()
|
||||
? (i.getNode().getParameters().isNotEmpty())
|
||||
? "<#aebef2>✦ <#5ef288><font:minecraft:uniform>"
|
||||
+ i.getParentPath()
|
||||
+ " <#42ecf5>"
|
||||
+ i.getName() + " "
|
||||
+ i.getNode().getParameters().convert((f)
|
||||
-> "<#d665f0>" + f.example())
|
||||
.toString(" ") + "\n"
|
||||
: ""
|
||||
: "")
|
||||
+ (i.isNode() ? "<font:minecraft:uniform>" + pickRandoms(Math.min(i.getNode().getParameters().size() + 1, 5), i) + "<reset>" : "")
|
||||
+ "'><click:" + (i.isNode() ? "suggest_command" : "run_command") + ":" + i.getPath() + " >"
|
||||
+ "<#46826a>⇀<gradient:#42ecf5:#428df5> " + i.getName() + "</click></hover>"
|
||||
+ (i.isNode() ?
|
||||
" " + i.getNode().getParameters().convert((f)
|
||||
-> "<hover:show_text:'"
|
||||
+ f.getNames().convert((ff) -> "<#d665f0>" + ff).toString(", ") + "\n"
|
||||
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + f.getDescription() + "<reset>\n"
|
||||
+ (f.isRequired()
|
||||
? "<#db4321>⚠ <#faa796><font:minecraft:uniform>This parameter is required."
|
||||
: (f.hasDefault()
|
||||
? "<#2181db>✔ <#78dcf0><font:minecraft:uniform>Defaults to \""+f.getParam().defaultValue()+"\" if undefined."
|
||||
: "<#a73abd>✔ <#78dcf0><font:minecraft:uniform>This parameter is optional.")) + "<reset>\n"
|
||||
+ (f.isContextual() ? "<#ff9900>➱ <#ffcc00><font:minecraft:uniform>The value may be derived from environment context <reset>\n" : "")
|
||||
+ "<#cc00ff>✢ <#ff33cc><font:minecraft:uniform>This parameter is of type " + f.getType().getSimpleName()
|
||||
+ "'>"
|
||||
+ (f.isRequired() ? "<red>[" : "")
|
||||
+ "<gradient:#d665f0:#a37feb>" + f.getName()
|
||||
+ (f.isRequired() ? "<red>]<gray>" : "")
|
||||
+ "</hover>").toString(" ")
|
||||
: "<gradient:#afe3d3:#a2dae0> - Category of Commands"
|
||||
)
|
||||
);
|
||||
//@done
|
||||
sendMessageRaw(s);
|
||||
System.out.println(s);
|
||||
} else {
|
||||
sendMessage(i.getPath() + "()");
|
||||
}
|
||||
}
|
||||
|
||||
public void playSound(Sound sound, float volume, float pitch) {
|
||||
if (isPlayer()) {
|
||||
player().playSound(player().getLocation(), sound, volume, pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user