mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 10:39:07 +00:00
Added ability to create Iris Wand from WorldEdit selection.
This commit is contained in:
@@ -18,7 +18,9 @@
|
||||
|
||||
package com.volmit.iris.core.commands;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.link.WorldEditLink;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.service.ObjectSVC;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
@@ -41,12 +43,7 @@ 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.ChatColor;
|
||||
import org.bukkit.HeightMap;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.TileState;
|
||||
@@ -426,6 +423,24 @@ public class CommandObject implements DecreeExecutor {
|
||||
sender().sendMessage("Reverted " + actualReverts + " pastes!");
|
||||
}
|
||||
|
||||
@Decree(description = "Gets an object wand and grabs the current WorldEdit selection.", aliases = "we", origin = DecreeOrigin.PLAYER, studio = true)
|
||||
public void we() {
|
||||
if(!Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||
sender().sendMessage(C.RED + "You can't get a WorldEdit selection without WorldEdit, you know.");
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "Get an object wand", sync = true)
|
||||
public void wand() {
|
||||
player().getInventory().addItem(WandSVC.createWand());
|
||||
|
||||
32
src/main/java/com/volmit/iris/core/link/WorldEditLink.java
Normal file
32
src/main/java/com/volmit/iris/core/link/WorldEditLink.java
Normal file
@@ -0,0 +1,32 @@
|
||||
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 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -233,20 +233,17 @@ public class IrisToolbelt {
|
||||
return isIrisWorld(i) && access(i).isStudio();
|
||||
}
|
||||
|
||||
public static void retainMantleDataForSlice(String className)
|
||||
{
|
||||
public static void retainMantleDataForSlice(String className) {
|
||||
toolbeltConfiguration.put("retain.mantle." + className, true);
|
||||
}
|
||||
|
||||
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of)
|
||||
{
|
||||
public static <T> T getMantleData(World world, int x, int y, int z, Class<T> of) {
|
||||
PlatformChunkGenerator e = access(world);
|
||||
if(e == null) {return null;}
|
||||
return e.getEngine().getMantle().getMantle().get(x, y - world.getMinHeight(), z, of);
|
||||
}
|
||||
|
||||
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of)
|
||||
{
|
||||
public static <T> void deleteMantleData(World world, int x, int y, int z, Class<T> of) {
|
||||
PlatformChunkGenerator e = access(world);
|
||||
if(e == null) {return;}
|
||||
e.getEngine().getMantle().getMantle().remove(x, y - world.getMinHeight(), z, of);
|
||||
|
||||
Reference in New Issue
Block a user