mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Introduce Resettable interface
This commit is contained in:
parent
efbe1a737d
commit
048974dca5
@ -0,0 +1,6 @@
|
|||||||
|
package com.boydti.fawe;
|
||||||
|
|
||||||
|
public interface Resettable {
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
}
|
@ -3,7 +3,7 @@ package com.boydti.fawe.beta;
|
|||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
|
|
||||||
public interface IQueueWrapper {
|
public interface IQueueWrapper {
|
||||||
default IQueueExtent wrapQueue(IQueueExtent queue) {
|
default IQueueExtent<IQueueChunk> wrapQueue(IQueueExtent<IQueueChunk> queue) {
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.beta.implementation.queue;
|
package com.boydti.fawe.beta.implementation.queue;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.beta.IQueueChunk;
|
||||||
import com.boydti.fawe.beta.IQueueWrapper;
|
import com.boydti.fawe.beta.IQueueWrapper;
|
||||||
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
|
||||||
import com.boydti.fawe.beta.Filter;
|
import com.boydti.fawe.beta.Filter;
|
||||||
@ -64,12 +65,12 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IQueueExtent getNewQueue() {
|
private IQueueExtent<IQueueChunk> getNewQueue() {
|
||||||
return wrapQueue(handler.getQueue(this.world, this.processor));
|
return wrapQueue(handler.getQueue(this.world, this.processor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQueueExtent wrapQueue(IQueueExtent queue) {
|
public IQueueExtent<IQueueChunk> wrapQueue(IQueueExtent<IQueueChunk> queue) {
|
||||||
// TODO wrap
|
// TODO wrap
|
||||||
queue.setProcessor(this.processor);
|
queue.setProcessor(this.processor);
|
||||||
return queue;
|
return queue;
|
||||||
@ -91,22 +92,22 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
|
|||||||
try {
|
try {
|
||||||
final Filter newFilter = filter.fork();
|
final Filter newFilter = filter.fork();
|
||||||
// Create a chunk that we will reuse/reset for each operation
|
// Create a chunk that we will reuse/reset for each operation
|
||||||
final IQueueExtent queue = getNewQueue();
|
final IQueueExtent<IQueueChunk> queue = getNewQueue();
|
||||||
synchronized (queue) {
|
synchronized (queue) {
|
||||||
ChunkFilterBlock block = null;
|
ChunkFilterBlock block = null;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Get the next chunk posWeakChunk
|
// Get the next chunk posWeakChunk
|
||||||
final int X, Z;
|
final int chunkX, chunkZ;
|
||||||
synchronized (chunksIter) {
|
synchronized (chunksIter) {
|
||||||
if (!chunksIter.hasNext()) {
|
if (!chunksIter.hasNext()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final BlockVector2 pos = chunksIter.next();
|
final BlockVector2 pos = chunksIter.next();
|
||||||
X = pos.getX();
|
chunkX = pos.getX();
|
||||||
Z = pos.getZ();
|
chunkZ = pos.getZ();
|
||||||
}
|
}
|
||||||
block = queue.apply(block, newFilter, region, X, Z, full);
|
block = queue.apply(block, newFilter, region, chunkX, chunkZ, full);
|
||||||
}
|
}
|
||||||
queue.flush();
|
queue.flush();
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,6 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
this.set = set;
|
this.set = set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SparseBitSet getBitSet() {
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return set.cardinality();
|
return set.cardinality();
|
||||||
@ -69,10 +65,10 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
if (size() < length * length * length) {
|
if (size() < length * length * length) {
|
||||||
int index = -1;
|
int index = -1;
|
||||||
while ((index = set.nextSetBit(index + 1)) != -1) {
|
while ((index = set.nextSetBit(index + 1)) != -1) {
|
||||||
int b1 = (index & 0xFF);
|
int b1 = (byte) (index >> 0) & 0xFF;
|
||||||
int b2 = ((byte) (index >> 8)) & 0x7F;
|
int b2 = (byte) (index >> 8) & 0x7F;
|
||||||
int b3 = ((byte) (index >> 15)) & 0xFF;
|
int b3 = (byte) (index >> 15) & 0xFF;
|
||||||
int b4 = ((byte) (index >> 23)) & 0xFF;
|
int b4 = (byte) (index >> 23) & 0xFF;
|
||||||
if (Math.abs((offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21)) - x) <= radius && Math.abs((offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)) - z) <= radius && Math.abs((b1) - y) <= radius) {
|
if (Math.abs((offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21)) - x) <= radius && Math.abs((offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)) - z) <= radius && Math.abs((b1) - y) <= radius) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -111,12 +107,12 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
index = set.nextSetBit(index + 1);
|
index = set.nextSetBit(index + 1);
|
||||||
}
|
}
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
int b1 = (index & 0xFF);
|
int b1 = (byte) (index >> 0) & 0xFF;
|
||||||
int b2 = ((byte) (index >> 8)) & 0x7F;
|
int b2 = (byte) (index >> 8) & 0x7F;
|
||||||
int b3 = ((byte) (index >> 15)) & 0xFF;
|
int b3 = (byte) (index >> 15) & 0xFF;
|
||||||
int b4 = ((byte) (index >> 23)) & 0xFF;
|
int b4 = (byte) (index >> 23) & 0xFF;
|
||||||
int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21);
|
int x = offsetX + (((b3 + (MathMan.unpair8x(b2) << 8)) << 21) >> 21);
|
||||||
int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21);
|
int z = offsetZ + (((b4 + (MathMan.unpair8y(b2) << 8)) << 21) >> 21);
|
||||||
return MutableBlockVector3.get(x, b1, z);
|
return MutableBlockVector3.get(x, b1, z);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -146,9 +142,9 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
int b2 = ((byte) (index >> 8)) & 0x7F;
|
int b2 = ((byte) (index >> 8)) & 0x7F;
|
||||||
int b3 = ((byte) (index >> 15)) & 0xFF;
|
int b3 = ((byte) (index >> 15)) & 0xFF;
|
||||||
int b4 = ((byte) (index >> 23)) & 0xFF;
|
int b4 = ((byte) (index >> 23)) & 0xFF;
|
||||||
mutable.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21));
|
mutable.mutX(offsetX + (((b3 + (MathMan.unpair8x(b2) << 8)) << 21) >> 21));
|
||||||
mutable.mutY(b1);
|
mutable.mutY(b1);
|
||||||
mutable.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21));
|
mutable.mutZ(offsetZ + (((b4 + (MathMan.unpair8y(b2) << 8)) << 21) >> 21));
|
||||||
previous = index;
|
previous = index;
|
||||||
index = set.nextSetBit(index + 1);
|
index = set.nextSetBit(index + 1);
|
||||||
return mutable;
|
return mutable;
|
||||||
@ -193,10 +189,7 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
if (relX > 1023 || relX < -1024 || relZ > 1023 || relZ < -1024) {
|
if (relX > 1023 || relX < -1024 || relZ > 1023 || relZ < -1024) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (y < 0 || y > 256) {
|
return y >= 0 && y <= 256;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean add(int x, int y, int z) {
|
public boolean add(int x, int y, int z) {
|
||||||
|
@ -21,7 +21,8 @@ public class MemoryCheckingExtent extends PassthroughExtent {
|
|||||||
public Extent getExtent() {
|
public Extent getExtent() {
|
||||||
if (MemUtil.isMemoryLimited()) {
|
if (MemUtil.isMemoryLimited()) {
|
||||||
if (this.player != null) {
|
if (this.player != null) {
|
||||||
player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", (TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory"))));
|
player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason",
|
||||||
|
TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory")));
|
||||||
if (Permission.hasPermission(this.player, "worldedit.fast")) {
|
if (Permission.hasPermission(this.player, "worldedit.fast")) {
|
||||||
this.player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
|
this.player.print(TranslatableComponent.of("fawe.info.worldedit.oom.admin"));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
public interface ResettableMask {
|
import com.boydti.fawe.Resettable;
|
||||||
|
|
||||||
|
public interface ResettableMask extends Resettable {
|
||||||
|
|
||||||
|
@Override
|
||||||
void reset();
|
void reset();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.Resettable;
|
||||||
import com.boydti.fawe.object.mask.ResettableMask;
|
import com.boydti.fawe.object.mask.ResettableMask;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -21,11 +22,8 @@ public class PatternTraverser {
|
|||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pattern instanceof ResettablePattern) {
|
if (pattern instanceof Resettable) {
|
||||||
((ResettablePattern) pattern).reset();
|
((Resettable) pattern).reset();
|
||||||
}
|
|
||||||
if (pattern instanceof ResettableMask) {
|
|
||||||
((ResettableMask) pattern).reset();
|
|
||||||
}
|
}
|
||||||
Class<?> current = pattern.getClass();
|
Class<?> current = pattern.getClass();
|
||||||
while (current.getSuperclass() != null) {
|
while (current.getSuperclass() != null) {
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
public interface ResettablePattern {
|
import com.boydti.fawe.Resettable;
|
||||||
|
|
||||||
|
public interface ResettablePattern extends Resettable {
|
||||||
|
|
||||||
|
@Override
|
||||||
void reset();
|
void reset();
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,6 @@ public class EditSessionBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AbstractChangeSet changeTask;
|
private AbstractChangeSet changeTask;
|
||||||
private int maxY;
|
|
||||||
private Extent bypassHistory;
|
private Extent bypassHistory;
|
||||||
private Extent bypassAll;
|
private Extent bypassAll;
|
||||||
private Extent extent;
|
private Extent extent;
|
||||||
@ -409,7 +408,6 @@ public class EditSessionBuilder {
|
|||||||
allowedRegions = player.getCurrentRegions();
|
allowedRegions = player.getCurrentRegions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.maxY = world == null ? 255 : world.getMaxY();
|
|
||||||
FaweRegionExtent regionExtent = null;
|
FaweRegionExtent regionExtent = null;
|
||||||
if (allowedRegions != null) {
|
if (allowedRegions != null) {
|
||||||
if (allowedRegions.length == 0) {
|
if (allowedRegions.length == 0) {
|
||||||
@ -423,7 +421,7 @@ public class EditSessionBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this.extent = new HeightBoundExtent(this.extent, this.limit, 0, maxY);
|
// this.extent = new HeightBoundExtent(this.extent, this.limit, 0, world.getMaxY());
|
||||||
}
|
}
|
||||||
IBatchProcessor limitProcessor = regionExtent;
|
IBatchProcessor limitProcessor = regionExtent;
|
||||||
if (limit != null && !limit.isUnlimited()) {
|
if (limit != null && !limit.isUnlimited()) {
|
||||||
@ -495,7 +493,4 @@ public class EditSessionBuilder {
|
|||||||
return blockBag;
|
return blockBag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxY() {
|
|
||||||
return maxY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,17 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
|||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ExtentTraverser<T extends Extent> {
|
public class ExtentTraverser<T extends Extent> {
|
||||||
private T root;
|
private final T root;
|
||||||
private ExtentTraverser<T> parent;
|
private final ExtentTraverser<T> parent;
|
||||||
|
|
||||||
public ExtentTraverser(T root) {
|
public ExtentTraverser(@NotNull T root) {
|
||||||
this(root, null);
|
this(root, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExtentTraverser(T root, ExtentTraverser<T> parent) {
|
public ExtentTraverser(@NotNull T root, ExtentTraverser<T> parent) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
@ -61,7 +62,7 @@ public class ExtentTraverser<T extends Extent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <U> U findAndGet(Class<U> clazz) {
|
public <U> U findAndGet(Class<U> clazz) {
|
||||||
ExtentTraverser<Extent> traverser = find((Class) clazz);
|
ExtentTraverser<Extent> traverser = find( clazz);
|
||||||
return (traverser != null) ? (U) traverser.get() : null;
|
return (traverser != null) ? (U) traverser.get() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,9 +105,8 @@ public class ExtentTraverser<T extends Extent> {
|
|||||||
public ExtentTraverser<T> next() {
|
public ExtentTraverser<T> next() {
|
||||||
try {
|
try {
|
||||||
if (root instanceof AbstractDelegateExtent) {
|
if (root instanceof AbstractDelegateExtent) {
|
||||||
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
AbstractDelegateExtent root = (AbstractDelegateExtent) this.root;
|
||||||
field.setAccessible(true);
|
T value = (T) root.getExtent();
|
||||||
T value = (T) field.get(root);
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@ import java.util.Arrays;
|
|||||||
public class FaweTimer implements Runnable {
|
public class FaweTimer implements Runnable {
|
||||||
|
|
||||||
private final double[] history = new double[]{20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d};
|
private final double[] history = new double[]{20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d, 20d};
|
||||||
private int historyIndex = 0;
|
private int historyIndex;
|
||||||
private long lastPoll = System.currentTimeMillis();
|
private long lastPoll = System.currentTimeMillis();
|
||||||
private long tickStart = System.currentTimeMillis();
|
private long tickStart = System.currentTimeMillis();
|
||||||
private final long tickInterval = 5;
|
private final long tickInterval = 5;
|
||||||
private long tick = 0;
|
private long tick;
|
||||||
private long tickMod = 0;
|
private long tickMod;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -21,7 +21,7 @@ public class FaweTimer implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long timeSpent = (tickStart - lastPoll);
|
long timeSpent = tickStart - lastPoll;
|
||||||
if (timeSpent == 0) {
|
if (timeSpent == 0) {
|
||||||
timeSpent = 1;
|
timeSpent = 1;
|
||||||
}
|
}
|
||||||
@ -34,15 +34,14 @@ public class FaweTimer implements Runnable {
|
|||||||
lastPoll = tickStart;
|
lastPoll = tickStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long lastGetTPSTick = 0;
|
private long lastGetTPSTick;
|
||||||
private double lastGetTPSValue = 20d;
|
private double lastGetTPSValue = 20d;
|
||||||
|
|
||||||
public double getTPS() {
|
public double getTPS() {
|
||||||
if (tick < lastGetTPSTick + tickInterval) {
|
if (tick < lastGetTPSTick + tickInterval) {
|
||||||
return lastGetTPSValue;
|
return lastGetTPSValue;
|
||||||
}
|
}
|
||||||
double total = 0;
|
double total = Arrays.stream(history).sum();
|
||||||
for (double v : history) total += v;
|
|
||||||
lastGetTPSValue = total / history.length;
|
lastGetTPSValue = total / history.length;
|
||||||
lastGetTPSTick = tick;
|
lastGetTPSTick = tick;
|
||||||
return lastGetTPSValue;
|
return lastGetTPSValue;
|
||||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.util.image.ImageUtil;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
@ -255,7 +255,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
this.limit = builder.getLimit().copy();
|
this.limit = builder.getLimit().copy();
|
||||||
this.player = builder.getPlayer();
|
this.player = builder.getPlayer();
|
||||||
this.changeSet = builder.getChangeTask();
|
this.changeSet = builder.getChangeTask();
|
||||||
this.maxY = builder.getMaxY();
|
this.maxY = world.getMaxY();
|
||||||
this.blockBag = builder.getBlockBag();
|
this.blockBag = builder.getBlockBag();
|
||||||
this.history = changeSet != null;
|
this.history = changeSet != null;
|
||||||
}
|
}
|
||||||
|
@ -97,9 +97,8 @@ public class RegionCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/set",
|
name = "/set",
|
||||||
aliases = {"/"},
|
desc = "Sets all the blocks in the region"
|
||||||
desc = "Sets all the blocks in the region"
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.set")
|
@CommandPermissions("worldedit.region.set")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.beta.implementation.IChunkExtent;
|
import com.boydti.fawe.beta.implementation.IChunkExtent;
|
||||||
@ -45,8 +44,6 @@ import com.boydti.fawe.util.ExtentTraverser;
|
|||||||
import com.boydti.fawe.util.MaskTraverser;
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -56,7 +53,6 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
@ -74,11 +70,9 @@ import com.sk89q.worldedit.world.block.BlockType;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -125,40 +119,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
public BrushTool() {
|
public BrushTool() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
|
||||||
// public static BrushTool fromString(Player player, LocalSession session, String json) throws CommandException, InputParseException {
|
|
||||||
// Gson gson = new Gson();
|
|
||||||
// Type type = new TypeToken<Map<String, Object>>() {
|
|
||||||
// }.getType();
|
|
||||||
// Map<String, Object> root = gson.fromJson(json, type);
|
|
||||||
// if (root == null) {
|
|
||||||
// getLogger(BrushTool.class).debug("Failed to load " + json);
|
|
||||||
// return new BrushTool();
|
|
||||||
// }
|
|
||||||
// Map<String, Object> primary = (Map<String, Object>) root.get("primary");
|
|
||||||
// Map<String, Object> secondary = (Map<String, Object>) root.getOrDefault("secondary", primary);
|
|
||||||
//
|
|
||||||
// VisualMode visual = VisualMode.valueOf((String) root.getOrDefault("visual", "NONE"));
|
|
||||||
// TargetMode target = TargetMode.valueOf((String) root.getOrDefault("target", "TARGET_BLOCK_RANGE"));
|
|
||||||
// int range = ((Number) root.getOrDefault("range", -1)).intValue();
|
|
||||||
// int offset = ((Number) root.getOrDefault("offset", 0)).intValue();
|
|
||||||
//
|
|
||||||
// BrushTool tool = new BrushTool();
|
|
||||||
// tool.visualMode = visual;
|
|
||||||
// tool.targetMode = target;
|
|
||||||
// tool.range = range;
|
|
||||||
// tool.targetOffset = offset;
|
|
||||||
//
|
|
||||||
// BrushSettings primarySettings = BrushSettings.get(tool, player, session, primary);
|
|
||||||
// tool.setPrimary(primarySettings);
|
|
||||||
// if (primary != secondary) {
|
|
||||||
// BrushSettings secondarySettings = BrushSettings.get(tool, player, session, secondary);
|
|
||||||
// tool.setSecondary(secondarySettings);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return tool;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void setHolder(BaseItem holder) {
|
public void setHolder(BaseItem holder) {
|
||||||
this.holder = holder;
|
this.holder = holder;
|
||||||
}
|
}
|
||||||
@ -167,32 +127,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
return primary.getBrush() != null || secondary.getBrush() != null;
|
return primary.getBrush() != null || secondary.getBrush() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return toString(new Gson());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(Gson gson) {
|
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
|
||||||
map.put("primary", primary.getSettings());
|
|
||||||
if (primary != secondary) {
|
|
||||||
map.put("secondary", secondary.getSettings());
|
|
||||||
}
|
|
||||||
if (visualMode != null && visualMode != VisualMode.NONE) {
|
|
||||||
map.put("visual", visualMode);
|
|
||||||
}
|
|
||||||
if (targetMode != TargetMode.TARGET_BLOCK_RANGE) {
|
|
||||||
map.put("target", targetMode);
|
|
||||||
}
|
|
||||||
if (range != -1 && range != DEFAULT_RANGE) {
|
|
||||||
map.put("range", range);
|
|
||||||
}
|
|
||||||
if (targetOffset != 0) {
|
|
||||||
map.put("offset", targetOffset);
|
|
||||||
}
|
|
||||||
return gson.toJson(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if (holder != null) {
|
if (holder != null) {
|
||||||
BrushCache.setTool(holder, this);
|
BrushCache.setTool(holder, this);
|
||||||
@ -357,7 +291,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current brush.
|
* Get the current brush.
|
||||||
*
|
|
||||||
* @return the current brush
|
* @return the current brush
|
||||||
*/
|
*/
|
||||||
public Brush getBrush() {
|
public Brush getBrush() {
|
||||||
|
@ -62,11 +62,11 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) {
|
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) {
|
||||||
try {
|
try {
|
||||||
editSession.disableBuffering();
|
editSession.disableBuffering();
|
||||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
BaseBlock applied = secondary.apply(blockPoint);
|
BaseBlock applied = secondary.apply(blockPoint);
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
editSession.setBlock(blockPoint, secondary);
|
editSession.setBlock(blockPoint, secondary);
|
||||||
} else {
|
} else {
|
||||||
editSession.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), secondary);
|
editSession.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), secondary);
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException ignored) {
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
@ -76,8 +76,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
} finally {
|
} finally {
|
||||||
if (bag != null) {
|
if (bag != null) {
|
||||||
bag.flushChanges();
|
bag.flushChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,11 +90,11 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) {
|
try (EditSession editSession = session.createEditSession(player, "LongRangeBuildTool")) {
|
||||||
try {
|
try {
|
||||||
editSession.disableBuffering();
|
editSession.disableBuffering();
|
||||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||||
BaseBlock applied = primary.apply(blockPoint);
|
BaseBlock applied = primary.apply(blockPoint);
|
||||||
if (applied.getBlockType().getMaterial().isAir()) {
|
if (applied.getBlockType().getMaterial().isAir()) {
|
||||||
editSession.setBlock(blockPoint, primary);
|
editSession.setBlock(blockPoint, primary);
|
||||||
} else {
|
} else {
|
||||||
editSession.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), primary);
|
editSession.setBlock(pos.toVector().subtract(pos.getDirection()).toBlockPoint(), primary);
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException ignored) {
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
@ -104,8 +104,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
} finally {
|
} finally {
|
||||||
if (bag != null) {
|
if (bag != null) {
|
||||||
bag.flushChanges();
|
bag.flushChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ public class QueryTool implements BlockTool {
|
|||||||
builder.append(TextComponent.of(" (" + legacy[0] + ":" + legacy[1] + ") ", TextColor.DARK_GRAY)
|
builder.append(TextComponent.of(" (" + legacy[0] + ":" + legacy[1] + ") ", TextColor.DARK_GRAY)
|
||||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.legacy.hover"))));
|
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.legacy.hover"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
|
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
|
||||||
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
|
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
|
||||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.light.hover"))));
|
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.tool.info.light.hover"))));
|
||||||
|
@ -120,4 +120,5 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
recurse(server, editSession, world, pos.add(0, -1, 0),
|
recurse(server, editSession, world, pos.add(0, -1, 0),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -31,6 +29,7 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plants a tree.
|
* Plants a tree.
|
||||||
|
@ -328,12 +328,12 @@ public class PlatformManager {
|
|||||||
if (!(actor instanceof Player)) {
|
if (!(actor instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = (Player) actor;
|
Player player = (Player) actor;
|
||||||
LocalSession session = worldEdit.getSessionManager().get(actor);
|
LocalSession session = worldEdit.getSessionManager().get(actor);
|
||||||
|
|
||||||
Request.reset();
|
Request.reset();
|
||||||
Request.request().setSession(session);
|
Request.request().setSession(session);
|
||||||
Request.request().setWorld(player.getWorld());
|
Request.request().setWorld(player.getWorld());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Vector3 vector = location.toVector();
|
Vector3 vector = location.toVector();
|
||||||
@ -348,19 +348,19 @@ public class PlatformManager {
|
|||||||
// superpickaxe is special because its primary interaction is a left click, not a right click
|
// superpickaxe is special because its primary interaction is a left click, not a right click
|
||||||
// in addition, it is implicitly bound to all pickaxe items, not just a single tool item
|
// in addition, it is implicitly bound to all pickaxe items, not just a single tool item
|
||||||
if (session.hasSuperPickAxe() && player.isHoldingPickAxe()) {
|
if (session.hasSuperPickAxe() && player.isHoldingPickAxe()) {
|
||||||
final BlockTool superPickaxe = session.getSuperPickaxe();
|
final BlockTool superPickaxe = session.getSuperPickaxe();
|
||||||
if (superPickaxe != null && superPickaxe.canUse(player)) {
|
if (superPickaxe != null && superPickaxe.canUse(player)) {
|
||||||
player.runAction(() -> reset(superPickaxe)
|
player.runAction(() -> reset(superPickaxe)
|
||||||
.actPrimary(queryCapability(Capability.WORLD_EDITING),
|
.actPrimary(queryCapability(Capability.WORLD_EDITING),
|
||||||
getConfiguration(), player, session, location), false, true);
|
getConfiguration(), player, session, location), false, true);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Tool tool = session.getTool(player);
|
Tool tool = session.getTool(player);
|
||||||
if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) {
|
if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) {
|
||||||
player.runAction(() -> reset(((DoubleActionBlockTool) tool))
|
player.runAction(() -> reset((DoubleActionBlockTool) tool)
|
||||||
.actSecondary(queryCapability(Capability.WORLD_EDITING),
|
.actSecondary(queryCapability(Capability.WORLD_EDITING),
|
||||||
getConfiguration(), player, session, location), false, true);
|
getConfiguration(), player, session, location), false, true);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -384,10 +384,10 @@ public class PlatformManager {
|
|||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
handleThrowable(e, actor);
|
handleThrowable(e, actor);
|
||||||
} finally {
|
} finally {
|
||||||
Request.reset();
|
Request.reset();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void handleThrowable(Throwable e, Actor actor) {
|
public void handleThrowable(Throwable e, Actor actor) {
|
||||||
FaweException faweException = FaweException.get(e);
|
FaweException faweException = FaweException.get(e);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.Filter;
|
import com.boydti.fawe.beta.Filter;
|
||||||
import com.boydti.fawe.beta.IBatchProcessor;
|
|
||||||
import com.boydti.fawe.object.changeset.AbstractChangeSet;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -209,21 +207,6 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
|||||||
return getExtent().setBiome(position, biome);
|
return getExtent().setBiome(position, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
// special
|
|
||||||
@Override
|
|
||||||
public Extent disableHistory() {
|
|
||||||
return super.disableHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Extent addProcessor(IBatchProcessor processor) {
|
|
||||||
return super.addProcessor(processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Extent enableHistory(AbstractChangeSet changeSet) {
|
|
||||||
return super.enableHistory(changeSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Operation commit() {
|
public Operation commit() {
|
||||||
|
Loading…
Reference in New Issue
Block a user