mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-24 19:46:34 +01:00
Queue optimizations + WorldGuard global region
This commit is contained in:
parent
9f289f8fac
commit
e5590ed12f
@ -10,7 +10,7 @@ buildscript {
|
||||
}
|
||||
|
||||
group = 'com.boydti.fawe'
|
||||
version = '3.3.17'
|
||||
version = '3.3.18'
|
||||
description = """FastAsyncWorldEdit"""
|
||||
|
||||
subprojects {
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: FastAsyncWorldEdit
|
||||
main: com.boydti.fawe.bukkit.FaweBukkit
|
||||
version: 3.3.17
|
||||
version: 3.3.18
|
||||
description: Fast Async WorldEdit plugin
|
||||
authors: [Empire92]
|
||||
loadbefore: [WorldEdit]
|
||||
|
@ -2,7 +2,7 @@ package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
@ -35,46 +35,40 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
|
||||
}
|
||||
|
||||
public ProtectedRegion isowner(final Player player, final Location location) {
|
||||
public ProtectedRegion getRegion(final Player player, final Location loc) {
|
||||
final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final RegionManager manager = this.worldguard.getRegionManager(player.getWorld());
|
||||
RegionManager manager = this.worldguard.getRegionManager(player.getWorld());
|
||||
final ProtectedRegion global = manager.getRegion("__global__");
|
||||
if (isAllowed(localplayer, global)) {
|
||||
return global;
|
||||
}
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation());
|
||||
for (final ProtectedRegion region : regions) {
|
||||
if (region.isOwner(localplayer)) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().equals(player.getName().toLowerCase())) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().contains(player.getName().toLowerCase() + "//")) {
|
||||
return region;
|
||||
} else if (region.isOwner("*")) {
|
||||
if (isAllowed(localplayer, region)) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ProtectedRegion getregion(final Player player, final BlockVector location) {
|
||||
final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||
final ApplicableRegionSet regions = this.worldguard.getRegionManager(player.getWorld()).getApplicableRegions(location);
|
||||
for (final ProtectedRegion region : regions) {
|
||||
if (region.isOwner(localplayer)) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().equals(player.getName().toLowerCase())) {
|
||||
return region;
|
||||
} else if (region.getId().toLowerCase().contains(player.getName().toLowerCase() + "//")) {
|
||||
return region;
|
||||
} else if (region.isOwner("*")) {
|
||||
return region;
|
||||
}
|
||||
public boolean isAllowed(LocalPlayer localplayer, ProtectedRegion region) {
|
||||
if (region.isOwner(localplayer)) {
|
||||
return true;
|
||||
} else if (region.getId().toLowerCase().equals(localplayer.getName().toLowerCase())) {
|
||||
return true;
|
||||
} else if (region.getId().toLowerCase().contains(localplayer.getName().toLowerCase() + "//")) {
|
||||
return true;
|
||||
} else if (region.isOwner("*")) {
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final ProtectedRegion myregion = this.isowner(player, location);
|
||||
final ProtectedRegion myregion = this.getRegion(player, location);
|
||||
if (myregion != null) {
|
||||
final Location pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
|
||||
final Location pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
|
||||
|
@ -5,7 +5,6 @@ import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.util.FaweQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
@ -78,25 +77,35 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
result.addTask(runnable);
|
||||
}
|
||||
|
||||
private FaweChunk lastChunk;
|
||||
private int lastX = Integer.MIN_VALUE;
|
||||
private int lastZ = Integer.MIN_VALUE;
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, short id, byte data) {
|
||||
if ((y > 255) || (y < 0)) {
|
||||
return false;
|
||||
}
|
||||
long pair = (long) (x >> 4) << 32 | (z >> 4) & 0xFFFFFFFFL;
|
||||
FaweChunk<Chunk> result = this.blocks.get(pair);
|
||||
if (result == null) {
|
||||
result = this.getChunk(x >> 4, z >> 4);
|
||||
result.setBlock(x & 15, y, z & 15, id, data);
|
||||
FaweChunk<Chunk> previous = this.blocks.put(pair, result);
|
||||
if (previous == null) {
|
||||
chunks.add(result);
|
||||
return true;
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
if (cx != lastX || cz != lastZ) {
|
||||
lastX = cx;
|
||||
lastZ = cz;
|
||||
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
||||
lastChunk = this.blocks.get(pair);
|
||||
if (lastChunk == null) {
|
||||
lastChunk = this.getChunk(x >> 4, z >> 4);
|
||||
lastChunk.setBlock(x & 15, y, z & 15, id, data);
|
||||
FaweChunk<Chunk> previous = this.blocks.put(pair, lastChunk);
|
||||
if (previous == null) {
|
||||
chunks.add(lastChunk);
|
||||
return true;
|
||||
}
|
||||
this.blocks.put(pair, previous);
|
||||
lastChunk = previous;
|
||||
}
|
||||
this.blocks.put(pair, previous);
|
||||
result = previous;
|
||||
}
|
||||
result.setBlock(x & 15, y, z & 15, id, data);
|
||||
lastChunk.setBlock(x & 15, y, z & 15, id, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -120,6 +129,8 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
|
||||
@Override
|
||||
public FaweChunk<Chunk> next() {
|
||||
lastX = Integer.MIN_VALUE;
|
||||
lastZ = Integer.MIN_VALUE;
|
||||
try {
|
||||
if (this.blocks.size() == 0) {
|
||||
return null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: FastAsyncWorldEdit
|
||||
main: com.boydti.fawe.bukkit.FaweBukkit
|
||||
version: 3.3.17
|
||||
version: 3.3.18
|
||||
description: Fast Async WorldEdit plugin
|
||||
authors: [Empire92]
|
||||
loadbefore: [WorldEdit]
|
||||
|
@ -49,7 +49,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_FAILED_LOAD_CHUNK("&cFailed to load 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"),
|
||||
|
||||
WORLDEDIT_OOM_ADMIN("&cPossible options:\n&8 - &7//fast\n&8 - &7Do smaller edits\n&8 - &7Allocate more memory\n&8 - &7Disable this safeguard", "Info"),
|
||||
NOT_PLAYER("&cYou must be a player to perform this action!", "Error"),
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -19,17 +20,17 @@ public class NullExtent implements Extent {
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(final Vector2D arg0) {
|
||||
return EditSession.nullBiome;
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_FAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(final Vector arg0) {
|
||||
return EditSession.nullBlock;
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_FAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getLazyBlock(final Vector arg0) {
|
||||
return EditSession.nullBlock;
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_FAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,17 +40,17 @@ public class NullExtent implements Extent {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final Vector2D arg0, final BaseBiome arg1) {
|
||||
return false;
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_FAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(final Vector arg0, final BaseBlock arg1) throws WorldEditException {
|
||||
return false;
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_FAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
||||
return null;
|
||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_FAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,6 +123,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -388,7 +389,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
public void setChangeSet(FaweChangeSet set) {
|
||||
changes = -1;
|
||||
changes++;
|
||||
this.changeSet = set;
|
||||
}
|
||||
|
||||
@ -562,7 +563,7 @@ public class EditSession implements Extent {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final Vector2D position, final BaseBiome biome) {
|
||||
this.changes = -1;
|
||||
this.changes++;
|
||||
return this.bypassNone.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@ -672,7 +673,7 @@ public class EditSession implements Extent {
|
||||
* @throws WorldEditException thrown on a set error
|
||||
*/
|
||||
public boolean setBlock(final Vector position, final BaseBlock block, final Stage stage) throws WorldEditException {
|
||||
this.changes = -1;
|
||||
this.changes++;
|
||||
switch (stage) {
|
||||
case BEFORE_HISTORY:
|
||||
return this.bypassNone.setBlock(position, block);
|
||||
@ -750,11 +751,10 @@ public class EditSession implements Extent {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private int setBlocks(final Set<Vector> vset, final Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
for (final Vector v : vset) {
|
||||
affected += this.setBlock(v, pattern) ? 1 : 0;
|
||||
changes += this.setBlock(v, pattern) ? 1 : 0;
|
||||
}
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -988,7 +988,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1065,7 +1065,19 @@ public class EditSession implements Extent {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int setBlocks(final Region region, final BaseBlock block) throws MaxChangedBlocksException {
|
||||
return this.setBlocks(region, new SingleBlockPattern(block));
|
||||
checkNotNull(region);
|
||||
checkNotNull(block);
|
||||
Iterator<BlockVector> iter = region.iterator();
|
||||
try {
|
||||
while (iter.hasNext()) {
|
||||
this.bypassNone.setBlock(iter.next(), block);
|
||||
}
|
||||
} catch (final MaxChangedBlocksException e) {
|
||||
throw e;
|
||||
} catch (final WorldEditException e) {
|
||||
throw new RuntimeException("Unexpected exception", e);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1088,7 +1100,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1146,7 +1158,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1330,7 +1342,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = ground.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1352,7 +1364,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = naturalizer.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1383,7 +1395,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = copy.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1428,7 +1440,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1476,7 +1488,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1518,7 +1530,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1549,13 +1561,11 @@ public class EditSession implements Extent {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeCylinder(Vector pos, final Pattern block, double radiusX, double radiusZ, int height, final boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
radiusX += 0.5;
|
||||
radiusZ += 0.5;
|
||||
|
||||
if (height == 0) {
|
||||
return this.changes = -1;
|
||||
return this.changes;
|
||||
} else if (height < 0) {
|
||||
height = -height;
|
||||
pos = pos.subtract(0, height, 0);
|
||||
@ -1597,23 +1607,15 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
if (this.setBlock(pos.add(x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(-x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(-x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(pos.add(x, y, z), block);
|
||||
this.setBlock(pos.add(-x, y, z), block);
|
||||
this.setBlock(pos.add(x, y, -z), block);
|
||||
this.setBlock(pos.add(-x, y, -z), block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
return this.changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1643,8 +1645,6 @@ public class EditSession implements Extent {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeSphere(final Vector pos, final Pattern block, double radiusX, double radiusY, double radiusZ, final boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
radiusX += 0.5;
|
||||
radiusY += 0.5;
|
||||
radiusZ += 0.5;
|
||||
@ -1687,35 +1687,19 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.setBlock(pos.add(x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(-x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(x, -y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(-x, -y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(x, -y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(-x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(pos.add(-x, -y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(pos.add(x, y, z), block);
|
||||
this.setBlock(pos.add(-x, y, z), block);
|
||||
this.setBlock(pos.add(x, -y, z), block);
|
||||
this.setBlock(pos.add(x, y, -z), block);
|
||||
this.setBlock(pos.add(-x, -y, z), block);
|
||||
this.setBlock(pos.add(x, -y, -z), block);
|
||||
this.setBlock(pos.add(-x, y, -z), block);
|
||||
this.setBlock(pos.add(-x, -y, -z), block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1729,35 +1713,23 @@ public class EditSession implements Extent {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makePyramid(final Vector position, final Pattern block, int size, final boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
final int height = size;
|
||||
|
||||
for (int y = 0; y <= height; ++y) {
|
||||
size--;
|
||||
for (int x = 0; x <= size; ++x) {
|
||||
for (int z = 0; z <= size; ++z) {
|
||||
|
||||
if ((filled && (z <= size) && (x <= size)) || (z == size) || (x == size)) {
|
||||
|
||||
if (this.setBlock(position.add(x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(position.add(-x, y, z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(position.add(x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
if (this.setBlock(position.add(-x, y, -z), block)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(position.add(x, y, z), block);
|
||||
this.setBlock(position.add(-x, y, z), block);
|
||||
this.setBlock(position.add(x, y, -z), block);
|
||||
this.setBlock(position.add(-x, y, -z), block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1769,7 +1741,6 @@ public class EditSession implements Extent {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int thaw(final Vector position, final double radius) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
final double radiusSq = radius * radius;
|
||||
|
||||
final int ox = position.getBlockX();
|
||||
@ -1792,15 +1763,11 @@ public class EditSession implements Extent {
|
||||
|
||||
switch (id) {
|
||||
case BlockID.ICE:
|
||||
if (this.setBlock(pt, water)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(pt, water);
|
||||
break;
|
||||
|
||||
case BlockID.SNOW:
|
||||
if (this.setBlock(pt, air)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(pt, air);
|
||||
break;
|
||||
|
||||
case BlockID.AIR:
|
||||
@ -1815,7 +1782,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1827,7 +1794,7 @@ public class EditSession implements Extent {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int simulateSnow(final Vector position, final double radius) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
final double radiusSq = radius * radius;
|
||||
|
||||
final int ox = position.getBlockX();
|
||||
@ -1854,9 +1821,7 @@ public class EditSession implements Extent {
|
||||
|
||||
// Ice!
|
||||
if ((id == BlockID.WATER) || (id == BlockID.STATIONARY_WATER)) {
|
||||
if (this.setBlock(pt, ice)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(pt, ice);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1871,15 +1836,13 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
// add snow cover
|
||||
if (this.setBlock(pt.add(0, 1, 0), snow)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(pt.add(0, 1, 0), snow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1906,7 +1869,7 @@ public class EditSession implements Extent {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int green(final Vector position, final double radius, final boolean onlyNormalDirt) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
final double radiusSq = radius * radius;
|
||||
|
||||
final int ox = position.getBlockX();
|
||||
@ -1932,10 +1895,7 @@ public class EditSession implements Extent {
|
||||
if (onlyNormalDirt && (data != 0)) {
|
||||
break loop;
|
||||
}
|
||||
|
||||
if (this.setBlock(pt, grass)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(pt, grass);
|
||||
break loop;
|
||||
|
||||
case BlockID.WATER:
|
||||
@ -1955,7 +1915,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1985,7 +1945,7 @@ public class EditSession implements Extent {
|
||||
EditSession.this.flushQueue();
|
||||
}
|
||||
}, true);
|
||||
return this.changes = -1;
|
||||
return this.changes = ground.getAffected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2040,7 +2000,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
});
|
||||
}
|
||||
return this.changes = -1;
|
||||
return this.changes = trees.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2201,7 +2161,7 @@ public class EditSession implements Extent {
|
||||
final RValue z = expression.getVariable("z", false);
|
||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||
expression.setEnvironment(environment);
|
||||
int affected = 0;
|
||||
|
||||
for (BlockVector position : region) {
|
||||
// offset, scale
|
||||
final Vector scaled = position.subtract(zero).divide(unit);
|
||||
@ -2211,11 +2171,9 @@ public class EditSession implements Extent {
|
||||
// read block from world
|
||||
BaseBlock material = FaweCache.CACHE_BLOCK[this.queue.getCombinedId4DataDebug(sourcePosition.getBlockX(), sourcePosition.getBlockY(), sourcePosition.getBlockZ(), 0, this)];
|
||||
// queue operation
|
||||
if (this.setBlock(position, material)) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(position, material);
|
||||
}
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2229,7 +2187,7 @@ public class EditSession implements Extent {
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int hollowOutRegion(final Region region, final int thickness, final Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
|
||||
final Set<BlockVector> outside = new HashSet<BlockVector>();
|
||||
|
||||
@ -2276,7 +2234,6 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outside.addAll(newOutside);
|
||||
}
|
||||
|
||||
@ -2288,13 +2245,10 @@ public class EditSession implements Extent {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.setBlock(position, pattern.next(position))) {
|
||||
++affected;
|
||||
}
|
||||
this.setBlock(position, pattern.next(position));
|
||||
}
|
||||
|
||||
return affected;
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2354,7 +2308,6 @@ public class EditSession implements Extent {
|
||||
|
||||
vset.add(new Vector(tipx, tipy, tipz));
|
||||
}
|
||||
notdrawn = false;
|
||||
}
|
||||
|
||||
vset = this.getBallooned(vset, radius);
|
||||
|
@ -29,6 +29,8 @@ public final class Operations {
|
||||
|
||||
private Operations() {}
|
||||
|
||||
private static RunContext context = new RunContext();
|
||||
|
||||
/**
|
||||
* Complete a given operation synchronously until it completes.
|
||||
*
|
||||
@ -36,9 +38,11 @@ public final class Operations {
|
||||
* @throws WorldEditException WorldEdit exception
|
||||
*/
|
||||
public static void complete(Operation operation) throws WorldEditException {
|
||||
while (operation != null) {
|
||||
operation = operation.resume(new RunContext());
|
||||
}
|
||||
try {
|
||||
while (true) {
|
||||
operation = operation.resume(context);
|
||||
}
|
||||
} catch (NullPointerException ignore) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,12 +54,12 @@ public final class Operations {
|
||||
*/
|
||||
public static void completeLegacy(Operation operation) throws MaxChangedBlocksException {
|
||||
try {
|
||||
while (operation != null) {
|
||||
operation = operation.resume(new RunContext());
|
||||
while (true) {
|
||||
operation = operation.resume(context);
|
||||
}
|
||||
} catch (final WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (NullPointerException ignore) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,12 +71,12 @@ public final class Operations {
|
||||
*/
|
||||
public static void completeBlindly(Operation operation) {
|
||||
try {
|
||||
while (operation != null) {
|
||||
operation = operation.resume(new RunContext());
|
||||
while (true) {
|
||||
operation = operation.resume(context);
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (NullPointerException ignore) {}
|
||||
}
|
||||
|
||||
public static void completeSmart(final Operation op, final Runnable whenDone, final boolean threadsafe) {
|
||||
|
@ -18,7 +18,7 @@ import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.profile.GameProfileManager;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
@Plugin(id = "com.boydti.fawe", name = "FastAsyncWorldEdit", description = "Lagless WorldEdit, Area restrictions, Memory mangement, Block logging", url = "https://github.com/boy0001/FastAsyncWorldedit", version = "3.3.17")
|
||||
@Plugin(id = "com.boydti.fawe", name = "FastAsyncWorldEdit", description = "Lagless WorldEdit, Area restrictions, Memory mangement, Block logging", url = "https://github.com/boy0001/FastAsyncWorldedit", version = "3.3.18")
|
||||
public class SpongeMain {
|
||||
public PluginContainer plugin;
|
||||
|
||||
|
@ -50,25 +50,35 @@ public abstract class SpongeQueue_0 extends FaweQueue {
|
||||
result.addTask(runnable);
|
||||
}
|
||||
|
||||
private FaweChunk lastChunk;
|
||||
private int lastX = Integer.MIN_VALUE;
|
||||
private int lastZ = Integer.MIN_VALUE;
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, final int y, int z, final short id, final byte data) {
|
||||
if ((y > 255) || (y < 0)) {
|
||||
return false;
|
||||
}
|
||||
long pair = (long) (x >> 4) << 32 | (z >> 4) & 0xFFFFFFFFL;
|
||||
FaweChunk<Chunk> result = this.blocks.get(pair);
|
||||
if (result == null) {
|
||||
result = this.getChunk(x >> 4, z >> 4);
|
||||
result.setBlock(x & 15, y, z & 15, id, data);
|
||||
final FaweChunk<Chunk> previous = this.blocks.put(pair, result);
|
||||
if (previous == null) {
|
||||
chunks.add(result);
|
||||
return true;
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
if (cx != lastX || cz != lastZ) {
|
||||
lastX = cx;
|
||||
lastZ = cz;
|
||||
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
|
||||
lastChunk = this.blocks.get(pair);
|
||||
if (lastChunk == null) {
|
||||
lastChunk = this.getChunk(x >> 4, z >> 4);
|
||||
lastChunk.setBlock(x & 15, y, z & 15, id, data);
|
||||
FaweChunk<Chunk> previous = this.blocks.put(pair, lastChunk);
|
||||
if (previous == null) {
|
||||
chunks.add(lastChunk);
|
||||
return true;
|
||||
}
|
||||
this.blocks.put(pair, previous);
|
||||
lastChunk = previous;
|
||||
}
|
||||
this.blocks.put(pair, previous);
|
||||
result = previous;
|
||||
}
|
||||
result.setBlock(x & 15, y, z & 15, id, data);
|
||||
lastChunk.setBlock(x & 15, y, z & 15, id, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -90,6 +100,8 @@ public abstract class SpongeQueue_0 extends FaweQueue {
|
||||
|
||||
@Override
|
||||
public FaweChunk<Chunk> next() {
|
||||
lastX = Integer.MIN_VALUE;
|
||||
lastZ = Integer.MIN_VALUE;
|
||||
try {
|
||||
if (this.blocks.size() == 0) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user