mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Added permission checks for tools on /use/, so now if you switch world or lose your permissions, you lose your tools.
This commit is contained in:
parent
5755755c15
commit
a18546d698
@ -455,7 +455,7 @@ public class LocalSession {
|
|||||||
Tool tool = getTool(item);
|
Tool tool = getTool(item);
|
||||||
|
|
||||||
if (tool == null || !(tool instanceof BrushTool)) {
|
if (tool == null || !(tool instanceof BrushTool)) {
|
||||||
tool = new BrushTool();
|
tool = new BrushTool("worldedit.brush.sphere");
|
||||||
setTool(item, tool);
|
setTool(item, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,8 +834,10 @@ public class WorldEdit {
|
|||||||
Tool tool = session.getTool(player.getItemInHand());
|
Tool tool = session.getTool(player.getItemInHand());
|
||||||
|
|
||||||
if (tool != null && tool instanceof TraceTool) {
|
if (tool != null && tool instanceof TraceTool) {
|
||||||
((TraceTool)tool).act(server, config, player, session);
|
if (tool.canUse(player)) {
|
||||||
return true;
|
((TraceTool)tool).act(server, config, player, session);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -866,8 +868,10 @@ public class WorldEdit {
|
|||||||
Tool tool = session.getTool(player.getItemInHand());
|
Tool tool = session.getTool(player.getItemInHand());
|
||||||
|
|
||||||
if (tool != null && tool instanceof BlockTool) {
|
if (tool != null && tool instanceof BlockTool) {
|
||||||
((BlockTool)tool).actPrimary(server, config, player, session, clicked);
|
if (tool.canUse(player)) {
|
||||||
return true;
|
((BlockTool)tool).actPrimary(server, config, player, session, clicked);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -901,16 +905,20 @@ public class WorldEdit {
|
|||||||
}
|
}
|
||||||
} else if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
|
} else if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
|
||||||
if (session.getSuperPickaxe() != null) {
|
if (session.getSuperPickaxe() != null) {
|
||||||
return session.getSuperPickaxe().actPrimary(server, config,
|
if (session.getSuperPickaxe().canUse(player)) {
|
||||||
player, session, clicked);
|
return session.getSuperPickaxe().actPrimary(server, config,
|
||||||
|
player, session, clicked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tool tool = session.getTool(player.getItemInHand());
|
Tool tool = session.getTool(player.getItemInHand());
|
||||||
|
|
||||||
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
if (tool != null && tool instanceof DoubleActionBlockTool) {
|
||||||
((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked);
|
if (tool.canUse(player)) {
|
||||||
return true;
|
((DoubleActionBlockTool)tool).actSecondary(server, config, player, session, clicked);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -77,9 +77,9 @@ public class BrushCommands {
|
|||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
|
|
||||||
if (args.hasFlag('h')) {
|
if (args.hasFlag('h')) {
|
||||||
tool.setBrush(new HollowSphereBrush());
|
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
||||||
} else {
|
} else {
|
||||||
tool.setBrush(new SphereBrush());
|
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(String.format("Sphere brush shape equipped (%d).",
|
player.print(String.format("Sphere brush shape equipped (%d).",
|
||||||
@ -121,9 +121,9 @@ public class BrushCommands {
|
|||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
|
|
||||||
if (args.hasFlag('h')) {
|
if (args.hasFlag('h')) {
|
||||||
tool.setBrush(new HollowCylinderBrush(height));
|
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
||||||
} else {
|
} else {
|
||||||
tool.setBrush(new CylinderBrush(height));
|
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(String.format("Cylinder brush shape equipped (%d by %d).",
|
player.print(String.format("Cylinder brush shape equipped (%d by %d).",
|
||||||
@ -163,7 +163,7 @@ public class BrushCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')));
|
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
|
||||||
|
|
||||||
player.print("Clipboard brush shape equipped.");
|
player.print("Clipboard brush shape equipped.");
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ public class BrushCommands {
|
|||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setBrush(new SmoothBrush(iterations));
|
tool.setBrush(new SmoothBrush(iterations), "worldedit.brush.smooth");
|
||||||
|
|
||||||
player.print(String.format("Smooth brush equipped (%d x %dx).",
|
player.print(String.format("Smooth brush equipped (%d x %dx).",
|
||||||
radius, iterations));
|
radius, iterations));
|
||||||
@ -225,7 +225,7 @@ public class BrushCommands {
|
|||||||
tool.setFill(fill);
|
tool.setFill(fill);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setMask(new BlockTypeMask(BlockID.FIRE));
|
tool.setMask(new BlockTypeMask(BlockID.FIRE));
|
||||||
tool.setBrush(new SphereBrush());
|
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
||||||
|
|
||||||
player.print(String.format("Extinguisher equipped (%d).",
|
player.print(String.format("Extinguisher equipped (%d).",
|
||||||
radius));
|
radius));
|
||||||
|
@ -36,6 +36,10 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission("worldedit.superpickaxe.area");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
|
@ -29,6 +29,10 @@ import com.sk89q.worldedit.blocks.BlockID;
|
|||||||
*/
|
*/
|
||||||
public class BlockDataCyler implements DoubleActionBlockTool {
|
public class BlockDataCyler implements DoubleActionBlockTool {
|
||||||
|
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission("worldedit.tool.data-cycler");
|
||||||
|
}
|
||||||
|
|
||||||
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
|
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
|
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
this.targetBlock = targetBlock;
|
this.targetBlock = targetBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission("worldedit.tool.replacer");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
|
|
||||||
|
@ -39,6 +39,27 @@ public class BrushTool implements TraceTool {
|
|||||||
private Brush brush = new SphereBrush();
|
private Brush brush = new SphereBrush();
|
||||||
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||||
private int size = 1;
|
private int size = 1;
|
||||||
|
private String permission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the tool.
|
||||||
|
*
|
||||||
|
* @param permission
|
||||||
|
*/
|
||||||
|
public BrushTool(String permission) {
|
||||||
|
this.permission = permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if the player can still be using this tool (considering
|
||||||
|
* permissions and such).
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission(permission);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filter.
|
* Get the filter.
|
||||||
@ -63,8 +84,9 @@ public class BrushTool implements TraceTool {
|
|||||||
*
|
*
|
||||||
* @param brush
|
* @param brush
|
||||||
*/
|
*/
|
||||||
public void setBrush(Brush brush) {
|
public void setBrush(Brush brush, String perm) {
|
||||||
this.brush = brush;
|
this.brush = brush;
|
||||||
|
this.permission = perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,10 @@ import com.sk89q.worldedit.blocks.*;
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class QueryTool implements BlockTool {
|
public class QueryTool implements BlockTool {
|
||||||
|
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission("worldedit.tool.info");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
|
@ -39,6 +39,10 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission("worldedit.superpickaxe.recursive");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
|
@ -29,6 +29,10 @@ import com.sk89q.worldedit.blocks.BlockID;
|
|||||||
*/
|
*/
|
||||||
public class SinglePickaxe implements BlockTool {
|
public class SinglePickaxe implements BlockTool {
|
||||||
|
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission("worldedit.superpickaxe");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.tools;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a tool. This interface alone defines nothing. A tool also
|
* Represents a tool. This interface alone defines nothing. A tool also
|
||||||
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
||||||
@ -26,4 +28,14 @@ package com.sk89q.worldedit.tools;
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public abstract interface Tool {
|
public abstract interface Tool {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if the player can still be using this tool (considering
|
||||||
|
* permissions and such).
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean canUse(LocalPlayer player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,10 @@ public class TreePlanter implements BlockTool {
|
|||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUse(LocalPlayer player) {
|
||||||
|
return player.hasPermission("worldedit.tool.tree");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user