Added back in /worldedit for permissions purposes.

This commit is contained in:
sk89q 2010-10-18 10:47:23 -07:00
parent 6c33aa44e2
commit 765575b433

View File

@ -51,7 +51,7 @@ public class SMWorldEditListener extends PluginListener {
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer); WorldEditPlayer player = new SMWorldEditPlayer(modPlayer);
if (itemInHand != 271) { return false; } if (itemInHand != 271) { return false; }
if (!modPlayer.canUseCommand("/editpos2")) { return false; } if (!canUseCommand(modPlayer, "/editpos2")) { return false; }
WorldEditSession session = worldEdit.getSession(player); WorldEditSession session = worldEdit.getSession(player);
@ -79,8 +79,8 @@ public class SMWorldEditListener extends PluginListener {
*/ */
@Override @Override
public boolean onBlockDestroy(Player modPlayer, Block blockClicked) { public boolean onBlockDestroy(Player modPlayer, Block blockClicked) {
if (!modPlayer.canUseCommand("/editpos1") if (!canUseCommand(modPlayer, "/editpos1")
&& !modPlayer.canUseCommand("/.")) { return false; } && !canUseCommand(modPlayer, "/.")) { return false; }
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEdit worldEdit = WorldEdit.getInstance();
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer); WorldEditPlayer player = new SMWorldEditPlayer(modPlayer);
@ -132,7 +132,7 @@ public class SMWorldEditListener extends PluginListener {
try { try {
if (worldEdit.getCommands().containsKey(split[0])) { if (worldEdit.getCommands().containsKey(split[0])) {
if (modPlayer.canUseCommand(split[0])) { if (canUseCommand(modPlayer, split[0])) {
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer); WorldEditPlayer player = new SMWorldEditPlayer(modPlayer);
WorldEditSession session = worldEdit.getSession(player); WorldEditSession session = worldEdit.getSession(player);
EditSession editSession = EditSession editSession =
@ -176,4 +176,16 @@ public class SMWorldEditListener extends PluginListener {
return true; return true;
} }
/**
* Checks to see if the player can use a command or /worldedit.
*
* @param player
* @param command
* @return
*/
private boolean canUseCommand(Player player, String command) {
return player.canUseCommand(command)
|| player.canUseCommand("/worldedit");
}
} }