mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-17 14:03:55 +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:
@ -36,6 +36,10 @@ public class AreaPickaxe implements BlockTool {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public boolean canUse(LocalPlayer player) {
|
||||
return player.hasPermission("worldedit.superpickaxe.area");
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
LocalWorld world = clicked.getWorld();
|
||||
|
@ -29,6 +29,10 @@ import com.sk89q.worldedit.blocks.BlockID;
|
||||
*/
|
||||
public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
|
||||
public boolean canUse(LocalPlayer player) {
|
||||
return player.hasPermission("worldedit.tool.data-cycler");
|
||||
}
|
||||
|
||||
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
|
||||
|
||||
|
@ -36,6 +36,10 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
this.targetBlock = targetBlock;
|
||||
}
|
||||
|
||||
public boolean canUse(LocalPlayer player) {
|
||||
return player.hasPermission("worldedit.tool.replacer");
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
||||
|
@ -39,6 +39,27 @@ public class BrushTool implements TraceTool {
|
||||
private Brush brush = new SphereBrush();
|
||||
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||
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.
|
||||
@ -63,8 +84,9 @@ public class BrushTool implements TraceTool {
|
||||
*
|
||||
* @param brush
|
||||
*/
|
||||
public void setBrush(Brush brush) {
|
||||
public void setBrush(Brush brush, String perm) {
|
||||
this.brush = brush;
|
||||
this.permission = perm;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,10 @@ import com.sk89q.worldedit.blocks.*;
|
||||
* @author sk89q
|
||||
*/
|
||||
public class QueryTool implements BlockTool {
|
||||
|
||||
public boolean canUse(LocalPlayer player) {
|
||||
return player.hasPermission("worldedit.tool.info");
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
@ -39,6 +39,10 @@ public class RecursivePickaxe implements BlockTool {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public boolean canUse(LocalPlayer player) {
|
||||
return player.hasPermission("worldedit.superpickaxe.recursive");
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
LocalWorld world = clicked.getWorld();
|
||||
|
@ -29,6 +29,10 @@ import com.sk89q.worldedit.blocks.BlockID;
|
||||
*/
|
||||
public class SinglePickaxe implements BlockTool {
|
||||
|
||||
public boolean canUse(LocalPlayer player) {
|
||||
return player.hasPermission("worldedit.superpickaxe");
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
LocalWorld world = clicked.getWorld();
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
|
||||
/**
|
||||
* Represents a tool. This interface alone defines nothing. A tool also
|
||||
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
||||
@ -26,4 +28,14 @@ package com.sk89q.worldedit.tools;
|
||||
* @author sk89q
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean canUse(LocalPlayer player) {
|
||||
return player.hasPermission("worldedit.tool.tree");
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
||||
|
Reference in New Issue
Block a user