Create zones with WorldEdit cuboid selections

The WorldEdit API is utilized to allow the use of WorldEdit selections
when creating or modifying a warzone. If the current player has a
WorldEdit selection when the /setzone command is used, this selection will
be used for the zone's corners.
This commit is contained in:
cmastudios 2013-06-08 22:55:35 -05:00
parent da14a8fc4d
commit 21688ba4d0
3 changed files with 29 additions and 1 deletions

View File

@ -25,6 +25,10 @@
<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>
</repository>
</repositories>
<issueManagement>
<system>Github issues</system>
@ -92,5 +96,11 @@
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>5.5.6</version>
<type>jar</type>
</dependency>
</dependencies>
</project>

View File

@ -1,7 +1,10 @@
package com.tommytony.war.command;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.Location;
import com.tommytony.war.War;
@ -26,6 +29,18 @@ 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) {
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;
}
}
War.war.addWandBearer(player, this.args[0]);
} else if (this.args.length == 2) {
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")) {

View File

@ -4,7 +4,7 @@ description: Minecraft PVP arenas (called warzones) for a fast-paced and structu
author: tommytony
website: http://war.tommytony.com
main: com.tommytony.war.War
softdepend: [Spout, TagAPI]
softdepend: [Spout, TagAPI, WorldEdit]
permissions:
war.*:
description: Full War permissions. Create and destroy warzones. Change War configuration.
@ -99,6 +99,9 @@ commands:
2) Left-click to select or move corner1,
3) Right-click to select or move corner2.
Turn off wand by dropping the wooden sword.
\\\\ WorldEdit Cuboid mode \\
1) Create a cuboid selection using WorldEdit
2) /setzone <zone-name>
\\\\ Wandless Cuboid mode \\
/setzone <zone-name> <corner1/corner2/c1/c2/pos1/pos2>
savezone: