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 double size = 1;
|
||||||
private Set<String> permissions;
|
private Set<String> permissions;
|
||||||
private ScrollAction scrollAction;
|
private ScrollAction scrollAction;
|
||||||
|
private String lastWorld;
|
||||||
|
|
||||||
public BrushSettings() {
|
public BrushSettings() {
|
||||||
this.permissions = new HashSet<>();
|
this.permissions = new HashSet<>();
|
||||||
@ -209,6 +210,20 @@ public class BrushSettings {
|
|||||||
return this;
|
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() {
|
public Brush getBrush() {
|
||||||
return brush;
|
return brush;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import com.boydti.fawe.object.mask.MaskedTargetBlock;
|
|||||||
import com.boydti.fawe.object.pattern.PatternTraverser;
|
import com.boydti.fawe.object.pattern.PatternTraverser;
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
import com.boydti.fawe.util.MaskTraverser;
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@ -441,12 +442,17 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
if (brush == null) return false;
|
if (brush == null) return false;
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
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);
|
Vector target = getPosition(editSession, player);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
editSession.cancel();
|
editSession.cancel();
|
||||||
BBC.NO_BLOCK.send(player);
|
BBC.NO_BLOCK.send(player);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
Request.request().setEditSession(editSession);
|
Request.request().setEditSession(editSession);
|
||||||
|
Loading…
Reference in New Issue
Block a user