mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-24 19:46:34 +01:00
Fixes #121
This commit is contained in:
parent
b209c6221a
commit
4ac02d6297
@ -18,7 +18,7 @@ public class BukkitEditSessionWrapper_0 extends EditSessionWrapper {
|
||||
try {
|
||||
// Try to hook into BlocksHub
|
||||
this.hook = new BlocksHubHook();
|
||||
} catch (final Throwable e) {}
|
||||
} catch (final Throwable ignore) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -113,7 +113,7 @@ public class Sniper {
|
||||
if (fp.getMeta("fawe_action") != null) {
|
||||
return false;
|
||||
}
|
||||
RegionWrapper[] mask = WEManager.IMP.getMask(fp).toArray(new RegionWrapper[0]);
|
||||
RegionWrapper[] mask = WEManager.IMP.getMask(fp);
|
||||
queue = FaweAPI.createQueue(fp.getLocation().world, true);
|
||||
this.mask = (MaskedFaweQueue) (queue = new MaskedFaweQueue(queue, mask));
|
||||
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.bukkit.v1_8;
|
||||
|
||||
import com.boydti.fawe.bukkit.ABukkitMain;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitEditSessionWrapper_0;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.object.EditSessionWrapper;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -14,6 +15,6 @@ public class BukkitMain_18 extends ABukkitMain {
|
||||
|
||||
@Override
|
||||
public EditSessionWrapper getEditSessionWrapper(EditSession session) {
|
||||
return new EditSessionWrapper(session);
|
||||
return new BukkitEditSessionWrapper_0(session);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.bukkit.v1_9;
|
||||
|
||||
import com.boydti.fawe.bukkit.ABukkitMain;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitEditSessionWrapper_0;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.object.EditSessionWrapper;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -13,6 +14,6 @@ public class BukkitMain_19 extends ABukkitMain {
|
||||
|
||||
@Override
|
||||
public EditSessionWrapper getEditSessionWrapper(EditSession session) {
|
||||
return new EditSessionWrapper(session);
|
||||
return new BukkitEditSessionWrapper_0(session);
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class FaweAPI {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static Set<RegionWrapper> getRegions(FawePlayer player) {
|
||||
public static RegionWrapper[] getRegions(FawePlayer player) {
|
||||
return WEManager.IMP.getMask(player);
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,7 @@ public enum BBC {
|
||||
WORLDEDIT_CANCEL_REASON_MAX_ENTITIES("Too many entities", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_MAX_ITERATIONS("Max iterations", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_MAX_FAILS("Outside allowed region", "Cancel"),
|
||||
WORLDEDIT_CANCEL_REASON_NO_REGION("No allowed region", "Cancel"),
|
||||
WORLDEDIT_FAILED_LOAD_CHUNK("&cSkipped loading chunk: &7%s0;%s1&c. Try increasing chunk-wait.", "Cancel"),
|
||||
|
||||
LOADING_CLIPBOARD("Loading clipboard from disk, please wait.", "History"),
|
||||
|
@ -281,7 +281,7 @@ public abstract class FawePlayer<T> {
|
||||
* Get the player's current allowed WorldEdit regions
|
||||
* @return
|
||||
*/
|
||||
public HashSet<RegionWrapper> getCurrentRegions() {
|
||||
public RegionWrapper[] getCurrentRegions() {
|
||||
return WEManager.IMP.getMask(this);
|
||||
}
|
||||
|
||||
|
@ -16,16 +16,15 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class ProcessedWEExtent extends FaweRegionExtent {
|
||||
private final FaweLimit limit;
|
||||
private final RegionWrapper[] mask;
|
||||
|
||||
public ProcessedWEExtent(final Extent parent, final HashSet<RegionWrapper> mask, FaweLimit limit) {
|
||||
public ProcessedWEExtent(final Extent parent, final RegionWrapper[] mask, FaweLimit limit) {
|
||||
super(parent);
|
||||
this.mask = mask.toArray(new RegionWrapper[mask.size()]);
|
||||
this.mask = mask;
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.plotsquared.listener.WEManager;
|
||||
@ -21,7 +22,11 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
public FaweMask getMask(FawePlayer fp) {
|
||||
final PlotPlayer pp = PlotPlayer.wrap((Player) fp.parent);
|
||||
final HashSet<RegionWrapper> regions = WEManager.getMask(pp);
|
||||
if (regions.size() == 0 || !PS.get().hasPlotArea(pp.getLocation().getWorld())) {
|
||||
if (regions.size() == 0) {
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (plot.isOwner(pp.getUUID())) {
|
||||
System.out.println("INVALID MASK? " + WEManager.getMask(pp) + " | " + plot + " | " + pp.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final HashSet<com.boydti.fawe.object.RegionWrapper> faweRegions = new HashSet<>();
|
||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweLocation;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
@ -64,47 +63,43 @@ public class WEManager {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public HashSet<RegionWrapper> getMask(final FawePlayer<?> player) {
|
||||
return TaskManager.IMP.sync(new RunnableVal<HashSet<RegionWrapper>>() {
|
||||
public RegionWrapper[] getMask(final FawePlayer<?> player) {
|
||||
HashSet<RegionWrapper> mask = TaskManager.IMP.sync(new RunnableVal<HashSet<RegionWrapper>>() {
|
||||
@Override
|
||||
public void run(HashSet<RegionWrapper> value) {
|
||||
final HashSet<RegionWrapper> regions = new HashSet<>();
|
||||
public void run(HashSet<RegionWrapper> ignore) {
|
||||
this.value = new HashSet<>();
|
||||
String world = player.getLocation().world;
|
||||
if (!world.equals(player.getMeta("lastMaskWorld"))) {
|
||||
player.deleteMeta("lastMaskWorld");
|
||||
player.deleteMeta("lastMask");
|
||||
}
|
||||
player.setMeta("lastMaskWorld", world);
|
||||
if (player.hasPermission("fawe.bypass") || !Settings.REGION_RESTRICTIONS) {
|
||||
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
player.deleteMeta("lastmask");
|
||||
this.value = regions;
|
||||
value.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
return;
|
||||
}
|
||||
for (final FaweMaskManager manager : managers) {
|
||||
if (player.hasPermission("fawe." + manager.getKey())) {
|
||||
final FaweMask mask = manager.getMask(player);
|
||||
if (mask != null) {
|
||||
regions.addAll(mask.getRegions());
|
||||
value.addAll(mask.getRegions());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (regions.size() == 0) {
|
||||
HashSet<RegionWrapper> mask = player.<HashSet<RegionWrapper>>getMeta("lastmask");
|
||||
if (mask != null) {
|
||||
FaweLocation loc = player.getLocation();
|
||||
for (RegionWrapper region : mask) {
|
||||
if (region.isIn(loc.x, loc.z)) {
|
||||
player.deleteMeta("lastmask");
|
||||
this.value = regions;
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.value = mask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.setMeta("lastmask", regions);
|
||||
this.value = regions;
|
||||
return;
|
||||
}
|
||||
}, 1000);
|
||||
if (mask == null || mask.isEmpty()) {
|
||||
mask = player.getMeta("lastMask");
|
||||
if (mask == null) {
|
||||
mask = new HashSet<>();
|
||||
}
|
||||
}
|
||||
player.setMeta("lastmask", mask);
|
||||
return mask.toArray(new RegionWrapper[mask.size()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean intersects(final RegionWrapper region1, final RegionWrapper region2) {
|
||||
return (region1.minX <= region2.maxX) && (region1.maxX >= region2.minX) && (region1.minZ <= region2.maxZ) && (region1.maxZ >= region2.minZ);
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
Extent extent;
|
||||
HashSet<RegionWrapper> mask;
|
||||
RegionWrapper[] mask;
|
||||
final FawePlayer fp = FawePlayer.wrap(actor);
|
||||
final LocalSession session = fp.getSession();
|
||||
this.fastmode = session.hasFastMode();
|
||||
@ -287,9 +287,9 @@ public class EditSession implements Extent {
|
||||
queue.addEditSession(this);
|
||||
this.limit = fp.getLimit();
|
||||
mask = WEManager.IMP.getMask(fp);
|
||||
if (mask.size() == 0) {
|
||||
if (mask.length == 0) {
|
||||
// No allowed area; return null extent
|
||||
extent = this.regionExtent = new NullExtent(world, BBC.WORLDEDIT_CANCEL_REASON_MAX_FAILS);
|
||||
extent = this.regionExtent = new NullExtent(world, BBC.WORLDEDIT_CANCEL_REASON_NO_REGION);
|
||||
this.bypassReorderHistory = extent;
|
||||
this.bypassHistory = extent;
|
||||
this.bypassNone = extent;
|
||||
@ -426,23 +426,14 @@ public class EditSession implements Extent {
|
||||
eventBus.post(event);
|
||||
final Extent toReturn = event.getExtent();
|
||||
if (toReturn != extent) {
|
||||
String className = toReturn.getClass().getSimpleName().toLowerCase();
|
||||
if (className.contains("coreprotect")) {
|
||||
if (Settings.EXTENT_DEBUG) {
|
||||
Fawe.debug("&cUnsafe extent detected: " + toReturn.getClass().getCanonicalName() + " !");
|
||||
Fawe.debug("&8 - &7Use BlocksHub instead");
|
||||
Fawe.debug("&8 - &7Or use FAWE rollback");
|
||||
Fawe.debug("&8 - &7Change `extent.debug: false` to hide this message");
|
||||
}
|
||||
return extent;
|
||||
}
|
||||
String className = toReturn.getClass().getName().toLowerCase();
|
||||
for (String allowed : Settings.ALLOWED_3RDPARTY_EXTENTS) {
|
||||
if (className.contains(allowed.toLowerCase())) {
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
if (Settings.EXTENT_DEBUG) {
|
||||
Fawe.debug("&cPotentially inefficient WorldEdit extent: " + toReturn.getClass().getSimpleName());
|
||||
Fawe.debug("&cPotentially inefficient WorldEdit extent: " + toReturn.getClass().getName());
|
||||
Fawe.debug("&8 - &7For area restrictions, it is recommended to use the FaweAPI");
|
||||
Fawe.debug("&8 - &7To allow this plugin add it to the FAWE `allowed-plugins` list");
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ package com.sk89q.worldedit.command.composition;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.NullChangeSet;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.google.common.base.Joiner;
|
||||
@ -55,7 +55,6 @@ import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
||||
import com.sk89q.worldedit.util.command.composition.CommandExecutor;
|
||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -105,9 +104,9 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
||||
RegionFunction function = ((RegionVisitor) operation).function;
|
||||
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
HashSet<RegionWrapper> mask = WEManager.IMP.getMask(fp);
|
||||
RegionWrapper[] mask = WEManager.IMP.getMask(fp);
|
||||
|
||||
if (function instanceof BlockReplace && mask.size() == 1 && mask.iterator().next().contains(current)) {
|
||||
if (function instanceof BlockReplace && mask.length == 1 && mask[0].equals(current)) {
|
||||
try {
|
||||
BlockReplace replace = ((BlockReplace) function);
|
||||
Field field = replace.getClass().getDeclaredField("pattern");
|
||||
|
Loading…
Reference in New Issue
Block a user