Various fixes
This commit is contained in:
parent
706b44a26a
commit
0d7c0474cc
@ -8,7 +8,6 @@ import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitEntity;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
@ -91,6 +90,10 @@ public class AsyncWorld implements World {
|
||||
queue.enqueue();
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
queue.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldBorder getWorldBorder() {
|
||||
return TaskManager.IMP.sync(new RunnableVal<WorldBorder>() {
|
||||
|
@ -22,6 +22,7 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.MutableClassToInstanceMap;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.thevoxelbox.voxelsniper.brush.IBrush;
|
||||
import com.thevoxelbox.voxelsniper.brush.SnipeBrush;
|
||||
@ -87,7 +88,7 @@ public class Sniper {
|
||||
if (this.tmpWorld == null) {
|
||||
Player player = getPlayer();
|
||||
FawePlayer<Player> fp = FawePlayer.wrap(player);
|
||||
if (this.baseQueue == null) {
|
||||
if (this.baseQueue == null || !StringMan.isEqual(baseQueue.getWorldName(), player.getWorld().getName())) {
|
||||
this.baseQueue = FaweAPI.createQueue(fp.getLocation().world, false);
|
||||
}
|
||||
RegionWrapper[] mask = WEManager.IMP.getMask(fp);
|
||||
@ -398,7 +399,7 @@ public class Sniper {
|
||||
FaweChangeSet changeSet = changeQueue.getChangeSet();
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(getPlayer());
|
||||
LocalSession session = fp.getSession();
|
||||
baseQueue.enqueue();
|
||||
baseQueue.flush();
|
||||
session.remember(changeSet.toEditSession(fp));
|
||||
changeQueue.flush();
|
||||
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.object.change;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.extent.FastWorldEditExtent;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
@ -36,8 +37,9 @@ public class MutableBlockChange implements Change {
|
||||
|
||||
public void create(UndoContext context) {
|
||||
Extent extent = context.getExtent();
|
||||
if (extent.getClass() == FastWorldEditExtent.class) {
|
||||
FastWorldEditExtent fwee = (FastWorldEditExtent) extent;
|
||||
ExtentTraverser<FastWorldEditExtent> find = new ExtentTraverser(extent).find(FastWorldEditExtent.class);
|
||||
if (find != null) {
|
||||
FastWorldEditExtent fwee = find.get();
|
||||
fwee.getQueue().setBlock(x, y, z, id, data);
|
||||
} else {
|
||||
Fawe.debug("FAWE doesn't support: " + extent + " for " + getClass() + " (bug Empire92)");
|
||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.object.change;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.extent.FastWorldEditExtent;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
@ -30,8 +31,9 @@ public class MutableChunkChange implements Change {
|
||||
|
||||
public void create(UndoContext context, boolean undo) {
|
||||
Extent extent = context.getExtent();
|
||||
if (extent.getClass() == FastWorldEditExtent.class) {
|
||||
FastWorldEditExtent fwee = (FastWorldEditExtent) extent;
|
||||
ExtentTraverser<FastWorldEditExtent> find = new ExtentTraverser(extent).find(FastWorldEditExtent.class);
|
||||
if (find != null) {
|
||||
FastWorldEditExtent fwee = find.get();
|
||||
if (undo) {
|
||||
fwee.getQueue().setChunk(from);
|
||||
} else {
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.object.change;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.extent.FastWorldEditExtent;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.DoubleTag;
|
||||
import com.sk89q.jnbt.LongTag;
|
||||
@ -44,8 +45,9 @@ public class MutableEntityChange implements Change {
|
||||
|
||||
public void delete(UndoContext context) {
|
||||
Extent extent = context.getExtent();
|
||||
if (extent.getClass() == FastWorldEditExtent.class) {
|
||||
FastWorldEditExtent fwee = (FastWorldEditExtent) extent;
|
||||
ExtentTraverser<FastWorldEditExtent> find = new ExtentTraverser(extent).find(FastWorldEditExtent.class);
|
||||
if (find != null) {
|
||||
FastWorldEditExtent fwee = find.get();
|
||||
Map<String, Tag> map = tag.getValue();
|
||||
long most;
|
||||
long least;
|
||||
@ -72,8 +74,9 @@ public class MutableEntityChange implements Change {
|
||||
|
||||
public void create(UndoContext context) {
|
||||
Extent extent = context.getExtent();
|
||||
if (extent.getClass() == FastWorldEditExtent.class) {
|
||||
FastWorldEditExtent fwee = (FastWorldEditExtent) extent;
|
||||
ExtentTraverser<FastWorldEditExtent> find = new ExtentTraverser(extent).find(FastWorldEditExtent.class);
|
||||
if (find != null) {
|
||||
FastWorldEditExtent fwee = find.get();
|
||||
Map<String, Tag> map = tag.getValue();
|
||||
List<DoubleTag> pos = (List<DoubleTag>) map.get("Pos").getValue();
|
||||
int x = (int) Math.round(pos.get(0).getValue());
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.object.change;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.extent.FastWorldEditExtent;
|
||||
import com.boydti.fawe.util.ExtentTraverser;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -37,8 +38,9 @@ public class MutableTileChange implements Change {
|
||||
|
||||
public void create(UndoContext context) {
|
||||
Extent extent = context.getExtent();
|
||||
if (extent.getClass() == FastWorldEditExtent.class) {
|
||||
FastWorldEditExtent fwee = (FastWorldEditExtent) extent;
|
||||
ExtentTraverser<FastWorldEditExtent> find = new ExtentTraverser(extent).find(FastWorldEditExtent.class);
|
||||
if (find != null) {
|
||||
FastWorldEditExtent fwee = find.get();
|
||||
Map<String, Tag> map = tag.getValue();
|
||||
int x = ((IntTag) map.get("x")).getValue();
|
||||
int y = ((IntTag) map.get("y")).getValue();
|
||||
|
@ -71,7 +71,9 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
public abstract Iterator<Change> getIterator(boolean redo);
|
||||
|
||||
public EditSession toEditSession(FawePlayer player) {
|
||||
return new EditSessionBuilder(world).player(player).autoQueue(false).fastmode(true).checkMemory(false).changeSet(this).allowedRegions(RegionWrapper.GLOBAL().toArray()).build();
|
||||
EditSession editSession = new EditSessionBuilder(world).player(player).autoQueue(false).fastmode(false).checkMemory(false).changeSet(this).allowedRegions(RegionWrapper.GLOBAL().toArray()).build();
|
||||
editSession.setSize(1);
|
||||
return editSession;
|
||||
}
|
||||
|
||||
public void add(EntityCreate change) {
|
||||
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
|
||||
public class DelegateFaweQueue extends FaweQueue {
|
||||
private final FaweQueue parent;
|
||||
private FaweQueue parent;
|
||||
|
||||
public DelegateFaweQueue(FaweQueue parent) {
|
||||
super(parent.getWorldName());
|
||||
@ -23,6 +23,10 @@ public class DelegateFaweQueue extends FaweQueue {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(FaweQueue parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return parent.getWorldName();
|
||||
|
@ -156,7 +156,7 @@ public class EditSession implements Extent {
|
||||
|
||||
private World world;
|
||||
private FaweQueue queue;
|
||||
private Extent bypassNone;
|
||||
private Extent extent;
|
||||
private HistoryExtent history;
|
||||
private Extent bypassHistory;
|
||||
private Extent bypassAll;
|
||||
@ -248,19 +248,19 @@ public class EditSession implements Extent {
|
||||
this.limit = limit;
|
||||
this.queue = SetQueue.IMP.getNewQueue(Fawe.imp().getWorldName(world), fastmode, autoQueue);
|
||||
this.bypassAll = wrapExtent(new FastWorldEditExtent(world, queue), bus, event, Stage.BEFORE_CHANGE);
|
||||
this.bypassHistory = (bypassNone = wrapExtent(bypassAll, bus, event, Stage.BEFORE_REORDER));
|
||||
this.bypassHistory = (this.extent = wrapExtent(bypassAll, bus, event, Stage.BEFORE_REORDER));
|
||||
if (!fastmode && !(changeSet instanceof NullChangeSet)) {
|
||||
if (combineStages) {
|
||||
changeTask = changeSet;
|
||||
changeSet.addChangeTask(queue);
|
||||
} else {
|
||||
this.bypassNone = (history = new HistoryExtent(this, bypassHistory, changeSet, queue));
|
||||
this.extent = (history = new HistoryExtent(this, bypassHistory, changeSet, queue));
|
||||
}
|
||||
}
|
||||
if (allowedRegions != null) {
|
||||
this.bypassNone = new ProcessedWEExtent(bypassNone, allowedRegions, limit);
|
||||
this.extent = new ProcessedWEExtent(this.extent, allowedRegions, limit);
|
||||
}
|
||||
bypassNone = wrapExtent(bypassNone, bus, event, Stage.BEFORE_HISTORY);
|
||||
this.extent = wrapExtent(this.extent, bus, event, Stage.BEFORE_HISTORY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,7 +302,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
public FaweRegionExtent getRegionExtent() {
|
||||
ExtentTraverser<FaweRegionExtent> traverser = new ExtentTraverser(bypassNone).find(FaweRegionExtent.class);
|
||||
ExtentTraverser<FaweRegionExtent> traverser = new ExtentTraverser(this.extent).find(FaweRegionExtent.class);
|
||||
return traverser == null ? null : traverser.get();
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
public boolean cancel() {
|
||||
ExtentTraverser traverser = new ExtentTraverser(bypassNone);
|
||||
ExtentTraverser traverser = new ExtentTraverser(this.extent);
|
||||
NullExtent nullExtent = new NullExtent(world, BBC.WORLDEDIT_CANCEL_REASON_MANUAL);
|
||||
while (traverser != null) {
|
||||
ExtentTraverser next = traverser.next();
|
||||
@ -324,7 +324,7 @@ public class EditSession implements Extent {
|
||||
traverser = next;
|
||||
}
|
||||
bypassHistory = nullExtent;
|
||||
bypassNone = nullExtent;
|
||||
this.extent = nullExtent;
|
||||
bypassAll = nullExtent;
|
||||
dequeue();
|
||||
queue.clear();
|
||||
@ -452,7 +452,7 @@ public class EditSession implements Extent {
|
||||
* @return mask, may be null
|
||||
*/
|
||||
public Mask getMask() {
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(bypassNone).find(MaskingExtent.class);
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
|
||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||
}
|
||||
|
||||
@ -465,11 +465,11 @@ public class EditSession implements Extent {
|
||||
if (mask == null) {
|
||||
mask = Masks.alwaysTrue();
|
||||
}
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(bypassNone).find(MaskingExtent.class);
|
||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
|
||||
if (maskingExtent != null) {
|
||||
maskingExtent.get().setMask(mask);
|
||||
} else if (mask != Masks.alwaysTrue()) {
|
||||
bypassNone = new MaskingExtent(bypassNone, mask);
|
||||
this.extent = new MaskingExtent(this.extent, mask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,11 +494,11 @@ public class EditSession implements Extent {
|
||||
* @return the survival simulation extent
|
||||
*/
|
||||
public SurvivalModeExtent getSurvivalExtent() {
|
||||
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser(bypassNone).find(SurvivalModeExtent.class);
|
||||
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser(this.extent).find(SurvivalModeExtent.class);
|
||||
if (survivalExtent != null) {
|
||||
return survivalExtent.get();
|
||||
} else {
|
||||
return (SurvivalModeExtent) (bypassNone = new SurvivalModeExtent(bypassNone, getWorld()));
|
||||
return (SurvivalModeExtent) (this.extent = new SurvivalModeExtent(this.extent, getWorld()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,7 +522,7 @@ public class EditSession implements Extent {
|
||||
if (history == null) {
|
||||
return;
|
||||
}
|
||||
ExtentTraverser traverseHistory = new ExtentTraverser(bypassNone).find(HistoryExtent.class);
|
||||
ExtentTraverser traverseHistory = new ExtentTraverser(this.extent).find(HistoryExtent.class);
|
||||
if (disableHistory) {
|
||||
if (traverseHistory != null) {
|
||||
ExtentTraverser beforeHistory = traverseHistory.previous();
|
||||
@ -530,7 +530,7 @@ public class EditSession implements Extent {
|
||||
beforeHistory.setNext(afterHistory.get());
|
||||
}
|
||||
} else if (traverseHistory == null) {
|
||||
ExtentTraverser traverseBypass = new ExtentTraverser(bypassNone).find(bypassHistory);
|
||||
ExtentTraverser traverseBypass = new ExtentTraverser(this.extent).find(bypassHistory);
|
||||
if (traverseBypass != null) {
|
||||
ExtentTraverser beforeHistory = traverseBypass.previous();
|
||||
beforeHistory.setNext(history);
|
||||
@ -591,13 +591,13 @@ public class EditSession implements Extent {
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(final Vector2D position) {
|
||||
return this.bypassNone.getBiome(position);
|
||||
return this.extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final Vector2D position, final BaseBiome biome) {
|
||||
this.changes++;
|
||||
return this.bypassNone.setBiome(position, biome);
|
||||
return this.extent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -809,7 +809,7 @@ public class EditSession implements Extent {
|
||||
this.changes++;
|
||||
switch (stage) {
|
||||
case BEFORE_HISTORY:
|
||||
return this.bypassNone.setBlock(position, block);
|
||||
return this.extent.setBlock(position, block);
|
||||
case BEFORE_CHANGE:
|
||||
return this.bypassHistory.setBlock(position, block);
|
||||
case BEFORE_REORDER:
|
||||
@ -855,7 +855,7 @@ public class EditSession implements Extent {
|
||||
public boolean setBlock(final Vector position, final BaseBlock block) throws MaxChangedBlocksException {
|
||||
this.changes++;
|
||||
try {
|
||||
return this.bypassNone.setBlock(position, block);
|
||||
return this.extent.setBlock(position, block);
|
||||
} catch (final MaxChangedBlocksException e) {
|
||||
throw e;
|
||||
} catch (final WorldEditException e) {
|
||||
@ -924,7 +924,7 @@ public class EditSession implements Extent {
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(final com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
|
||||
Entity result = this.bypassNone.createEntity(location, entity);
|
||||
Entity result = this.extent.createEntity(location, entity);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1005,12 +1005,12 @@ public class EditSession implements Extent {
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(final Region region) {
|
||||
return this.bypassNone.getEntities(region);
|
||||
return this.extent.getEntities(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
return this.bypassNone.getEntities();
|
||||
return this.extent.getEntities();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1234,7 +1234,7 @@ public class EditSession implements Extent {
|
||||
Iterator<BlockVector> iter = region.iterator();
|
||||
try {
|
||||
while (iter.hasNext()) {
|
||||
this.bypassNone.setBlock(iter.next(), block);
|
||||
this.extent.setBlock(iter.next(), block);
|
||||
}
|
||||
} catch (final MaxChangedBlocksException e) {
|
||||
throw e;
|
||||
|
Loading…
Reference in New Issue
Block a user