mirror of
https://github.com/taoneill/war.git
synced 2025-01-03 06:17:33 +01:00
Update WorldEdit Integration
Breaking, now requires WorldEdit newer than Oct. 18, 2018
This commit is contained in:
parent
5e4f0022df
commit
a0174935fe
35
war/pom.xml
35
war/pom.xml
@ -15,21 +15,17 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven.cmastudios.me</id>
|
||||
<url>https://maven.cmastudios.me/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>cma-repo</id>
|
||||
<url>http://ftp.cmastudios.me/maven/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>tagapi-repo</id>
|
||||
<url>http://repo.kitteh.org/content/repositories/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<issueManagement>
|
||||
@ -48,8 +44,8 @@
|
||||
</scm>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>cma-repo</id>
|
||||
<url>ftp://ftp.cmastudios.me/srv/ftp/maven</url>
|
||||
<id>maven.cmastudios.me</id>
|
||||
<url>s3://maven.cmastudios.me/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
@ -93,8 +89,9 @@
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ftp</artifactId>
|
||||
<groupId>org.kuali.maven.wagons</groupId>
|
||||
<artifactId>maven-s3-wagon</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<resources>
|
||||
@ -137,9 +134,15 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>5.5.8</version>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.0-20181118.055910-28</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-core</artifactId>
|
||||
<version>7.0.0-20181118.055910-28</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1,13 +1,9 @@
|
||||
package com.tommytony.war.command;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.utility.Compat;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
|
||||
|
||||
public class SetZoneCommand extends AbstractZoneMakerCommand {
|
||||
@ -30,20 +26,15 @@ public class SetZoneCommand extends AbstractZoneMakerCommand {
|
||||
} else if (this.args.length > 2) {
|
||||
return false;
|
||||
} else if (this.args.length == 1) {
|
||||
if (War.war.getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||
WorldEditPlugin worldEdit = (WorldEditPlugin) War.war.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
Selection selection = worldEdit.getSelection(player);
|
||||
if (selection != null && selection instanceof CuboidSelection) {
|
||||
Location min = selection.getMinimumPoint();
|
||||
Location max = selection.getMaximumPoint();
|
||||
ZoneSetter setter = new ZoneSetter(player, this.args[0]);
|
||||
setter.placeCorner1(min.getBlock());
|
||||
setter.placeCorner2(max.getBlock());
|
||||
return true;
|
||||
}
|
||||
Compat.BlockPair pair = Compat.getWorldEditSelection(player);
|
||||
if (pair != null) {
|
||||
ZoneSetter setter = new ZoneSetter(player, this.args[0]);
|
||||
setter.placeCorner1(pair.getBlock1());
|
||||
setter.placeCorner2(pair.getBlock2());
|
||||
return true;
|
||||
}
|
||||
War.war.addWandBearer(player, this.args[0]);
|
||||
} else if (this.args.length == 2) {
|
||||
} else {
|
||||
if (!this.args[1].equals("southeast") && !this.args[1].equals("northwest") && !this.args[1].equals("se") && !this.args[1].equals("nw") && !this.args[1].equals("corner1") && !this.args[1].equals("corner2") && !this.args[1].equals("c1") && !this.args[1].equals("c2") && !this.args[1].equals("pos1") && !this.args[1].equals("pos2") && !this.args[1].equals("wand")) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,14 +1,11 @@
|
||||
package com.tommytony.war.ui;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.command.ZoneSetter;
|
||||
import com.tommytony.war.utility.Compat;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -38,14 +35,13 @@ public class EditOrCreateZoneUI extends ChestUI {
|
||||
War.war.getUIManager().getPlayerMessage(player, "Select region for zone using WorldEdit and then type a name:", new StringRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WorldEditPlugin worldEdit = (WorldEditPlugin) War.war.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
Selection selection = worldEdit.getSelection(player);
|
||||
if (selection != null && selection instanceof CuboidSelection) {
|
||||
Location min = selection.getMinimumPoint();
|
||||
Location max = selection.getMaximumPoint();
|
||||
Compat.BlockPair pair = Compat.getWorldEditSelection(player);
|
||||
if (pair != null) {
|
||||
ZoneSetter setter = new ZoneSetter(player, this.getValue());
|
||||
setter.placeCorner1(min.getBlock());
|
||||
setter.placeCorner2(max.getBlock());
|
||||
setter.placeCorner1(pair.getBlock1());
|
||||
setter.placeCorner2(pair.getBlock2());
|
||||
} else {
|
||||
War.war.badMsg(player, "Invalid selection. Creation cancelled.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,17 @@
|
||||
package com.tommytony.war.utility;
|
||||
|
||||
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.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.tommytony.war.War;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -16,4 +27,46 @@ public class Compat {
|
||||
is.setItemMeta(meta);
|
||||
return is;
|
||||
}
|
||||
|
||||
public static class BlockPair {
|
||||
final Block block1;
|
||||
final Block block2;
|
||||
|
||||
BlockPair(Block block1, Block block2) {
|
||||
this.block1 = block1;
|
||||
this.block2 = block2;
|
||||
}
|
||||
|
||||
public Block getBlock1() {
|
||||
return block1;
|
||||
}
|
||||
|
||||
public Block getBlock2() {
|
||||
return block2;
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockPair getWorldEditSelection(Player player) {
|
||||
if (!War.war.getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||
return null;
|
||||
}
|
||||
BukkitPlayer wp = BukkitAdapter.adapt(player);
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(wp);
|
||||
try {
|
||||
Region selection = session.getSelection(wp.getWorld());
|
||||
if (selection instanceof CuboidRegion) {
|
||||
BlockVector3 min = selection.getMinimumPoint();
|
||||
BlockVector3 max = selection.getMaximumPoint();
|
||||
return new BlockPair(
|
||||
player.getWorld().getBlockAt(min.getBlockX(), min.getBlockY(), min.getBlockZ()),
|
||||
player.getWorld().getBlockAt(max.getBlockX(), max.getBlockY(), max.getBlockZ())
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user