3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Added permissions support for the tools.

Dieser Commit ist enthalten in:
sk89q 2010-11-26 19:37:37 -08:00
Ursprung 0ec0b42026
Commit 9ff5c6375a
2 geänderte Dateien mit 43 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -137,7 +137,7 @@ public class WorldEditListener extends PluginListener {
commands.put("//drain", "[Radius] - Drain nearby water/lava pools"); commands.put("//drain", "[Radius] - Drain nearby water/lava pools");
commands.put("//limit", "[Num] - See documentation"); commands.put("//limit", "[Num] - See documentation");
commands.put("//mode", "[Mode] <Size> - Set super pickaxe mode (single/recursive/area)"); commands.put("//mode", "[Mode] <Size> - Set super pickaxe mode (single/recursive/area)");
commands.put("//tool", "[Tool] - Set pickaxe tool (none/tree)"); commands.put("//tool", "[Tool] - Set pickaxe tool (none/tree/info)");
commands.put("//expand", "[Num] <Dir> - Expands the selection"); commands.put("//expand", "[Num] <Dir> - Expands the selection");
commands.put("//contract", "[Num] <Dir> - Contracts the selection"); commands.put("//contract", "[Num] <Dir> - Contracts the selection");
commands.put("//rotate", "[Angle] - Rotate the clipboard"); commands.put("//rotate", "[Angle] - Rotate the clipboard");
@ -627,9 +627,17 @@ public class WorldEditListener extends PluginListener {
session.setTool(WorldEditSession.Tool.NONE); session.setTool(WorldEditSession.Tool.NONE);
player.print("No tool equipped. -3 XP, +10 Manliness"); player.print("No tool equipped. -3 XP, +10 Manliness");
} else if (split[1].equalsIgnoreCase("tree")) { } else if (split[1].equalsIgnoreCase("tree")) {
if (!canUseCommand(player, "/treetool")) {
player.printError("You do not have the /treetool permission.");
return true;
}
session.setTool(WorldEditSession.Tool.TREE); session.setTool(WorldEditSession.Tool.TREE);
player.print("Tree planting tool equipped. +5 XP"); player.print("Tree planting tool equipped. +5 XP");
} else if (split[1].equalsIgnoreCase("info")) { } else if (split[1].equalsIgnoreCase("info")) {
if (!canUseCommand(player, "/infotool")) {
player.printError("You do not have the /infotool permission.");
return true;
}
session.setTool(WorldEditSession.Tool.INFO); session.setTool(WorldEditSession.Tool.INFO);
player.print("Block information tool equipped."); player.print("Block information tool equipped.");
} else { } else {
@ -1957,6 +1965,17 @@ public class WorldEditListener extends PluginListener {
|| player.canUseCommand("/worldedit"); || player.canUseCommand("/worldedit");
} }
/**
* Checks to see if the player can use a command or /worldedit.
*
* @param player
* @param command
* @return
*/
private boolean canUseCommand(WorldEditPlayer player, String command) {
return canUseCommand(player.getPlayerObject(), command);
}
/** /**
* Loads the configuration. * Loads the configuration.
*/ */

Datei anzeigen

@ -289,7 +289,7 @@ public class WorldEditPlayer {
* @return point * @return point
*/ */
public Vector getBlockIn() { public Vector getBlockIn() {
return Vector.toBlockPoint(player.getX(), player.getY(), player.getZ()); return Vector.toBlockPoint(getPlayer().getX(), getPlayer().getY(), getPlayer().getZ());
} }
/** /**
@ -298,7 +298,7 @@ public class WorldEditPlayer {
* @return point * @return point
*/ */
public Vector getBlockOn() { public Vector getBlockOn() {
return Vector.toBlockPoint(player.getX(), player.getY() - 1, player.getZ()); return Vector.toBlockPoint(getPlayer().getX(), getPlayer().getY() - 1, getPlayer().getZ());
} }
/** /**
@ -308,7 +308,7 @@ public class WorldEditPlayer {
* @return point * @return point
*/ */
public Vector getBlockTrace(int range) { public Vector getBlockTrace(int range) {
HitBlox hitBlox = new HitBlox(player, range, 0.2); HitBlox hitBlox = new HitBlox(getPlayer(),range, 0.2);
Block block = hitBlox.getTargetBlock(); Block block = hitBlox.getTargetBlock();
if (block == null) { if (block == null) {
return null; return null;
@ -323,7 +323,7 @@ public class WorldEditPlayer {
* @return point * @return point
*/ */
public Vector getSolidBlockTrace(int range) { public Vector getSolidBlockTrace(int range) {
HitBlox hitBlox = new HitBlox(player, range, 0.2); HitBlox hitBlox = new HitBlox(getPlayer(),range, 0.2);
Block block = null; Block block = null;
while (hitBlox.getNextBlock() != null while (hitBlox.getNextBlock() != null
@ -362,7 +362,7 @@ public class WorldEditPlayer {
* @return * @return
*/ */
public int getItemInHand() { public int getItemInHand() {
return player.getItemInHand(); return getPlayer().getItemInHand();
} }
/** /**
@ -371,7 +371,7 @@ public class WorldEditPlayer {
* @return String * @return String
*/ */
public String getName() { public String getName() {
return player.getName(); return getPlayer().getName();
} }
/** /**
@ -385,7 +385,7 @@ public class WorldEditPlayer {
* @return pitch * @return pitch
*/ */
public double getPitch() { public double getPitch() {
return player.getPitch(); return getPlayer().getPitch();
} }
/** /**
@ -394,7 +394,7 @@ public class WorldEditPlayer {
* @return point * @return point
*/ */
public Vector getPosition() { public Vector getPosition() {
return new Vector(player.getX(), player.getY(), player.getZ()); return new Vector(getPlayer().getX(), getPlayer().getY(), getPlayer().getZ());
} }
/** /**
@ -408,7 +408,7 @@ public class WorldEditPlayer {
* @return yaw * @return yaw
*/ */
public double getYaw() { public double getYaw() {
return player.getRotation(); return getPlayer().getRotation();
} }
/** /**
@ -424,7 +424,7 @@ public class WorldEditPlayer {
* @param amt * @param amt
*/ */
public void giveItem(int type, int amt) { public void giveItem(int type, int amt) {
player.giveItem(type, amt); getPlayer().giveItem(type, amt);
} }
/** /**
@ -436,7 +436,7 @@ public class WorldEditPlayer {
public boolean passThroughForwardWall(int range) { public boolean passThroughForwardWall(int range) {
boolean foundNext = false; boolean foundNext = false;
int searchDist = 0; int searchDist = 0;
HitBlox hitBlox = new HitBlox(player, range, 0.2); HitBlox hitBlox = new HitBlox(getPlayer(),range, 0.2);
Block block; Block block;
while ((block = hitBlox.getNextBlock()) != null) { while ((block = hitBlox.getNextBlock()) != null) {
searchDist++; searchDist++;
@ -464,7 +464,7 @@ public class WorldEditPlayer {
* @param msg * @param msg
*/ */
public void printRaw(String msg) { public void printRaw(String msg) {
player.sendMessage(msg); getPlayer().sendMessage(msg);
} }
/** /**
@ -473,7 +473,7 @@ public class WorldEditPlayer {
* @param msg * @param msg
*/ */
public void print(String msg) { public void print(String msg) {
player.sendMessage(Colors.LightPurple + msg); getPlayer().sendMessage(Colors.LightPurple + msg);
} }
/** /**
@ -482,7 +482,7 @@ public class WorldEditPlayer {
* @param msg * @param msg
*/ */
public void printError(String msg) { public void printError(String msg) {
player.sendMessage(Colors.Rose + msg); getPlayer().sendMessage(Colors.Rose + msg);
} }
/** /**
@ -499,7 +499,7 @@ public class WorldEditPlayer {
loc.z = pos.getZ(); loc.z = pos.getZ();
loc.rotX = (float) yaw; loc.rotX = (float) yaw;
loc.rotY = (float) pitch; loc.rotY = (float) pitch;
player.teleportTo(loc); getPlayer().teleportTo(loc);
} }
/** /**
@ -508,6 +508,13 @@ public class WorldEditPlayer {
* @return * @return
*/ */
public String[] getGroups() { public String[] getGroups() {
return player.getGroups(); return getPlayer().getGroups();
}
/**
* @return the player
*/
public Player getPlayerObject() {
return player;
} }
} }