mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-25 03:55:35 +01:00
Fixes #309
This commit is contained in:
parent
f9ee91f192
commit
6d52e47d3f
@ -83,26 +83,34 @@ public class Sniper {
|
||||
|
||||
// Added
|
||||
public AsyncWorld getWorld() {
|
||||
if (permanentWorld == null) {
|
||||
permanentWorld = new AsyncWorld(null, null);
|
||||
}
|
||||
if (this.maskQueue == null) {
|
||||
Player player = getPlayer();
|
||||
FawePlayer<Player> fp = FawePlayer.wrap(player);
|
||||
if (this.baseQueue == null || !StringMan.isEqual(baseQueue.getWorldName(), player.getWorld().getName())) {
|
||||
this.baseQueue = FaweAPI.createQueue(fp.getLocation().world, false);
|
||||
synchronized (this) {
|
||||
if (permanentWorld == null) {
|
||||
permanentWorld = new AsyncWorld(null, null);
|
||||
}
|
||||
RegionWrapper[] mask = WEManager.IMP.getMask(fp);
|
||||
this.maskQueue = new MaskedFaweQueue(baseQueue, mask);
|
||||
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
||||
FaweChangeSet changeSet = FaweChangeSet.getDefaultChangeSet(worldEditWorld, fp.getUUID());
|
||||
if (Fawe.imp().getBlocksHubApi() != null) {
|
||||
changeSet = LoggingChangeSet.wrap(fp, changeSet);
|
||||
if (this.maskQueue == null) {
|
||||
Player player = getPlayer();
|
||||
FawePlayer<Player> fp = FawePlayer.wrap(player);
|
||||
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);
|
||||
this.maskQueue = new MaskedFaweQueue(baseQueue, mask);
|
||||
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
||||
FaweChangeSet changeSet = FaweChangeSet.getDefaultChangeSet(worldEditWorld, fp.getUUID());
|
||||
if (Fawe.imp().getBlocksHubApi() != null) {
|
||||
changeSet = LoggingChangeSet.wrap(fp, changeSet);
|
||||
}
|
||||
this.changeQueue = new ChangeSetFaweQueue(changeSet, maskQueue);
|
||||
permanentWorld.changeWorld(player.getWorld(), changeQueue);
|
||||
}
|
||||
this.changeQueue = new ChangeSetFaweQueue(changeSet, maskQueue);
|
||||
permanentWorld.changeWorld(player.getWorld(), changeQueue);
|
||||
return permanentWorld;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetMask() {
|
||||
synchronized (this) {
|
||||
maskQueue = null;
|
||||
}
|
||||
return permanentWorld;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
@ -122,7 +130,7 @@ public class Sniper {
|
||||
try {
|
||||
Player player = getPlayer();
|
||||
FawePlayer<Player> fp = FawePlayer.wrap(player);
|
||||
maskQueue = null;
|
||||
resetMask();
|
||||
if (clickedBlock != null) {
|
||||
clickedBlock = getWorld().getBlockAt(clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
|
||||
}
|
||||
@ -296,7 +304,7 @@ public class Sniper {
|
||||
performerBrush.initP(snipeData);
|
||||
}
|
||||
final FawePlayer<Player> fp = FawePlayer.wrap(getPlayer());
|
||||
fp.runAction(new RunnableVal<Boolean>() {
|
||||
fp.runAsyncIfFree(new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean value) {
|
||||
boolean result = brush.perform(snipeAction, snipeData, targetBlock, lastBlock);
|
||||
@ -305,7 +313,7 @@ public class Sniper {
|
||||
}
|
||||
world.commit();
|
||||
}
|
||||
}, true, true);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -375,18 +383,20 @@ public class Sniper {
|
||||
}
|
||||
|
||||
public void storeUndo(Undo undo) {
|
||||
if (changeQueue != null) {
|
||||
FaweChangeSet changeSet = changeQueue.getChangeSet();
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(getPlayer());
|
||||
LocalSession session = fp.getSession();
|
||||
session.remember(changeSet.toEditSession(fp));
|
||||
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
||||
changeSet = FaweChangeSet.getDefaultChangeSet(worldEditWorld, fp.getUUID());
|
||||
changeQueue.setChangeSet(changeSet);
|
||||
// NEW QUEUE?
|
||||
maskQueue = null;
|
||||
baseQueue = null;
|
||||
changeQueue = null;
|
||||
synchronized (this) {
|
||||
if (changeQueue != null) {
|
||||
FaweChangeSet changeSet = changeQueue.getChangeSet();
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(getPlayer());
|
||||
LocalSession session = fp.getSession();
|
||||
session.remember(changeSet.toEditSession(fp));
|
||||
com.sk89q.worldedit.world.World worldEditWorld = fp.getWorld();
|
||||
changeSet = FaweChangeSet.getDefaultChangeSet(worldEditWorld, fp.getUUID());
|
||||
changeQueue.setChangeSet(changeSet);
|
||||
// NEW QUEUE?
|
||||
maskQueue = null;
|
||||
baseQueue = null;
|
||||
changeQueue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user