diff --git a/pom.xml b/pom.xml
index 8ab31bb..c25b8e4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
tech.sbdevelopment
V10Lift
- 0.8
+ 0.9
jar
V10Lift
@@ -146,6 +146,10 @@
jitpack.io
https://jitpack.io
+
+ enginehub-maven
+ https://maven.enginehub.org/repo/
+
@@ -196,5 +200,13 @@
5.0.1
compile
+
+
+
+ com.sk89q.worldedit
+ worldedit-bukkit
+ 7.2.9
+ provided
+
\ No newline at end of file
diff --git a/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftCommand.java b/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftCommand.java
index 12d92fe..381b439 100644
--- a/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftCommand.java
+++ b/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftCommand.java
@@ -1,6 +1,14 @@
package tech.sbdevelopment.v10lift.commands;
import com.cryptomorin.xseries.XMaterial;
+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.BlockVector2;
+import com.sk89q.worldedit.regions.CuboidRegion;
+import com.sk89q.worldedit.regions.Polygonal2DRegion;
+import com.sk89q.worldedit.regions.Region;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@@ -131,6 +139,17 @@ public class V10LiftCommand implements CommandExecutor {
} else {
ConfigUtil.sendMessage(sender, "General.NoPermission");
}
+ } else if (args[0].equalsIgnoreCase("build") && args.length == 2 && args[1].equalsIgnoreCase("worldedit")) {
+ //v10lift build worldedit
+ if (!(sender instanceof Player)) {
+ ConfigUtil.sendMessage(sender, "General.PlayerOnly");
+ return true;
+ }
+ if (sender.hasPermission("v10lift.build") || sender.hasPermission("v10lift.admin")) {
+ return buildWorldEditCommand(sender);
+ } else {
+ ConfigUtil.sendMessage(sender, "General.NoPermission");
+ }
} else if (args[0].equalsIgnoreCase("rope") && args.length == 2) {
//v10lift rope add || v10lift rope del
if (!(sender instanceof Player)) {
@@ -784,6 +803,86 @@ public class V10LiftCommand implements CommandExecutor {
return true;
}
+ private boolean buildWorldEditCommand(CommandSender sender) {
+ Player p = (Player) sender;
+ if (!DataManager.containsEditPlayer(p.getUniqueId())) {
+ ConfigUtil.sendMessage(sender, "General.SwitchOnEdit");
+ return true;
+ }
+
+ if (!DataManager.containsBuilderPlayer(p.getUniqueId())) {
+ DataManager.addBuilderPlayer(p.getUniqueId());
+ }
+
+ LocalSession ls = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(p));
+ Region region;
+ try {
+ region = ls.getSelection(BukkitAdapter.adapt(p.getWorld()));
+ } catch (IncompleteRegionException e) {
+ throw new RuntimeException(e);
+ }
+ if (region == null) {
+ ConfigUtil.sendMessage(sender, "Build.NoSelection");
+ return true;
+ }
+
+ List blocks = new ArrayList<>();
+ boolean success = true;
+ int failed = 0;
+ if (region instanceof Polygonal2DRegion) {
+ //Get all blocks in region
+ Polygonal2DRegion poly = (Polygonal2DRegion) region;
+ for (BlockVector2 bv : poly.getPoints()) {
+ for (int y = poly.getMinimumPoint().getBlockY(); y <= poly.getMaximumPoint().getBlockY(); y++) {
+ Block b = p.getWorld().getBlockAt(bv.getBlockX(), y, bv.getBlockZ());
+ if (b.getType() == Material.AIR) continue;
+
+ if (V10LiftAPI.getInstance().switchBlockAtLift(DataManager.getEditPlayer(p.getUniqueId()), b) == 0) {
+ blocks.add(b);
+ continue;
+ }
+ success = false;
+ failed++;
+ }
+ }
+ } else if (region instanceof CuboidRegion) {
+ //Get all blocks in region
+ CuboidRegion cuboid = (CuboidRegion) region;
+ for (int x = cuboid.getMinimumPoint().getBlockX(); x <= cuboid.getMaximumPoint().getBlockX(); x++) {
+ for (int y = cuboid.getMinimumPoint().getBlockY(); y <= cuboid.getMaximumPoint().getBlockY(); y++) {
+ for (int z = cuboid.getMinimumPoint().getBlockZ(); z <= cuboid.getMaximumPoint().getBlockZ(); z++) {
+ Block b = p.getWorld().getBlockAt(x, y, z);
+ if (b.getType() == Material.AIR) continue;
+
+ if (V10LiftAPI.getInstance().switchBlockAtLift(DataManager.getEditPlayer(p.getUniqueId()), b) == 0) {
+ blocks.add(b);
+ continue;
+ }
+ success = false;
+ failed++;
+ }
+ }
+ }
+ } else {
+ ConfigUtil.sendMessage(sender, "Build.UnsupportedSelection");
+ return true;
+ }
+
+ if (success) {
+ ConfigUtil.sendMessage(sender, "Build.BlocksAdded");
+ } else {
+ ConfigUtil.sendMessage(sender, "Build.BlocksFailed", Collections.singletonMap("%Failed%", String.valueOf(failed)));
+ }
+
+ if (DataManager.containsBuilderPlayer(p.getUniqueId())) {
+ DataManager.removeBuilderPlayer(p.getUniqueId());
+ V10LiftAPI.getInstance().sortLiftBlocks(DataManager.getEditPlayer(p.getUniqueId()));
+ ConfigUtil.sendMessage(sender, "Build.Disabled");
+ }
+
+ return true;
+ }
+
private boolean buildCommand(CommandSender sender) {
Player p = (Player) sender;
if (!DataManager.containsEditPlayer(p.getUniqueId())) {
diff --git a/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftTabCompleter.java b/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftTabCompleter.java
index d804d12..ce22a69 100644
--- a/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftTabCompleter.java
+++ b/src/main/java/tech/sbdevelopment/v10lift/commands/V10LiftTabCompleter.java
@@ -76,6 +76,8 @@ public class V10LiftTabCompleter implements TabCompleter {
return StringUtil.copyPartialMatches(args[2], playerOrGroupNames, new ArrayList<>());
} else if (args[0].equalsIgnoreCase("setoffline")) {
return StringUtil.copyPartialMatches(args[2], BOOL, new ArrayList<>());
+ } else if (args[0].equalsIgnoreCase("build")) {
+ return StringUtil.copyPartialMatches(args[2], List.of("worldedit"), new ArrayList<>());
}
} else if (args.length == 4) {
//Command based arguments
diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml
index 6f6e6d3..2962512 100644
--- a/src/main/resources/messages.yml
+++ b/src/main/resources/messages.yml
@@ -72,6 +72,10 @@ Build:
BlockAdded: '&aBlock added to the elevator.'
BlockRemoved: '&6Block removed from the elevator.'
BlacklistedMaterial: '&cThe material %Name% cannot be used!'
+ NoSelection: '&cYou must select a region with the WorldEdit wand first!'
+ UnsupportedSelection: '&cThe selection must be cuboid or polygonal!'
+ BlocksAdded: '&aBlocks added to the elevator.'
+ BlocksFailed: '&cNot all blocks could be added to the elevator. Failure amount: %Failed%'
Rope:
StillAdjusting: '&cYou are still adjusting a rope.'