mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fix masking extent + process non plot worlds
This commit is contained in:
parent
5b44e39bec
commit
56d50bd9e1
@ -35,7 +35,7 @@ public class SetBlockQueue {
|
||||
|
||||
public synchronized static boolean addNotify(Runnable whenDone) {
|
||||
if (runnables == null) {
|
||||
if (blocks == null) {
|
||||
if (blocks == null || blocks.size() == 0) {
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
@ -46,8 +46,23 @@ public class SetBlockQueue {
|
||||
runnables = new ArrayDeque<>();
|
||||
}
|
||||
if (whenDone != null) {
|
||||
init();
|
||||
runnables.add(whenDone);
|
||||
}
|
||||
if (blocks == null || blocks.size() == 0) {
|
||||
ArrayDeque<Runnable> tasks = runnables;
|
||||
lastInt = -1;
|
||||
lastBlock = null;
|
||||
runnables = null;
|
||||
running = false;
|
||||
blocks = null;
|
||||
slow = false;
|
||||
if (tasks != null) {
|
||||
for (Runnable runnable : tasks) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,6 +81,7 @@ public class SetBlockQueue {
|
||||
@Override
|
||||
public void run() {
|
||||
if (locked) {
|
||||
System.out.print("LOCKED!");
|
||||
return;
|
||||
}
|
||||
if (blocks == null || blocks.size() == 0) {
|
||||
@ -74,8 +90,8 @@ public class SetBlockQueue {
|
||||
lastInt = -1;
|
||||
lastBlock = null;
|
||||
runnables = null;
|
||||
blocks = null;
|
||||
running = false;
|
||||
blocks = null;
|
||||
slow = false;
|
||||
if (tasks != null) {
|
||||
for (Runnable runnable : tasks) {
|
||||
@ -92,6 +108,19 @@ public class SetBlockQueue {
|
||||
}
|
||||
Iterator<Entry<ChunkWrapper, PlotBlock[][]>> iter = blocks.entrySet().iterator();
|
||||
if (!iter.hasNext()) {
|
||||
PS.get().TASK.cancelTask(TaskManager.tasks.get(current));
|
||||
ArrayDeque<Runnable> tasks = runnables;
|
||||
lastInt = -1;
|
||||
lastBlock = null;
|
||||
runnables = null;
|
||||
running = false;
|
||||
blocks = null;
|
||||
slow = false;
|
||||
if (tasks != null) {
|
||||
for (Runnable runnable : tasks) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
Entry<ChunkWrapper, PlotBlock[][]> n = iter.next();
|
||||
@ -196,7 +225,10 @@ public class SetBlockQueue {
|
||||
ChunkWrapper wrap = new ChunkWrapper(world, X, Z);
|
||||
PlotBlock[][] result;
|
||||
result = blocks.get(wrap);
|
||||
if (!blocks.containsKey(wrap)) {
|
||||
if (result == null) {
|
||||
if (blocks == null) {
|
||||
init();
|
||||
}
|
||||
result = new PlotBlock[16][];
|
||||
blocks.put(wrap, result);
|
||||
}
|
||||
@ -219,7 +251,10 @@ public class SetBlockQueue {
|
||||
ChunkWrapper wrap = new ChunkWrapper(world, X, Z);
|
||||
PlotBlock[][] result;
|
||||
result = blocks.get(wrap);
|
||||
if (!blocks.containsKey(wrap)) {
|
||||
if (result == null) {
|
||||
if (blocks == null) {
|
||||
init();
|
||||
}
|
||||
result = new PlotBlock[16][];
|
||||
blocks.put(wrap, result);
|
||||
}
|
||||
|
@ -27,6 +27,12 @@ public class WEManager {
|
||||
public static HashSet<RegionWrapper> getMask(PlotPlayer player) {
|
||||
HashSet<RegionWrapper> regions = new HashSet<>();
|
||||
UUID uuid = player.getUUID();
|
||||
Location location = player.getLocation();
|
||||
String world = location.getWorld();
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
return regions;
|
||||
}
|
||||
for (Plot plot : PS.get().getPlotsInWorld(player.getLocation().getWorld())) {
|
||||
if (!plot.isBasePlot() || (Settings.DONE_RESTRICTS_BUILDING && FlagManager.getPlotFlag(plot, "done") != null)) {
|
||||
continue;
|
||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.MaskingExtent;
|
||||
import com.sk89q.worldedit.extent.cache.LastAccessExtentCache;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
|
||||
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
|
||||
@ -31,6 +32,7 @@ import com.sk89q.worldedit.extent.world.BlockQuirkExtent;
|
||||
import com.sk89q.worldedit.extent.world.ChunkLoadingExtent;
|
||||
import com.sk89q.worldedit.extent.world.FastModeExtent;
|
||||
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -41,9 +43,6 @@ public class WESubscriber {
|
||||
public void onEditSession(EditSessionEvent event) {
|
||||
World worldObj = event.getWorld();
|
||||
String world = worldObj.getName();
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
Actor actor = event.getActor();
|
||||
if (actor != null && actor.isPlayer()) {
|
||||
String name = actor.getName();
|
||||
@ -58,16 +57,21 @@ public class WESubscriber {
|
||||
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_BYPASS);
|
||||
}
|
||||
if (PS.get().isPlotWorld(world)) {
|
||||
event.setExtent(new NullExtent());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Settings.CHUNK_PROCESSOR) {
|
||||
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||
try {
|
||||
LocalSession session = ((BukkitMain) PS.get().IMP).worldEdit.getWorldEdit().getSession(name);
|
||||
boolean hasMask = session.getMask() != null;
|
||||
AbstractDelegateExtent extent = (AbstractDelegateExtent) event.getExtent();
|
||||
ChangeSetExtent history = null;
|
||||
MultiStageReorder reorder = null;
|
||||
boolean fast = ((BukkitMain) PS.get().IMP).worldEdit.getWorldEdit().getSession(name).hasFastMode();
|
||||
MaskingExtent maskextent = null;
|
||||
boolean fast = session.hasFastMode();
|
||||
while (extent.getExtent() != null && extent.getExtent() instanceof AbstractDelegateExtent) {
|
||||
AbstractDelegateExtent tmp = (AbstractDelegateExtent) extent.getExtent();
|
||||
if (tmp.getExtent() != null && tmp.getExtent() instanceof AbstractDelegateExtent) {
|
||||
@ -77,6 +81,9 @@ public class WESubscriber {
|
||||
if (tmp instanceof MultiStageReorder) {
|
||||
reorder = (MultiStageReorder) tmp;
|
||||
}
|
||||
if (hasMask && tmp instanceof MaskingExtent) {
|
||||
maskextent = tmp;
|
||||
}
|
||||
extent = tmp;
|
||||
}
|
||||
else {
|
||||
@ -95,9 +102,16 @@ public class WESubscriber {
|
||||
if (fast) {
|
||||
event.setExtent(new ExtentWrapper(extent));
|
||||
}
|
||||
else {
|
||||
if (maskextent != null) {
|
||||
ExtentWrapper wrapper = new ExtentWrapper(maskextent);
|
||||
field.set(maskextent, history);
|
||||
event.setExtent(wrapper);
|
||||
}
|
||||
else {
|
||||
ExtentWrapper wrapper = new ExtentWrapper(history);
|
||||
event.setExtent(wrapper);
|
||||
}
|
||||
field.set(history, reorder);
|
||||
field.set(reorder, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
||||
}
|
||||
@ -108,9 +122,11 @@ public class WESubscriber {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (PS.get().isPlotWorld(world)) {
|
||||
event.setExtent(new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(), event.getExtent()));
|
||||
}
|
||||
else {
|
||||
}
|
||||
else if (PS.get().isPlotWorld(world)) {
|
||||
event.setExtent(new WEExtent(mask, event.getExtent()));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user