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 {
|
||||||
// Try to hook into BlocksHub
|
// Try to hook into BlocksHub
|
||||||
this.hook = new BlocksHubHook();
|
this.hook = new BlocksHubHook();
|
||||||
} catch (final Throwable e) {}
|
} catch (final Throwable ignore) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,7 +113,7 @@ public class Sniper {
|
|||||||
if (fp.getMeta("fawe_action") != null) {
|
if (fp.getMeta("fawe_action") != null) {
|
||||||
return false;
|
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);
|
queue = FaweAPI.createQueue(fp.getLocation().world, true);
|
||||||
this.mask = (MaskedFaweQueue) (queue = new MaskedFaweQueue(queue, mask));
|
this.mask = (MaskedFaweQueue) (queue = new MaskedFaweQueue(queue, mask));
|
||||||
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.bukkit.v1_8;
|
package com.boydti.fawe.bukkit.v1_8;
|
||||||
|
|
||||||
import com.boydti.fawe.bukkit.ABukkitMain;
|
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.bukkit.v0.BukkitQueue_0;
|
||||||
import com.boydti.fawe.object.EditSessionWrapper;
|
import com.boydti.fawe.object.EditSessionWrapper;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -14,6 +15,6 @@ public class BukkitMain_18 extends ABukkitMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSessionWrapper getEditSessionWrapper(EditSession session) {
|
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;
|
package com.boydti.fawe.bukkit.v1_9;
|
||||||
|
|
||||||
import com.boydti.fawe.bukkit.ABukkitMain;
|
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.bukkit.v0.BukkitQueue_0;
|
||||||
import com.boydti.fawe.object.EditSessionWrapper;
|
import com.boydti.fawe.object.EditSessionWrapper;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -13,6 +14,6 @@ public class BukkitMain_19 extends ABukkitMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSessionWrapper getEditSessionWrapper(EditSession session) {
|
public EditSessionWrapper getEditSessionWrapper(EditSession session) {
|
||||||
return new EditSessionWrapper(session);
|
return new BukkitEditSessionWrapper_0(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ public class FaweAPI {
|
|||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<RegionWrapper> getRegions(FawePlayer player) {
|
public static RegionWrapper[] getRegions(FawePlayer player) {
|
||||||
return WEManager.IMP.getMask(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_ENTITIES("Too many entities", "Cancel"),
|
||||||
WORLDEDIT_CANCEL_REASON_MAX_ITERATIONS("Max iterations", "Cancel"),
|
WORLDEDIT_CANCEL_REASON_MAX_ITERATIONS("Max iterations", "Cancel"),
|
||||||
WORLDEDIT_CANCEL_REASON_MAX_FAILS("Outside allowed region", "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"),
|
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"),
|
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
|
* Get the player's current allowed WorldEdit regions
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public HashSet<RegionWrapper> getCurrentRegions() {
|
public RegionWrapper[] getCurrentRegions() {
|
||||||
return WEManager.IMP.getMask(this);
|
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.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ProcessedWEExtent extends FaweRegionExtent {
|
public class ProcessedWEExtent extends FaweRegionExtent {
|
||||||
private final FaweLimit limit;
|
private final FaweLimit limit;
|
||||||
private final RegionWrapper[] mask;
|
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);
|
super(parent);
|
||||||
this.mask = mask.toArray(new RegionWrapper[mask.size()]);
|
this.mask = mask;
|
||||||
this.limit = limit;
|
this.limit = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
import com.boydti.fawe.regions.FaweMask;
|
import com.boydti.fawe.regions.FaweMask;
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.plotsquared.listener.WEManager;
|
import com.plotsquared.listener.WEManager;
|
||||||
@ -21,7 +22,11 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
public FaweMask getMask(FawePlayer fp) {
|
public FaweMask getMask(FawePlayer fp) {
|
||||||
final PlotPlayer pp = PlotPlayer.wrap((Player) fp.parent);
|
final PlotPlayer pp = PlotPlayer.wrap((Player) fp.parent);
|
||||||
final HashSet<RegionWrapper> regions = WEManager.getMask(pp);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
final HashSet<com.boydti.fawe.object.RegionWrapper> faweRegions = new HashSet<>();
|
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.BBC;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FaweLocation;
|
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
@ -64,46 +63,42 @@ public class WEManager {
|
|||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public HashSet<RegionWrapper> getMask(final FawePlayer<?> player) {
|
public RegionWrapper[] getMask(final FawePlayer<?> player) {
|
||||||
return TaskManager.IMP.sync(new RunnableVal<HashSet<RegionWrapper>>() {
|
HashSet<RegionWrapper> mask = TaskManager.IMP.sync(new RunnableVal<HashSet<RegionWrapper>>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(HashSet<RegionWrapper> value) {
|
public void run(HashSet<RegionWrapper> ignore) {
|
||||||
final HashSet<RegionWrapper> regions = new HashSet<>();
|
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) {
|
if (player.hasPermission("fawe.bypass") || !Settings.REGION_RESTRICTIONS) {
|
||||||
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
value.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||||
player.deleteMeta("lastmask");
|
|
||||||
this.value = regions;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (final FaweMaskManager manager : managers) {
|
for (final FaweMaskManager manager : managers) {
|
||||||
if (player.hasPermission("fawe." + manager.getKey())) {
|
if (player.hasPermission("fawe." + manager.getKey())) {
|
||||||
final FaweMask mask = manager.getMask(player);
|
final FaweMask mask = manager.getMask(player);
|
||||||
if (mask != null) {
|
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);
|
}, 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) {
|
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);
|
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;
|
Extent extent;
|
||||||
HashSet<RegionWrapper> mask;
|
RegionWrapper[] mask;
|
||||||
final FawePlayer fp = FawePlayer.wrap(actor);
|
final FawePlayer fp = FawePlayer.wrap(actor);
|
||||||
final LocalSession session = fp.getSession();
|
final LocalSession session = fp.getSession();
|
||||||
this.fastmode = session.hasFastMode();
|
this.fastmode = session.hasFastMode();
|
||||||
@ -287,9 +287,9 @@ public class EditSession implements Extent {
|
|||||||
queue.addEditSession(this);
|
queue.addEditSession(this);
|
||||||
this.limit = fp.getLimit();
|
this.limit = fp.getLimit();
|
||||||
mask = WEManager.IMP.getMask(fp);
|
mask = WEManager.IMP.getMask(fp);
|
||||||
if (mask.size() == 0) {
|
if (mask.length == 0) {
|
||||||
// No allowed area; return null extent
|
// 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.bypassReorderHistory = extent;
|
||||||
this.bypassHistory = extent;
|
this.bypassHistory = extent;
|
||||||
this.bypassNone = extent;
|
this.bypassNone = extent;
|
||||||
@ -426,23 +426,14 @@ public class EditSession implements Extent {
|
|||||||
eventBus.post(event);
|
eventBus.post(event);
|
||||||
final Extent toReturn = event.getExtent();
|
final Extent toReturn = event.getExtent();
|
||||||
if (toReturn != extent) {
|
if (toReturn != extent) {
|
||||||
String className = toReturn.getClass().getSimpleName().toLowerCase();
|
String className = toReturn.getClass().getName().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;
|
|
||||||
}
|
|
||||||
for (String allowed : Settings.ALLOWED_3RDPARTY_EXTENTS) {
|
for (String allowed : Settings.ALLOWED_3RDPARTY_EXTENTS) {
|
||||||
if (className.contains(allowed.toLowerCase())) {
|
if (className.contains(allowed.toLowerCase())) {
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.EXTENT_DEBUG) {
|
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 - &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");
|
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.config.BBC;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.NullChangeSet;
|
import com.boydti.fawe.object.NullChangeSet;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.google.common.base.Joiner;
|
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.CommandExecutor;
|
||||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@ -105,9 +104,9 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
|||||||
RegionFunction function = ((RegionVisitor) operation).function;
|
RegionFunction function = ((RegionVisitor) operation).function;
|
||||||
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
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 {
|
try {
|
||||||
BlockReplace replace = ((BlockReplace) function);
|
BlockReplace replace = ((BlockReplace) function);
|
||||||
Field field = replace.getClass().getDeclaredField("pattern");
|
Field field = replace.getClass().getDeclaredField("pattern");
|
||||||
|
Loading…
Reference in New Issue
Block a user