Added super pick axe and /..

Dieser Commit ist enthalten in:
sk89q 2010-10-13 11:26:07 -07:00
Ursprung 598f4aa6cd
Commit 23b24b3615
4 geänderte Dateien mit 83 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -71,6 +71,7 @@ public class WorldEdit {
commands.put("/editpos2", "Set editing position #2"); commands.put("/editpos2", "Set editing position #2");
commands.put("/editwand", "Gives you the \"edit wand\""); commands.put("/editwand", "Gives you the \"edit wand\"");
commands.put("/toggleeditwand", "Toggles edit wand selection"); commands.put("/toggleeditwand", "Toggles edit wand selection");
commands.put("/.", "Toggles super pick axe.");
commands.put("/editundo", "Undo"); commands.put("/editundo", "Undo");
commands.put("/editredo", "Redo"); commands.put("/editredo", "Redo");
commands.put("/clearhistory", "Clear history"); commands.put("/clearhistory", "Clear history");
@ -259,6 +260,16 @@ public class WorldEdit {
} }
return true; return true;
// Toggle super pick axe
} else if (split[0].equalsIgnoreCase("/.")) {
checkArgs(split, 0, 0, split[0]);
if (session.toggleSuperPickAxe()) {
player.print("Super pick axe enabled.");
} else {
player.print("Super pick axe disabled.");
}
return true;
// Set max number of blocks to change at a time // Set max number of blocks to change at a time
} else if (split[0].equalsIgnoreCase("/editlimit")) { } else if (split[0].equalsIgnoreCase("/editlimit")) {
checkArgs(split, 1, 1, split[0]); checkArgs(split, 1, 1, split[0]);

Datei anzeigen

@ -98,6 +98,17 @@ public class WorldEditPlayer {
return player.getItemInHand(); return player.getItemInHand();
} }
/**
* Returns true if the player is holding a pick axe.
*
* @return whether a pick axe is held
*/
public boolean isHoldingPickAxe() {
int item = getItemInHand();
return item == 271 || item == 270 || item == 274 || item == 278
|| item == 285;
}
/** /**
* Get the player's cardinal direction (N, W, NW, etc.). * Get the player's cardinal direction (N, W, NW, etc.).
* *

Datei anzeigen

@ -91,13 +91,18 @@ public class WorldEditSMListener extends PluginListener {
*/ */
@Override @Override
public boolean onBlockDestroy(Player modPlayer, Block blockClicked) { public boolean onBlockDestroy(Player modPlayer, Block blockClicked) {
if (!modPlayer.canUseCommand("/editpos1")
&& !modPlayer.canUseCommand("/.")) { return false; }
WorldEditPlayer player = new WorldEditPlayer(modPlayer); WorldEditPlayer player = new WorldEditPlayer(modPlayer);
if (player.getItemInHand() != 271) { return false; }
if (!modPlayer.canUseCommand("/editpos1")) { return false; }
WorldEditSession session = worldEdit.getSession(player); WorldEditSession session = worldEdit.getSession(player);
if (player.isHoldingPickAxe()) {
if (session.hasSuperPickAxe()) {
return etc.getMCServer().e.d(blockClicked.getX(),
blockClicked.getY(), blockClicked.getZ(), 0);
}
} else if (player.getItemInHand() == 271) {
if (session.isToolControlEnabled()) { if (session.isToolControlEnabled()) {
Vector cur = Vector.toBlockPoint(blockClicked.getX(), Vector cur = Vector.toBlockPoint(blockClicked.getX(),
blockClicked.getY(), blockClicked.getY(),
@ -115,6 +120,7 @@ public class WorldEditSMListener extends PluginListener {
return true; return true;
} }
}
return false; return false;
} }

Datei anzeigen

@ -32,6 +32,7 @@ public class WorldEditSession {
private int historyPointer = 0; private int historyPointer = 0;
private CuboidClipboard clipboard; private CuboidClipboard clipboard;
private boolean toolControl = true; private boolean toolControl = true;
private boolean superPickAxe = false;
private int maxBlocksChanged = -1; private int maxBlocksChanged = -1;
/** /**
@ -242,4 +243,41 @@ public class WorldEditSession {
public void setBlockChangeLimit(int maxBlocksChanged) { public void setBlockChangeLimit(int maxBlocksChanged) {
this.maxBlocksChanged = maxBlocksChanged; this.maxBlocksChanged = maxBlocksChanged;
} }
/**
* Checks whether the super pick axe is enabled.
*
* @return status
*/
public boolean hasSuperPickAxe() {
return superPickAxe;
}
/**
* Enable super pick axe.
*
* @param superPickAxe
*/
public void enableSuperPickAxe() {
superPickAxe = true;
}
/**
* Disable super pick axe.
*
* @param superPickAxe
*/
public void disableSuperPickAxe() {
superPickAxe = false;
}
/**
* Toggle the super pick axe.
*
* @return status
*/
public boolean toggleSuperPickAxe() {
superPickAxe = !superPickAxe;
return superPickAxe;
}
} }