mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Added optional position parameter to //pos1 and //pos2
This commit is contained in:
parent
ddcf948974
commit
7b306160d7
@ -41,47 +41,84 @@ import com.sk89q.worldedit.blocks.*;
|
|||||||
public class SelectionCommands {
|
public class SelectionCommands {
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"/pos1"},
|
aliases = {"/pos1"},
|
||||||
usage = "",
|
usage = "[coordinates]",
|
||||||
desc = "Set position 1",
|
desc = "Set position 1",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.selection.pos"})
|
@CommandPermissions({"worldedit.selection.pos"})
|
||||||
public static void pos1(CommandContext args, WorldEdit we,
|
public static void pos1(CommandContext args, WorldEdit we,
|
||||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
|
||||||
|
Vector pos;
|
||||||
|
|
||||||
|
if(args.argsLength() == 1)
|
||||||
|
{
|
||||||
|
if(args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+"))
|
||||||
|
{
|
||||||
|
String[] coords = args.getString(0).split(",");
|
||||||
|
pos = new Vector(Integer.parseInt(coords[0]),
|
||||||
|
Integer.parseInt(coords[1]),
|
||||||
|
Integer.parseInt(coords[2]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.printError("Invalid coordinates " + args.getString(0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else pos = player.getBlockIn();
|
||||||
|
|
||||||
if (!session.getRegionSelector(player.getWorld())
|
if (!session.getRegionSelector(player.getWorld())
|
||||||
.selectPrimary(player.getBlockIn())) {
|
.selectPrimary(pos)) {
|
||||||
player.printError("Position already set.");
|
player.printError("Position already set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld())
|
session.getRegionSelector(player.getWorld())
|
||||||
.explainPrimarySelection(player, session, player.getBlockIn());
|
.explainPrimarySelection(player, session, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"/pos2"},
|
aliases = {"/pos2"},
|
||||||
usage = "",
|
usage = "[coordinates]",
|
||||||
desc = "Set position 2",
|
desc = "Set position 2",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.selection.pos"})
|
@CommandPermissions({"worldedit.selection.pos"})
|
||||||
public static void pos2(CommandContext args, WorldEdit we,
|
public static void pos2(CommandContext args, WorldEdit we,
|
||||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
|
||||||
|
Vector pos;
|
||||||
|
if(args.argsLength() == 1)
|
||||||
|
{
|
||||||
|
if(args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+"))
|
||||||
|
{
|
||||||
|
String[] coords = args.getString(0).split(",");
|
||||||
|
pos = new Vector(Integer.parseInt(coords[0]),
|
||||||
|
Integer.parseInt(coords[1]),
|
||||||
|
Integer.parseInt(coords[2]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.printError("Invalid coordinates " + args.getString(0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else pos = player.getBlockIn();
|
||||||
|
|
||||||
if (!session.getRegionSelector(player.getWorld())
|
if (!session.getRegionSelector(player.getWorld())
|
||||||
.selectSecondary(player.getBlockIn())) {
|
.selectSecondary(pos)) {
|
||||||
player.printError("Position already set.");
|
player.printError("Position already set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld())
|
session.getRegionSelector(player.getWorld())
|
||||||
.explainSecondarySelection(player, session, player.getBlockIn());
|
.explainSecondarySelection(player, session, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
Loading…
Reference in New Issue
Block a user