mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 14:21:33 +00:00
It compiles
This commit is contained in:
@@ -129,7 +129,6 @@ dependencies {
|
|||||||
implementation 'io.th0rgal:oraxen:1.94.0'
|
implementation 'io.th0rgal:oraxen:1.94.0'
|
||||||
implementation 'org.bukkit:craftbukkit:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
|
implementation 'org.bukkit:craftbukkit:1.18.2-R0.1-SNAPSHOT:remapped-mojang'
|
||||||
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
|
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
|
||||||
implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.9'
|
|
||||||
|
|
||||||
// Shaded
|
// Shaded
|
||||||
implementation 'com.dfsek:Paralithic:0.4.0'
|
implementation 'com.dfsek:Paralithic:0.4.0'
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public class IrisSettings {
|
|||||||
public double targetSpawnEntitiesPerChunk = 0.95;
|
public double targetSpawnEntitiesPerChunk = 0.95;
|
||||||
public boolean markerEntitySpawningSystem = true;
|
public boolean markerEntitySpawningSystem = true;
|
||||||
public boolean effectSystem = true;
|
public boolean effectSystem = true;
|
||||||
|
public boolean worldEditWandCUI = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -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 a1 = b[0].clone();
|
||||||
Location a2 = b[1].clone();
|
Location a2 = b[1].clone();
|
||||||
Cuboid cursor = new Cuboid(a1, a2);
|
Cuboid cursor = new Cuboid(a1, a2);
|
||||||
@@ -253,10 +253,8 @@ public class CommandObject implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack wand = player().getInventory().getItemInMainHand();
|
if(WandSVC.isHoldingWand(player())) {
|
||||||
|
Location[] g = WandSVC.getCuboid(player());
|
||||||
if(WandSVC.isWand(wand)) {
|
|
||||||
Location[] g = WandSVC.getCuboid(wand);
|
|
||||||
|
|
||||||
if(!here) {
|
if(!here) {
|
||||||
// TODO: WARNING HEIGHT
|
// TODO: WARNING HEIGHT
|
||||||
@@ -278,10 +276,8 @@ public class CommandObject implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack wand = player().getInventory().getItemInMainHand();
|
if(WandSVC.isHoldingIrisWand(player())) {
|
||||||
|
Location[] g = WandSVC.getCuboid(player());
|
||||||
if(WandSVC.isWand(wand)) {
|
|
||||||
Location[] g = WandSVC.getCuboid(wand);
|
|
||||||
|
|
||||||
if(!here) {
|
if(!here) {
|
||||||
// TODO: WARNING HEIGHT
|
// TODO: WARNING HEIGHT
|
||||||
@@ -364,7 +360,7 @@ public class CommandObject implements DecreeExecutor {
|
|||||||
@Param(description = "Overwrite existing object files", defaultValue = "false", aliases = "force")
|
@Param(description = "Overwrite existing object files", defaultValue = "false", aliases = "force")
|
||||||
boolean overwrite
|
boolean overwrite
|
||||||
) {
|
) {
|
||||||
IrisObject o = WandSVC.createSchematic(player().getInventory().getItemInMainHand());
|
IrisObject o = WandSVC.createSchematic(player());
|
||||||
|
|
||||||
if(o == null) {
|
if(o == null) {
|
||||||
sender().sendMessage(C.YELLOW + "You need to hold your wand!");
|
sender().sendMessage(C.YELLOW + "You need to hold your wand!");
|
||||||
@@ -398,7 +394,7 @@ public class CommandObject implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
|
Location[] b = WandSVC.getCuboid(player());
|
||||||
Location a1 = b[0].clone();
|
Location a1 = b[0].clone();
|
||||||
Location a2 = b[1].clone();
|
Location a2 = b[1].clone();
|
||||||
Direction d = Direction.closest(player().getLocation().getDirection()).reverse();
|
Direction d = Direction.closest(player().getLocation().getDirection()).reverse();
|
||||||
@@ -430,15 +426,16 @@ public class CommandObject implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<Location, Location> locs = WorldEditLink.getSelection(sender().player());
|
Cuboid locs = WorldEditLink.getSelection(sender().player());
|
||||||
if(locs.getFirst() == null)
|
|
||||||
sender().sendMessage(C.RED + "You don't have a WorldEdit selection!");
|
if(locs == null)
|
||||||
else if(locs.getSecond() == null)
|
{
|
||||||
sender().sendMessage(C.RED + "You need a valid WorldRegion selection in the current world!");
|
sender().sendMessage(C.RED + "You don't have a WorldEdit selection in this world.");
|
||||||
else {
|
return;
|
||||||
sender().player().getInventory().addItem(WandSVC.createWand(locs.getFirst(), locs.getSecond()));
|
|
||||||
sender().sendMessage(C.GREEN + "A fresh wand with your current WorldEdit selection on it!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
@Decree(description = "Get an object wand", sync = true)
|
||||||
@@ -455,7 +452,7 @@ public class CommandObject implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
|
Location[] b = WandSVC.getCuboid(player());
|
||||||
Location a1 = b[0].clone();
|
Location a1 = b[0].clone();
|
||||||
Location a2 = b[1].clone();
|
Location a2 = b[1].clone();
|
||||||
Location a1x = b[0].clone();
|
Location a1x = b[0].clone();
|
||||||
@@ -502,7 +499,7 @@ public class CommandObject implements DecreeExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand());
|
Location[] b = WandSVC.getCuboid(player());
|
||||||
b[0].add(new Vector(0, 1, 0));
|
b[0].add(new Vector(0, 1, 0));
|
||||||
b[1].add(new Vector(0, 1, 0));
|
b[1].add(new Vector(0, 1, 0));
|
||||||
Location a1 = b[0].clone();
|
Location a1 = b[0].clone();
|
||||||
|
|||||||
@@ -1,32 +1,37 @@
|
|||||||
package com.volmit.iris.core.link;
|
package com.volmit.iris.core.link;
|
||||||
|
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.volmit.iris.util.data.Cuboid;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import org.bukkit.World;
|
||||||
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 org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class WorldEditLink {
|
public class WorldEditLink {
|
||||||
|
public static Cuboid getSelection(Player p)
|
||||||
public static Pair<Location, Location> getSelection(Player p) {
|
{
|
||||||
LocalSession session = WorldEdit.getInstance().getSessionManager().getIfPresent(BukkitAdapter.adapt(p));
|
try
|
||||||
try {
|
{
|
||||||
if(session == null)
|
Object instance = Class.forName("com.sk89q.worldedit.WorldEdit").getDeclaredMethod("getInstance").invoke(null);
|
||||||
throw new MissingSessionException();
|
Object sessionManager = instance.getClass().getDeclaredMethod("getSessionManager").invoke(instance);
|
||||||
Region r = session.getSelection(BukkitAdapter.adapt(p.getWorld()));
|
Object player = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", Player.class).invoke(null, p);
|
||||||
BlockVector3 p1 = r.getMinimumPoint();
|
Object localSession = sessionManager.getClass().getDeclaredMethod("getIfPresent", Class.forName("com.sk89q.worldedit.session.SessionOwner")).invoke(sessionManager, player);
|
||||||
BlockVector3 p2 = r.getMaximumPoint();
|
Object world = Class.forName("com.sk89q.worldedit.bukkit.BukkitAdapter").getDeclaredMethod("adapt", World.class).invoke(null, p.getWorld());
|
||||||
return new Pair<>(new Location(p.getWorld(), p1.getX(), p1.getY(), p1.getZ()), new Location(p.getWorld(), p2.getX(), p2.getY(), p2.getZ()));
|
Object region = localSession.getClass().getDeclaredMethod("getSelection", world.getClass()).invoke(localSession, world);
|
||||||
} catch(MissingSessionException e) {
|
Object min = region.getClass().getDeclaredMethod("getMinimumPoint").invoke(region);
|
||||||
return new Pair<>(null, new Location(null, 0, 0, 0));
|
Object max = region.getClass().getDeclaredMethod("getMaximumPoint").invoke(region);
|
||||||
} catch(IncompleteRegionException e) {
|
return new Cuboid(p.getWorld(),
|
||||||
return new Pair<>(new Location(null, 0, 0, 0), null);
|
(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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
package com.volmit.iris.core.service;
|
package com.volmit.iris.core.service;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.edit.DustRevealer;
|
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.core.wand.WandSelection;
|
||||||
import com.volmit.iris.engine.object.IrisObject;
|
import com.volmit.iris.engine.object.IrisObject;
|
||||||
import com.volmit.iris.util.collection.KList;
|
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
|
* Creates an Iris Object from the 2 coordinates selected with a wand
|
||||||
*
|
*
|
||||||
* @param wand
|
* @param p
|
||||||
* The wand itemstack
|
* The wand player
|
||||||
* @return The new object
|
* @return The new object
|
||||||
*/
|
*/
|
||||||
public static IrisObject createSchematic(ItemStack wand) {
|
public static IrisObject createSchematic(Player p) {
|
||||||
if(!isWand(wand)) {
|
if(!isHoldingWand(p)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Location[] f = getCuboid(wand);
|
Location[] f = getCuboid(p);
|
||||||
Cuboid c = new Cuboid(f[0], f[1]);
|
Cuboid c = new Cuboid(f[0], f[1]);
|
||||||
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
|
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
|
||||||
for(Block b : c) {
|
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
|
* Creates an Iris Object from the 2 coordinates selected with a wand
|
||||||
*
|
*
|
||||||
* @param wand
|
|
||||||
* The wand itemstack
|
|
||||||
* @return The new object
|
* @return The new object
|
||||||
*/
|
*/
|
||||||
public static Matter createMatterSchem(Player p, ItemStack wand) {
|
public static Matter createMatterSchem(Player p) {
|
||||||
if(!isWand(wand)) {
|
if(!isHoldingWand(p)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Location[] f = getCuboid(wand);
|
Location[] f = getCuboid(p);
|
||||||
|
|
||||||
return WorldMatter.createMatter(p.getName(), f[0], f[1]);
|
return WorldMatter.createMatter(p.getName(), f[0], f[1]);
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
@@ -226,26 +226,32 @@ public class WandSVC implements IrisService {
|
|||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static Location[] getCuboidFromItem(ItemStack 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) {
|
|
||||||
ItemMeta im = is.getItemMeta();
|
ItemMeta im = is.getItemMeta();
|
||||||
return new Location[] {stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))};
|
return new Location[] {stringToLocation(im.getLore().get(0)), stringToLocation(im.getLore().get(1))};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static Location[] getCuboid(Player p) {
|
||||||
* Is a player holding an Iris wand
|
if(isHoldingIrisWand(p))
|
||||||
*
|
{
|
||||||
* @param p
|
return getCuboidFromItem(p.getInventory().getItemInMainHand());
|
||||||
* The player
|
}
|
||||||
* @return True if they are
|
|
||||||
*/
|
Cuboid c = WorldEditLink.getSelection(p);
|
||||||
|
|
||||||
|
if(c != null)
|
||||||
|
{
|
||||||
|
return new Location[] {c.getLowerNE(), c.getUpperSW()};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isHoldingWand(Player p) {
|
public static boolean isHoldingWand(Player p) {
|
||||||
|
return isHoldingIrisWand(p) || WorldEditLink.getSelection(p) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHoldingIrisWand(Player p) {
|
||||||
ItemStack is = p.getInventory().getItemInMainHand();
|
ItemStack is = p.getInventory().getItemInMainHand();
|
||||||
return is != null && isWand(is);
|
return is != null && isWand(is);
|
||||||
}
|
}
|
||||||
@@ -286,8 +292,8 @@ public class WandSVC implements IrisService {
|
|||||||
public void tick(Player p) {
|
public void tick(Player p) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
if(isWand(p.getInventory().getItemInMainHand())) {
|
if((IrisSettings.get().getWorld().worldEditWandCUI && isHoldingWand(p)) || isWand(p.getInventory().getItemInMainHand())) {
|
||||||
Location[] d = getCuboid(p.getInventory().getItemInMainHand());
|
Location[] d = getCuboid(p);
|
||||||
new WandSelection(new Cuboid(d[0], d[1]), p).draw();
|
new WandSelection(new Cuboid(d[0], d[1]), p).draw();
|
||||||
}
|
}
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
@@ -457,7 +463,7 @@ public class WandSVC implements IrisService {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location[] f = getCuboid(item);
|
Location[] f = getCuboidFromItem(item);
|
||||||
Location other = left ? f[1] : f[0];
|
Location other = left ? f[1] : f[0];
|
||||||
|
|
||||||
if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) {
|
if(other != null && !other.getWorld().getName().equals(a.getWorld().getName())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user