mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 04:38:35 +00:00
Major command changes that don't work yet.
This commit is contained in:
@ -19,17 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.session;
|
||||
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -44,11 +43,12 @@ public class PasteBuilder {
|
||||
private final Transform transform;
|
||||
private final Extent targetExtent;
|
||||
|
||||
private Mask sourceMask = Masks.alwaysTrue();
|
||||
|
||||
private BlockVector3 to = BlockVector3.ZERO;
|
||||
private boolean ignoreAirBlocks;
|
||||
private boolean ignoreBiomes;
|
||||
private boolean ignoreEntities;
|
||||
private RegionFunction canApply;
|
||||
private boolean copyEntities = true; // default because it used to be this way
|
||||
private boolean copyBiomes;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -75,6 +75,23 @@ public class PasteBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom mask of blocks to ignore from the source.
|
||||
* This provides a more flexible alternative to {@link #ignoreAirBlocks(boolean)}, for example
|
||||
* one might want to ignore structure void if copying a Minecraft Structure, etc.
|
||||
*
|
||||
* @param sourceMask
|
||||
* @return this builder instance
|
||||
*/
|
||||
public PasteBuilder maskSource(Mask sourceMask) {
|
||||
if (sourceMask == null) {
|
||||
this.sourceMask = Masks.alwaysTrue();
|
||||
return this;
|
||||
}
|
||||
this.sourceMask = sourceMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether air blocks in the source are skipped over when pasting.
|
||||
*
|
||||
@ -85,18 +102,29 @@ public class PasteBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PasteBuilder ignoreBiomes(boolean ignoreBiomes) {
|
||||
this.ignoreBiomes = ignoreBiomes;
|
||||
/**
|
||||
* Set whether the copy should include source entities.
|
||||
* Note that this is true by default for legacy reasons.
|
||||
*
|
||||
* @param copyEntities
|
||||
* @return this builder instance
|
||||
*/
|
||||
public PasteBuilder copyEntities(boolean copyEntities) {
|
||||
this.copyEntities = copyEntities;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PasteBuilder ignoreEntities(boolean ignoreEntities) {
|
||||
this.ignoreEntities = ignoreEntities;
|
||||
/**
|
||||
* Set whether the copy should include source biomes (if available).
|
||||
*
|
||||
* @param copyBiomes
|
||||
* @return this builder instance
|
||||
*/
|
||||
public PasteBuilder copyBiomes(boolean copyBiomes) {
|
||||
this.copyBiomes = copyBiomes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PasteBuilder filter(RegionFunction function) {
|
||||
this.canApply = function;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -106,28 +134,17 @@ public class PasteBuilder {
|
||||
* @return the operation
|
||||
*/
|
||||
public Operation build() {
|
||||
Extent extent = clipboard;
|
||||
if (!transform.isIdentity()) {
|
||||
extent = new BlockTransformExtent(extent, transform);
|
||||
}
|
||||
BlockTransformExtent extent = new BlockTransformExtent(clipboard, transform);
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to);
|
||||
copy.setTransform(transform);
|
||||
copy.setCopyingEntities(!ignoreEntities);
|
||||
copy.setCopyBiomes((!ignoreBiomes) && (!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes()));
|
||||
if (this.canApply != null) {
|
||||
copy.setFilterFunction(this.canApply);
|
||||
}
|
||||
if (targetExtent instanceof EditSession) {
|
||||
Mask sourceMask = ((EditSession) targetExtent).getSourceMask();
|
||||
if (sourceMask != null) {
|
||||
new MaskTraverser(sourceMask).reset(extent);
|
||||
copy.setSourceMask(sourceMask);
|
||||
((EditSession) targetExtent).setSourceMask(null);
|
||||
}
|
||||
}
|
||||
if (ignoreAirBlocks) {
|
||||
copy.setSourceMask(new ExistingBlockMask(clipboard));
|
||||
copy.setSourceMask(sourceMask == Masks.alwaysTrue() ? new ExistingBlockMask(clipboard)
|
||||
: new MaskIntersection(sourceMask, new ExistingBlockMask(clipboard)));
|
||||
} else {
|
||||
copy.setSourceMask(sourceMask);
|
||||
}
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setCopyingBiomes(copyBiomes && clipboard.hasBiomes());
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
@ -36,6 +38,8 @@ import com.sk89q.worldedit.session.storage.VoidStore;
|
||||
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -63,6 +67,8 @@ public class SessionManager {
|
||||
private static final int FLUSH_PERIOD = 1000 * 60;
|
||||
private static final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 5));
|
||||
private static final Logger log = LoggerFactory.getLogger(SessionManager.class);
|
||||
private static boolean warnedInvalidTool;
|
||||
|
||||
private final Timer timer = new Timer();
|
||||
private final WorldEdit worldEdit;
|
||||
private final Map<UUID, SessionHolder> sessions = new HashMap<>();
|
||||
@ -187,6 +193,19 @@ public class SessionManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setDefaultWand(String sessionItem, String configItem, LocalSession session, Tool wand) throws InvalidToolBindException {
|
||||
ItemType wandItem = null;
|
||||
if (sessionItem != null) {
|
||||
wandItem = ItemTypes.get(sessionItem);
|
||||
}
|
||||
if (wandItem == null) {
|
||||
wandItem = ItemTypes.get(configItem);
|
||||
}
|
||||
if (wandItem != null) {
|
||||
session.setTool(wandItem, wand);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a map of sessions to disk.
|
||||
*
|
||||
@ -242,7 +261,7 @@ public class SessionManager {
|
||||
* @return the key object
|
||||
*/
|
||||
protected UUID getKey(SessionKey key) {
|
||||
return key.getUniqueId();
|
||||
return key.getUniqueId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.session.request;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
@ -49,9 +49,7 @@ public final class Request {
|
||||
*
|
||||
* @return the world, which may be null
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
World getWorld() {
|
||||
public @Nullable World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@ -68,9 +66,7 @@ public final class Request {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
public
|
||||
@Nullable
|
||||
Extent getExtent() {
|
||||
public @Nullable Extent getExtent() {
|
||||
if (extent != null) return extent;
|
||||
if (editSession != null) return editSession;
|
||||
if (world != null) return world;
|
||||
@ -91,9 +87,7 @@ public final class Request {
|
||||
*
|
||||
* @return the session, which may be null
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
LocalSession getSession() {
|
||||
public @Nullable LocalSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
@ -111,9 +105,7 @@ public final class Request {
|
||||
*
|
||||
* @return the edit session, which may be null
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
EditSession getEditSession() {
|
||||
public @Nullable EditSession getEditSession() {
|
||||
return editSession;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,8 @@ public class RequestExtent implements Extent {
|
||||
if (request == null || !request.isValid()) {
|
||||
request = Request.request();
|
||||
}
|
||||
return request.getEditSession();
|
||||
final EditSession editSession = request.getEditSession();
|
||||
return editSession == null ? request.getWorld() : editSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user