9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 11:09:06 +00:00

It compiles

This commit is contained in:
DanMB
2022-06-04 21:42:15 -07:00
parent 33eb878834
commit dd804b6665
5 changed files with 81 additions and 73 deletions

View File

@@ -74,6 +74,7 @@ public class IrisSettings {
public double targetSpawnEntitiesPerChunk = 0.95;
public boolean markerEntitySpawningSystem = true;
public boolean effectSystem = true;
public boolean worldEditWandCUI = true;
}
@Data

View File

@@ -229,7 +229,7 @@ public class CommandObject implements DecreeExecutor {
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Cuboid cursor = new Cuboid(a1, a2);
@@ -253,10 +253,8 @@ public class CommandObject implements DecreeExecutor {
return;
}
ItemStack wand = player().getInventory().getItemInMainHand();
if(WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
if(WandSVC.isHoldingWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if(!here) {
// TODO: WARNING HEIGHT
@@ -278,10 +276,8 @@ public class CommandObject implements DecreeExecutor {
return;
}
ItemStack wand = player().getInventory().getItemInMainHand();
if(WandSVC.isWand(wand)) {
Location[] g = WandSVC.getCuboid(wand);
if(WandSVC.isHoldingIrisWand(player())) {
Location[] g = WandSVC.getCuboid(player());
if(!here) {
// TODO: WARNING HEIGHT
@@ -364,7 +360,7 @@ public class CommandObject implements DecreeExecutor {
@Param(description = "Overwrite existing object files", defaultValue = "false", aliases = "force")
boolean overwrite
) {
IrisObject o = WandSVC.createSchematic(player().getInventory().getItemInMainHand());
IrisObject o = WandSVC.createSchematic(player());
if(o == null) {
sender().sendMessage(C.YELLOW + "You need to hold your wand!");
@@ -398,7 +394,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Direction d = Direction.closest(player().getLocation().getDirection()).reverse();
@@ -430,15 +426,16 @@ public class CommandObject implements DecreeExecutor {
return;
}
Pair<Location, Location> locs = WorldEditLink.getSelection(sender().player());
if(locs.getFirst() == null)
sender().sendMessage(C.RED + "You don't have a WorldEdit selection!");
else if(locs.getSecond() == null)
sender().sendMessage(C.RED + "You need a valid WorldRegion selection in the current world!");
else {
sender().player().getInventory().addItem(WandSVC.createWand(locs.getFirst(), locs.getSecond()));
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
Cuboid locs = WorldEditLink.getSelection(sender().player());
if(locs == null)
{
sender().sendMessage(C.RED + "You don't have a WorldEdit selection in this world.");
return;
}
sender().player().getInventory().addItem(WandSVC.createWand(locs.getLowerNE(), locs.getUpperSW()));
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
}
@Decree(description = "Get an object wand", sync = true)
@@ -455,7 +452,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
Location a1 = b[0].clone();
Location a2 = b[1].clone();
Location a1x = b[0].clone();
@@ -502,7 +499,7 @@ public class CommandObject implements DecreeExecutor {
return;
}
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
Location[] b = WandSVC.getCuboid(player());
b[0].add(new Vector(0, 1, 0));
b[1].add(new Vector(0, 1, 0));
Location a1 = b[0].clone();

View File

@@ -1,32 +1,37 @@
package com.volmit.iris.core.link;
import com.mojang.datafixers.util.Pair;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.MissingSessionException;
import org.bukkit.Location;
import com.volmit.iris.util.data.Cuboid;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class WorldEditLink {
public static Pair<Location, Location> getSelection(Player p) {
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(BukkitAdapter.adapt(p));
try {
if(session == null)
throw new MissingSessionException();
Region r = session.getSelection(BukkitAdapter.adapt(p.getWorld()));
BlockVector3 p1 = r.getMinimumPoint();
BlockVector3 p2 = r.getMaximumPoint();
return new Pair<>(new Location(p.getWorld(), p1.getX(), p1.getY(), p1.getZ()), new Location(p.getWorld(), p2.getX(), p2.getY(), p2.getZ()));
} catch(MissingSessionException e) {
return new Pair<>(null, new Location(null, 0, 0, 0));
} catch(IncompleteRegionException e) {
return new Pair<>(new Location(null, 0, 0, 0), null);
public static Cuboid getSelection(Player p)
{
try
{
Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null);
Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance);
Object player = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", Player.class).invoke(null, p);
Object localSession = sessionManager.getClass().getDeclaredMethod("getIfPresent", Class.forName("com.sk89q.worldedit.session.SessionOwner")).invoke(sessionManager, player);
Object world = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", World.class).invoke(null, p.getWorld());
Object region = localSession.getClass().getDeclaredMethod("getSelection", world.getClass()).invoke(localSession, world);
Object min = region.getClass().getDeclaredMethod("getMinimumPoint").invoke(region);
Object max = region.getClass().getDeclaredMethod("getMaximumPoint").invoke(region);
return new Cuboid(p.getWorld(),
(int)min.getClass().getDeclaredMethod("getX").invoke(min),
(int)min.getClass().getDeclaredMethod("getY").invoke(min),
(int)min.getClass().getDeclaredMethod("getZ").invoke(min),
(int)min.getClass().getDeclaredMethod("getX").invoke(max),
(int)min.getClass().getDeclaredMethod("getY").invoke(max),
(int)min.getClass().getDeclaredMethod("getZ").invoke(max)
);
}
catch(Throwable e)
{
}
return null;
}
}

View File

@@ -19,7 +19,9 @@
package com.volmit.iris.core.service;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.edit.DustRevealer;
import com.volmit.iris.core.link.WorldEditLink;
import com.volmit.iris.core.wand.WandSelection;
import com.volmit.iris.engine.object.IrisObject;
import com.volmit.iris.util.collection.KList;
@@ -64,17 +66,17 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand
* The wand itemstack
* @param p
* The wand player
* @return The new object
*/
public static IrisObject createSchematic(ItemStack wand) {
if(!isWand(wand)) {
public static IrisObject createSchematic(Player p) {
if(!isHoldingWand(p)) {
return null;
}
try {
Location[] f = getCuboid(wand);
Location[] f = getCuboid(p);
Cuboid c = new Cuboid(f[0], f[1]);
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
for(Block b : c) {
@@ -98,17 +100,15 @@ public class WandSVC implements IrisService {
/**
* Creates an Iris Object from the 2 coordinates selected with a wand
*
* @param wand
* The wand itemstack
* @return The new object
*/
public static Matter createMatterSchem(Player p, ItemStack wand) {
if(!isWand(wand)) {
public static Matter createMatterSchem(Player p) {
if(!isHoldingWand(p)) {
return null;
}
try {
Location[] f = getCuboid(wand);
Location[] f = getCuboid(p);
return WorldMatter.createMatter(p.getName(), f[0], f[1]);
} catch(Throwable e) {
@@ -226,26 +226,32 @@ public class WandSVC implements IrisService {
return is;
}
/**
* Get a pair of locations that are selected in an Iris wand
*
* @param is
* The wand item
* @return An array with the 2 locations
*/
public static Location[] getCuboid(ItemStack is) {
public static Location[] getCuboidFromItem(ItemStack is) {
ItemMeta im = is.getItemMeta();
return new Location[] {stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))};
}
/**
* Is a player holding an Iris wand
*
* @param p
* The player
* @return True if they are
*/
public static Location[] getCuboid(Player p) {
if(isHoldingIrisWand(p))
{
return getCuboidFromItem(p.getInventory().getItemInMainHand());
}
Cuboid c = WorldEditLink.getSelection(p);
if(c != null)
{
return new Location[] {c.getLowerNE(), c.getUpperSW()};
}
return null;
}
public static boolean isHoldingWand(Player p) {
return isHoldingIrisWand(p) || WorldEditLink.getSelection(p) != null;
}
public static boolean isHoldingIrisWand(Player p) {
ItemStack is = p.getInventory().getItemInMainHand();
return is != null && isWand(is);
}
@@ -286,8 +292,8 @@ public class WandSVC implements IrisService {
public void tick(Player p) {
try {
try {
if(isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p.getInventory().getItemInMainHand());
if((IrisSettings.get().getWorld().worldEditWandCUI && isHoldingWand(p)) || isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p);
new WandSelection(new Cuboid(d[0], d[1]), p).draw();
}
} catch(Throwable e) {
@@ -457,7 +463,7 @@ public class WandSVC implements IrisService {
return item;
}
Location[] f = getCuboid(item);
Location[] f = getCuboidFromItem(item);
Location other = left ? f[1] : f[0];
if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) {