Check permission when using BrushTool
This commit is contained in:
parent
9a8ec501b7
commit
7cbb117215
@ -48,6 +48,7 @@ public class BrushSettings {
|
||||
private double size = 1;
|
||||
private Set<String> permissions;
|
||||
private ScrollAction scrollAction;
|
||||
private String lastWorld;
|
||||
|
||||
public BrushSettings() {
|
||||
this.permissions = new HashSet<>();
|
||||
@ -209,6 +210,20 @@ public class BrushSettings {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the world the brush is being used in
|
||||
* @param world
|
||||
* @return true if the world differs from the last used world
|
||||
*/
|
||||
public boolean setWorld(String world) {
|
||||
boolean result = false;
|
||||
if (this.lastWorld != null && !this.lastWorld.equalsIgnoreCase(world)) {
|
||||
result = true;
|
||||
}
|
||||
this.lastWorld = world;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Brush getBrush() {
|
||||
return brush;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import com.boydti.fawe.object.mask.MaskedTargetBlock;
|
||||
import com.boydti.fawe.object.pattern.PatternTraverser;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -441,12 +442,17 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
if (brush == null) return false;
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
if (current.setWorld(editSession.getWorld().getName()) && !current.canUse(player)) {
|
||||
BBC.NO_PERM.send(player, StringMan.join(current.getPermissions(), ","));
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector target = getPosition(editSession, player);
|
||||
|
||||
if (target == null) {
|
||||
editSession.cancel();
|
||||
BBC.NO_BLOCK.send(player);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
BlockBag bag = session.getBlockBag(player);
|
||||
Request.request().setEditSession(editSession);
|
||||
|
Loading…
Reference in New Issue
Block a user