3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 20:10:06 +01:00

Update to PlotSquared-we branch

Dieser Commit ist enthalten in:
Jesse Boyd 2019-11-06 09:29:20 +00:00
Ursprung 0bfb1dbdd1
Commit 240b2de90c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
27 geänderte Dateien mit 284 neuen und 198 gelöschten Zeilen

Datei anzeigen

@ -8,6 +8,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.generator.GenBase; import com.sk89q.worldedit.function.generator.GenBase;
import com.sk89q.worldedit.function.generator.Resource; import com.sk89q.worldedit.function.generator.Resource;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
@ -292,7 +293,7 @@ public interface IDelegateQueueExtent extends IQueueExtent {
} }
@Override @Override
default BlockArrayClipboard lazyCopy(Region region) { default Clipboard lazyCopy(Region region) {
return getParent().lazyCopy(region); return getParent().lazyCopy(region);
} }

Datei anzeigen

@ -7,6 +7,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.generator.GenBase; import com.sk89q.worldedit.function.generator.GenBase;
import com.sk89q.worldedit.function.generator.Resource; import com.sk89q.worldedit.function.generator.Resource;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
@ -699,7 +700,7 @@ public class DelegateFilterBlock extends FilterBlock {
} }
@Override @Override
public BlockArrayClipboard lazyCopy(Region region) { public Clipboard lazyCopy(Region region) {
return parent.lazyCopy(region); return parent.lazyCopy(region);
} }

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.sk89q.worldedit.extent.Extent;
public class BatchProcessorHolder implements IBatchProcessorHolder { public class BatchProcessorHolder implements IBatchProcessorHolder {
private IBatchProcessor processor = EmptyBatchProcessor.INSTANCE; private IBatchProcessor processor = EmptyBatchProcessor.INSTANCE;

Datei anzeigen

@ -0,0 +1,24 @@
package com.boydti.fawe.beta.implementation.processors;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.sk89q.worldedit.extent.Extent;
public abstract class ExtentBatchProcessorHolder extends BatchProcessorHolder implements Extent {
@Override
public Extent addProcessor(IBatchProcessor processor) {
join(processor);
return this;
}
@Override
public Extent enableHistory(FaweChangeSet changeSet) {
return this.addProcessor(changeSet);
}
@Override
public Extent disableHistory() {
this.remove(FaweChangeSet.class);
return this;
}
}

Datei anzeigen

@ -14,6 +14,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
@ -187,11 +188,10 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap
* @return * @return
*/ */
@Override @Override
public BlockArrayClipboard lazyCopy(Region region) { public Clipboard lazyCopy(Region region) {
WorldCopyClipboard faweClipboard = new WorldCopyClipboard(this, region); WorldCopyClipboard clipboard = new WorldCopyClipboard(() -> this, region);
BlockArrayClipboard weClipboard = new BlockArrayClipboard(region, faweClipboard); clipboard.setOrigin(region.getMinimumPoint());
weClipboard.setOrigin(region.getMinimumPoint()); return clipboard;
return weClipboard;
} }
/** /**

Datei anzeigen

@ -262,6 +262,10 @@ public abstract class QueueHandler implements Trimable, Runnable {
return new SingleThreadQueueExtent(); return new SingleThreadQueueExtent();
} }
public void uncache() {
queuePool.set(null);
}
public abstract void startSet(boolean parallel); public abstract void startSet(boolean parallel);
public abstract void endSet(boolean parallel); public abstract void endSet(boolean parallel);

Datei anzeigen

@ -15,6 +15,7 @@ import com.boydti.fawe.beta.implementation.chunk.ChunkHolder;
import com.boydti.fawe.beta.implementation.chunk.ReferenceChunk; import com.boydti.fawe.beta.implementation.chunk.ReferenceChunk;
import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder; import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder;
import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor;
import com.boydti.fawe.beta.implementation.processors.ExtentBatchProcessorHolder;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -33,7 +34,7 @@ import java.util.concurrent.Future;
* <p> * <p>
* This queue is reusable {@link #init(IChunkCache)} * This queue is reusable {@link #init(IChunkCache)}
*/ */
public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQueueExtent { public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent {
// // Pool discarded chunks for reuse (can safely be cleared by another thread) // // Pool discarded chunks for reuse (can safely be cleared by another thread)
// private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>(); // private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
@ -88,7 +89,6 @@ public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQu
*/ */
protected synchronized void reset() { protected synchronized void reset() {
if (!this.initialized) return; if (!this.initialized) return;
checkThread();
if (!this.chunks.isEmpty()) { if (!this.chunks.isEmpty()) {
for (IChunk chunk : this.chunks.values()) { for (IChunk chunk : this.chunks.values()) {
chunk.recycle(); chunk.recycle();
@ -124,23 +124,6 @@ public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQu
initialized = true; initialized = true;
} }
@Override
public Extent addProcessor(IBatchProcessor processor) {
join(processor);
return this;
}
@Override
public Extent enableHistory(FaweChangeSet changeSet) {
return this.addProcessor(changeSet);
}
@Override
public Extent disableHistory() {
this.remove(FaweChangeSet.class);
return this;
}
@Override @Override
public int size() { public int size() {
return chunks.size() + submissions.size(); return chunks.size() + submissions.size();
@ -241,8 +224,6 @@ public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQu
if (chunk != null) { if (chunk != null) {
return chunk; return chunk;
} }
checkThread();
final int size = chunks.size(); final int size = chunks.size();
final boolean lowMem = MemUtil.isMemoryLimited(); final boolean lowMem = MemUtil.isMemoryLimited();
if (enabledQueue && (lowMem || size > Settings.IMP.QUEUE.TARGET_SIZE)) { if (enabledQueue && (lowMem || size > Settings.IMP.QUEUE.TARGET_SIZE)) {
@ -316,7 +297,6 @@ public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQu
@Override @Override
public synchronized void flush() { public synchronized void flush() {
checkThread();
if (!chunks.isEmpty()) { if (!chunks.isEmpty()) {
if (MemUtil.isMemoryLimited()) { if (MemUtil.isMemoryLimited()) {
for (IChunk chunk : chunks.values()) { for (IChunk chunk : chunks.values()) {

Datei anzeigen

@ -15,7 +15,7 @@ public class Settings extends Config {
@Ignore @Ignore
public boolean PROTOCOL_SUPPORT_FIX = false; public boolean PROTOCOL_SUPPORT_FIX = false;
@Ignore @Ignore
public boolean PLOTSQUARED_HOOK = false; public boolean PLOTSQUARED_HOOK = true;
@Comment("These first 6 aren't configurable") // This is a comment @Comment("These first 6 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable @Final // Indicates that this value isn't configurable

Datei anzeigen

@ -1,7 +1,10 @@
package com.boydti.fawe.jnbt.anvil; package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.beta.Trimable;
import com.boydti.fawe.beta.implementation.processors.ExtentBatchProcessorHolder;
import com.boydti.fawe.jnbt.streamer.StreamDelegate; import com.boydti.fawe.jnbt.streamer.StreamDelegate;
import com.boydti.fawe.object.RunnableVal4; import com.boydti.fawe.object.RunnableVal4;
import com.boydti.fawe.object.collection.CleanableThreadLocal; import com.boydti.fawe.object.collection.CleanableThreadLocal;
@ -9,7 +12,11 @@ import com.boydti.fawe.object.io.BufferedRandomAccessFile;
import com.boydti.fawe.object.io.FastByteArrayInputStream; import com.boydti.fawe.object.io.FastByteArrayInputStream;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@ -34,7 +41,7 @@ import java.util.zip.InflaterInputStream;
* e.g.: `.Level.Entities.#` (Starts with a . as the root tag is unnamed) * e.g.: `.Level.Entities.#` (Starts with a . as the root tag is unnamed)
* Note: This class isn't thread safe. You can use it in an async thread, but not multiple at the same time * Note: This class isn't thread safe. You can use it in an async thread, but not multiple at the same time
*/ */
public class MCAFile implements Trimable { public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, Extent {
private static Field fieldBuf2; private static Field fieldBuf2;
private static Field fieldBuf3; private static Field fieldBuf3;
@ -145,6 +152,23 @@ public class MCAFile implements Trimable {
return init(new File(world.getStoragePath().toFile(), File.separator + "regions" + File.separator + "r." + mcrX + "." + mcrZ + ".mca")); return init(new File(world.getStoragePath().toFile(), File.separator + "regions" + File.separator + "r." + mcrX + "." + mcrZ + ".mca"));
} }
@Override
public BlockVector3 getMinimumPoint() {
return BlockVector3.at(this.X << 9, 0, this.Z << 9);
}
@Override
public BlockVector3 getMaximumPoint() {
return BlockVector3.at((this.X << 9) + 511, FaweCache.IMP.WORLD_MAX_Y, (this.Z << 9) + 511);
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
// final IChunk chunk = getChunk(x >> 4, z >> 4);
// return chunk.setTile(x & 15, y, z & 15, tile);
return false;
}
public int getIndex(int chunkX, int chunkZ) { public int getIndex(int chunkX, int chunkZ) {
return ((chunkX & 31) << 2) + ((chunkZ & 31) << 7); return ((chunkX & 31) << 2) + ((chunkZ & 31) << 7);
} }

Datei anzeigen

@ -0,0 +1,23 @@
package com.boydti.fawe.jnbt.anvil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
public class MCAWorld implements Extent {
@Override
public BlockVector3 getMinimumPoint() {
return null;
}
@Override
public BlockVector3 getMaximumPoint() {
return null;
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
return false;
}
}

Datei anzeigen

@ -1,15 +1,20 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.Fawe;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
public abstract class ReadOnlyClipboard extends SimpleClipboard { public abstract class ReadOnlyClipboard extends SimpleClipboard {
public final Region region; public final Region region;
@ -19,12 +24,48 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {
this.region = region; this.region = region;
} }
public static ReadOnlyClipboard of(final Extent editSession, final Region region) { public static ReadOnlyClipboard of(final Region region) {
return of(editSession, region, true, false); return of(Request.request().getEditSession(), region);
} }
public static ReadOnlyClipboard of(final Extent editSession, final Region region, boolean copyEntities, boolean copyBiomes) { public static ReadOnlyClipboard of(final Region region, boolean copyEntities, boolean copyBiomes) {
return new WorldCopyClipboard(editSession, region, copyEntities, copyBiomes); EditSession es = Request.request().getEditSession();
if (es == null) {
throw new IllegalArgumentException("Please provide an EditSession");
}
return of(es, region, copyEntities, copyBiomes);
}
public static ReadOnlyClipboard of(Extent extent, final Region region) {
Fawe.get().getQueueHandler().uncache();
return of(() -> extent, region);
}
public static ReadOnlyClipboard of(Extent extent, final Region region, boolean copyEntities, boolean copyBiomes) {
Fawe.get().getQueueHandler().uncache();
return of(() -> extent, region, copyEntities, copyBiomes);
}
public static ReadOnlyClipboard of(Supplier<Extent> supplier, final Region region) {
return of(supplier, region, true, false);
}
public static ReadOnlyClipboard of(Supplier<Extent> supplier, final Region region, boolean copyEntities, boolean copyBiomes) {
return new WorldCopyClipboard(supplier, region, copyEntities, copyBiomes);
}
private static Supplier<Extent> supply() {
World world = Request.request().getWorld();
return () -> {
EditSession current = Request.request().getEditSession();
if (current != null) {
if (current.getWorld().equals(world)) {
return current;
}
throw new UnsupportedOperationException("TODO: Cannot lazy copy accross worlds (bug jesse)");
}
throw new IllegalStateException("No world");
};
} }
public Region getRegion() { public Region getRegion() {

Datei anzeigen

@ -1,41 +1,30 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockState;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.function.Supplier;
public class WorldCopyClipboard extends ReadOnlyClipboard { public class WorldCopyClipboard extends ReadOnlyClipboard {
public final int mx, my, mz; public final int mx, my, mz;
private final boolean hasBiomes; private final boolean hasBiomes;
private final boolean hasEntities; private final boolean hasEntities;
private MutableBlockVector2 MutableBlockVector2 = new MutableBlockVector2(); private Extent extent;
public final Extent extent; private Supplier<Extent> supplier;
public WorldCopyClipboard(Extent editSession, Region region) { public WorldCopyClipboard(Supplier<Extent> supplier, Region region) {
this(editSession, region, true, false); this(supplier, region, true, false);
} }
public WorldCopyClipboard(Extent editSession, Region region, boolean hasEntities, boolean hasBiomes) { public WorldCopyClipboard(Supplier<Extent> supplier, Region region, boolean hasEntities, boolean hasBiomes) {
super(region); super(region);
this.hasBiomes = hasBiomes; this.hasBiomes = hasBiomes;
this.hasEntities = hasEntities; this.hasEntities = hasEntities;
@ -43,27 +32,37 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
this.mx = origin.getBlockX(); this.mx = origin.getBlockX();
this.my = origin.getBlockY(); this.my = origin.getBlockY();
this.mz = origin.getBlockZ(); this.mz = origin.getBlockZ();
this.extent = editSession; this.supplier = supplier;
}
public Extent getExtent() {
if (extent != null) {
return extent;
}
extent = supplier.get();
supplier = null;
return extent;
} }
@Override @Override
public BaseBlock getFullBlock(int x, int y, int z) { public BaseBlock getFullBlock(int x, int y, int z) {
return extent.getFullBlock(BlockVector3.at(mx + x, my + y, mz + z)); return getExtent().getFullBlock(mx + x, my + y, mz + z);
} }
public BaseBlock getBlockAbs(int x, int y, int z) { @Override
return extent.getFullBlock(BlockVector3.at(x, y, z)); public BlockState getBlock(int x, int y, int z) {
return getExtent().getBlock(mx + x, my + y, mz + z);
} }
@Override @Override
public BiomeType getBiomeType(int x, int z) { public BiomeType getBiomeType(int x, int z) {
return extent.getBiome(MutableBlockVector2.setComponents(mx + x, mz + z)); return getExtent().getBiomeType(mx + x, mz + z);
} }
@Override @Override
public List<? extends Entity> getEntities() { public List<? extends Entity> getEntities() {
if (!hasEntities) return new ArrayList<>(); if (!hasEntities) return new ArrayList<>();
return extent.getEntities(getRegion()); return getExtent().getEntities(getRegion());
} }
@Override @Override

Datei anzeigen

@ -1,20 +1,24 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.util.function.Supplier;
public class WorldCutClipboard extends WorldCopyClipboard { public class WorldCutClipboard extends WorldCopyClipboard {
public WorldCutClipboard(EditSession editSession, Region region, boolean copyEntities, boolean copyBiome) { public WorldCutClipboard(Supplier<Extent> supplier, Region region) {
super(editSession, region, copyEntities, copyBiome); super(supplier, region);
} }
public WorldCutClipboard(EditSession editSession, Region region) { public WorldCutClipboard(Supplier<Extent> supplier, Region region, boolean hasEntities, boolean hasBiomes) {
super(editSession, region); super(supplier, region, hasEntities, hasBiomes);
} }
@Override @Override
@ -22,22 +26,34 @@ public class WorldCutClipboard extends WorldCopyClipboard {
int xx = mx + x; int xx = mx + x;
int yy = my + y; int yy = my + y;
int zz = mz + z; int zz = mz + z;
BaseBlock block = extent.getFullBlock(BlockVector3.at(xx, yy, zz)); Extent extent = getExtent();
BaseBlock block = extent.getFullBlock(xx, yy, zz);
extent.setBlock(xx, yy, zz, BlockTypes.AIR.getDefaultState()); extent.setBlock(xx, yy, zz, BlockTypes.AIR.getDefaultState());
return block; return block;
} }
@Override @Override
public BaseBlock getBlockAbs(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
BaseBlock block = extent.getFullBlock(BlockVector3.at(x, y, z)); int xx = mx + x;
int yy = my + y;
int zz = mz + z;
Extent extent = getExtent();
BlockState block = extent.getBlock(xx, yy, zz);
extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
return block; return block;
} }
@Override @Override
public void close() { public void close() {
Extent extent = getExtent();
if (extent instanceof EditSession) { if (extent instanceof EditSession) {
((EditSession) extent).flushQueue(); ((EditSession) extent).flushQueue();
} else if (extent instanceof Closeable) {
try {
((Closeable) extent).close();
} catch (IOException e) {
e.printStackTrace();
}
} else { } else {
extent.commit(); extent.commit();
} }

Datei anzeigen

@ -74,11 +74,11 @@ public final class MemBlockSet extends BlockSet {
} }
public BlockVector3 getMinimumPoint() { public BlockVector3 getMinimumPoint() {
return BlockVector3.at(getMinX(), getMinY(), getMinZ()); return BlockVector3.at(getMinX(), getMinimumY(), getMinZ());
} }
public BlockVector3 getMaximumPoint() { public BlockVector3 getMaximumPoint() {
return BlockVector3.at(getMaxX(), getMaxY(), getMaxZ()); return BlockVector3.at(getMaxX(), getMaximumY(), getMaxZ());
} }
@Override @Override
@ -280,7 +280,7 @@ public final class MemBlockSet extends BlockSet {
} }
@Override @Override
public int getMinY() { public int getMinimumY() {
int maxY = 15; int maxY = 15;
int maxy = 16; int maxy = 16;
int by = Integer.MAX_VALUE; int by = Integer.MAX_VALUE;
@ -325,7 +325,7 @@ public final class MemBlockSet extends BlockSet {
} }
@Override @Override
public int getMaxY() { public int getMaximumY() {
int maxY = 0; int maxY = 0;
int maxy = 0; int maxy = 0;
int by = Integer.MIN_VALUE; int by = Integer.MIN_VALUE;

Datei anzeigen

@ -2,7 +2,6 @@ package com.boydti.fawe.regions.general.integrations.plotquared;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
@ -10,6 +9,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -29,12 +29,12 @@ public class FaweChunkManager extends ChunkManager {
} }
@Override @Override
public CompletableFuture loadChunk(String world, ChunkLoc loc, boolean force) { public CompletableFuture loadChunk(String world, BlockVector2 loc, boolean force) {
return parent.loadChunk(world, loc, force); return parent.loadChunk(world, loc, force);
} }
@Override @Override
public void unloadChunk(String world, ChunkLoc loc, boolean save) { public void unloadChunk(String world, BlockVector2 loc, boolean save) {
parent.unloadChunk(world, loc, save); parent.unloadChunk(world, loc, save);
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -71,8 +70,8 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
} }
@Override @Override
public boolean setBlock(final int x, final int y, final int z, final PlotBlock id) { public boolean setBlock(final int x, final int y, final int z, final BlockState id) {
return setBlock(x, y, z, legacyMapper.getBaseBlockFromPlotBlock(id)); return setBlock(x, y, z, id);
} }
@Override @Override
@ -81,9 +80,8 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
} }
@Override @Override
public PlotBlock getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
BlockState block = IMP.getBlock(x, y, z); return IMP.getBlock(x, y, z);
return PlotBlock.get(block.toBaseBlock());
} }
private BiomeType biome; private BiomeType biome;

Datei anzeigen

@ -8,7 +8,6 @@ import com.boydti.fawe.util.IOUtil;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
@ -47,7 +46,7 @@ public class FaweSchematicHandler extends SchematicHandler {
} }
@Override @Override
public void getCompoundTag(final String world, final Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone) { public void getCompoundTag(final String world, final Set<CuboidRegion> regions, final RunnableVal<CompoundTag> whenDone) {
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
Location[] corners = MainUtil.getCorners(world, regions); Location[] corners = MainUtil.getCorners(world, regions);
Location pos1 = corners[0]; Location pos1 = corners[0];

Datei anzeigen

@ -12,7 +12,6 @@ import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -22,14 +21,13 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.biome.Biomes; import com.sk89q.worldedit.world.biome.Biomes;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -56,7 +54,7 @@ public class PlotSetBiome extends Command {
return null; return null;
} }
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
final HashSet<RegionWrapper> regions = plot.getRegions(); final Set<CuboidRegion> regions = plot.getRegions();
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
Collection<BiomeType> knownBiomes = BiomeTypes.values(); Collection<BiomeType> knownBiomes = BiomeTypes.values();
final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry); final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
@ -81,9 +79,8 @@ public class PlotSetBiome extends Command {
.limitUnlimited() .limitUnlimited()
.build(); .build();
long seed = ThreadLocalRandom.current().nextLong(); long seed = ThreadLocalRandom.current().nextLong();
for (RegionWrapper region : regions) { for (CuboidRegion region : regions) {
CuboidRegion cuboid = new CuboidRegion(BlockVector3.at(region.minX, 0, region.minZ), BlockVector3.at(region.maxX, 256, region.maxZ)); session.regenerate(region, biome, seed);
session.regenerate(cuboid, biome, seed);
} }
session.flushQueue(); session.flushQueue();
plot.removeRunning(); plot.removeRunning();

Datei anzeigen

@ -15,7 +15,6 @@ import com.github.intellectualsites.plotsquared.plot.listener.WEManager;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
@ -29,6 +28,7 @@ import com.sk89q.worldedit.regions.RegionIntersection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -107,7 +107,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
@Override @Override
public FaweMask getMask(Player player, MaskType type) { public FaweMask getMask(Player player, MaskType type) {
final PlotPlayer pp = PlotPlayer.wrap(player); final PlotPlayer pp = PlotPlayer.wrap(player);
final HashSet<RegionWrapper> regions; final Set<CuboidRegion> regions;
Plot plot = pp.getCurrentPlot(); Plot plot = pp.getCurrentPlot();
if (isAllowed(player, plot, type)) { if (isAllowed(player, plot, type)) {
regions = plot.getRegions(); regions = plot.getRegions();
@ -115,8 +115,8 @@ public class PlotSquaredFeature extends FaweMaskManager {
plot = null; plot = null;
regions = WEManager.getMask(pp); regions = WEManager.getMask(pp);
if (regions.size() == 1) { if (regions.size() == 1) {
RegionWrapper region = regions.iterator().next(); CuboidRegion region = regions.iterator().next();
if (region.minX == Integer.MIN_VALUE && region.maxX == Integer.MAX_VALUE) { if (region.getMinimumPoint().getX() == Integer.MIN_VALUE && region.getMaximumPoint().getX() == Integer.MAX_VALUE) {
regions.clear(); regions.clear();
} }
} }
@ -128,12 +128,12 @@ public class PlotSquaredFeature extends FaweMaskManager {
int min = area != null ? area.MIN_BUILD_HEIGHT : 0; int min = area != null ? area.MIN_BUILD_HEIGHT : 0;
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255; int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
final HashSet<com.boydti.fawe.object.RegionWrapper> faweRegions = new HashSet<>(); final HashSet<com.boydti.fawe.object.RegionWrapper> faweRegions = new HashSet<>();
for (RegionWrapper current : regions) { for (CuboidRegion current : regions) {
faweRegions.add(new com.boydti.fawe.object.RegionWrapper(current.minX, current.maxX, min, max, current.minZ, current.maxZ)); faweRegions.add(new com.boydti.fawe.object.RegionWrapper(current.getMinimumX(), current.getMaximumX(), min, max, current.getMinimumZ(), current.getMaximumZ()));
} }
final RegionWrapper region = regions.iterator().next(); final CuboidRegion region = regions.iterator().next();
final BlockVector3 pos1 = BlockVector3.at(region.minX, min, region.minZ); final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
final BlockVector3 pos2 = BlockVector3.at(region.maxX, max, region.maxZ); final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
final Plot finalPlot = plot; final Plot finalPlot = plot;
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot) || regions.isEmpty()) { if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot) || regions.isEmpty()) {
return null; return null;
@ -145,7 +145,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
} else { } else {
World world = FaweAPI.getWorld(area.worldname); World world = FaweAPI.getWorld(area.worldname);
List<Region> weRegions = regions.stream() List<Region> weRegions = regions.stream()
.map(r -> new CuboidRegion(world, BlockVector3.at(r.minX, r.minY, r.minZ), BlockVector3.at(r.maxX, r.maxY, r.maxZ))) .map(r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())))
.collect(Collectors.toList()); .collect(Collectors.toList());
maskedRegion = new RegionIntersection(world, weRegions); maskedRegion = new RegionIntersection(world, weRegions);
} }

Datei anzeigen

@ -45,6 +45,7 @@ import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.PasteEvent; import com.sk89q.worldedit.event.extent.PasteEvent;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
@ -69,6 +70,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
@ -86,6 +88,7 @@ import java.net.URLEncoder;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.function.Supplier;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@ -186,7 +189,7 @@ public class ClipboardCommands {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
} }
session.setClipboard(null); session.setClipboard(null);
ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(editSession, region, !skipEntities, copyBiomes); ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(region, !skipEntities, copyBiomes);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
clipboard.setOrigin(session.getPlacementPosition(actor)); clipboard.setOrigin(session.getPlacementPosition(actor));
@ -197,37 +200,37 @@ public class ClipboardCommands {
} }
} }
@Command( // @Command(
name = "/lazycut", // name = "/lazycut",
desc = "Lazily cut the selection to the clipboard" // desc = "Lazily cut the selection to the clipboard"
) // )
@CommandPermissions("worldedit.clipboard.lazycut") // @CommandPermissions("worldedit.clipboard.lazycut")
public void lazyCut(Actor actor, LocalSession session, EditSession editSession, // public void lazyCut(Actor actor, LocalSession session, EditSession editSession,
@Selection final Region region, // @Selection final Region region,
@Switch(name = 'e', desc = "Skip copy entities") // @Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities, // boolean skipEntities,
@ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") // @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "")
Mask maskOpt, // Mask maskOpt,
@Switch(name = 'b', desc = "Also copy biomes") // @Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes) throws WorldEditException { // boolean copyBiomes) throws WorldEditException {
BlockVector3 min = region.getMinimumPoint(); // BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); // BlockVector3 max = region.getMaximumPoint();
long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); // long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
FaweLimit limit = actor.getLimit(); // FaweLimit limit = actor.getLimit();
if (volume >= limit.MAX_CHECKS) { // if (volume >= limit.MAX_CHECKS) {
throw FaweCache.MAX_CHECKS; // throw FaweCache.MAX_CHECKS;
} // }
if (volume >= limit.MAX_CHANGES) { // if (volume >= limit.MAX_CHANGES) {
throw FaweCache.MAX_CHANGES; // throw FaweCache.MAX_CHANGES;
} // }
session.setClipboard(null); // session.setClipboard(null);
//
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes); // ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard); // BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
clipboard.setOrigin(session.getPlacementPosition(actor)); // clipboard.setOrigin(session.getPlacementPosition(actor));
session.setClipboard(new ClipboardHolder(clipboard)); // session.setClipboard(new ClipboardHolder(clipboard));
BBC.COMMAND_CUT_LAZY.send(actor, region.getArea()); // BBC.COMMAND_CUT_LAZY.send(actor, region.getArea());
} // }
@Command( @Command(
name = "/cut", name = "/cut",

Datei anzeigen

@ -72,6 +72,10 @@ import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -146,13 +150,13 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.test") @CommandPermissions("worldedit.region.test")
@Logging(REGION) @Logging(REGION)
public void test(World world, Player player, EditSession editSession, public void test(Player player, @Arg(desc = "hello there") String message) throws WorldEditException {
@Selection Region region,
@Arg(desc = "The pattern of blocks to set") TextComponent test = LegacyComponentSerializer.legacy().deserialize(message, '&');
Pattern pattern, InjectedValueAccess context) throws WorldEditException { player.print(message);
editSession.addProcessor(new ChunkSendProcessor(world, () -> Stream.of(player))); player.print(test);
editSession.addProcessor(NullProcessor.INSTANCE); test = test.hoverEvent(HoverEvent.showText(TextComponent.of("Blah")));
editSession.setBlocks(region, pattern); player.print(test);
} }
@Command( @Command(

Datei anzeigen

@ -32,6 +32,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.RegionMaskingFilter; import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.generator.CavesGen; import com.sk89q.worldedit.function.generator.CavesGen;
@ -465,11 +466,10 @@ public interface Extent extends InputExtent, OutputExtent {
* @param region * @param region
* @return * @return
*/ */
default BlockArrayClipboard lazyCopy(Region region) { default Clipboard lazyCopy(Region region) {
WorldCopyClipboard faweClipboard = new WorldCopyClipboard(this, region); WorldCopyClipboard faweClipboard = new WorldCopyClipboard(() -> this, region);
BlockArrayClipboard weClipboard = new BlockArrayClipboard(region, faweClipboard); faweClipboard.setOrigin(region.getMinimumPoint());
weClipboard.setOrigin(region.getMinimumPoint()); return faweClipboard;
return weClipboard;
} }

Datei anzeigen

@ -6,6 +6,7 @@ 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;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.generator.GenBase; import com.sk89q.worldedit.function.generator.GenBase;
import com.sk89q.worldedit.function.generator.Resource; import com.sk89q.worldedit.function.generator.Resource;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
@ -133,7 +134,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
} }
@Override @Override
public BlockArrayClipboard lazyCopy(Region region) { public Clipboard lazyCopy(Region region) {
return getExtent().lazyCopy(region); return getExtent().lazyCopy(region);
} }

Datei anzeigen

@ -131,8 +131,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
if (pos1 == null || pos2 == null) { if (pos1 == null || pos2 == null) {
return; return;
} }
pos1 = pos1.clampY(world == null ? Integer.MIN_VALUE : 0, world == null ? Integer.MAX_VALUE : world.getMaxY()); pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY());
pos2 = pos2.clampY(world == null ? Integer.MIN_VALUE : 0, world == null ? Integer.MAX_VALUE : world.getMaxY()); pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY());
minX = Math.min(pos1.getX(), pos2.getX()); minX = Math.min(pos1.getX(), pos2.getX());
minY = Math.min(pos1.getY(), pos2.getY()); minY = Math.min(pos1.getY(), pos2.getY());
minZ = Math.min(pos1.getZ(), pos2.getZ()); minZ = Math.min(pos1.getZ(), pos2.getZ());
@ -196,16 +196,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return max; return max;
} }
@Override
public int getMinimumY() {
return minY;
}
@Override
public int getMaximumY() {
return maxY;
}
@Override @Override
public void expand(BlockVector3... changes) { public void expand(BlockVector3... changes) {
checkNotNull(changes); checkNotNull(changes);
@ -655,15 +645,31 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
} }
@Override @Override
public int getMinY() { public int getMinimumY() {
return minY; return minY;
} }
@Override @Override
public int getMaxY() { public int getMaximumY() {
return maxY; return maxY;
} }
public int getMinimumX() {
return minX;
}
public int getMinimumZ() {
return minZ;
}
public int getMaximumX() {
return maxX;
}
public int getMaximumZ() {
return maxZ;
}
@Override @Override
public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) { public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
int chunkX = chunk.getX(); int chunkX = chunk.getX();

Datei anzeigen

@ -385,16 +385,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
return Polygons.polygonizeCylinder(center, radius, maxPoints); return Polygons.polygonizeCylinder(center, radius, maxPoints);
} }
@Override
public int getMinY() {
return minY;
}
@Override
public int getMaxY() {
return maxY;
}
/** /**
* Return a new instance with the given center and radius in the X and Z * Return a new instance with the given center and radius in the X and Z
* axes with a Y that extends from the bottom of the extent to the top * axes with a Y that extends from the bottom of the extent to the top

Datei anzeigen

@ -195,17 +195,17 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
*/ */
List<BlockVector2> polygonize(int maxPoints); List<BlockVector2> polygonize(int maxPoints);
default int getMinY() { default int getMinimumY() {
return getMinimumPoint().getY(); return getMinimumPoint().getY();
} }
default int getMaxY() { default int getMaximumY() {
return getMaximumPoint().getY(); return getMaximumPoint().getY();
} }
default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) { default void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
int minSection = Math.max(0, getMinY() >> 4); int minSection = Math.max(0, getMinimumY() >> 4);
int maxSection = Math.min(15, getMaxY() >> 4); int maxSection = Math.min(15, getMaximumY() >> 4);
for (int layer = minSection; layer <= maxSection; layer++) { for (int layer = minSection; layer <= maxSection; layer++) {
if (!get.hasSection(layer) || !filter.appliesLayer(chunk, layer)) return; if (!get.hasSection(layer) || !filter.appliesLayer(chunk, layer)) return;
block = block.init(get, set, layer); block = block.init(get, set, layer);

Datei anzeigen

@ -19,9 +19,6 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import com.google.common.io.Resources; import com.google.common.io.Resources;
@ -244,29 +241,6 @@ public final class LegacyMapper {
return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF }; return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF };
} }
public BaseBlock getBaseBlockFromPlotBlock(PlotBlock plotBlock) {
if(plotBlock instanceof StringPlotBlock) {
try {
return BlockTypes.get(plotBlock.toString()).getDefaultState().toBaseBlock();
} catch (Throwable failed) {
log.error("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace();
return null;
}
}else if(plotBlock instanceof LegacyPlotBlock) {
try {
return BaseBlock.getState(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData()).toBaseBlock();
} catch (Throwable failed) {
log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace();
return null;
}
}else {
log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
return null;
}
}
public final static LegacyMapper getInstance() { public final static LegacyMapper getInstance() {
return INSTANCE; return INSTANCE;
} }