Fix VS brushes which require multiple clicks

This commit is contained in:
Jesse Boyd 2016-09-03 16:34:25 +10:00
parent f31c4fda82
commit 6818ff28ba
3 changed files with 22 additions and 25 deletions

2
.gitignore vendored
View File

@ -22,4 +22,4 @@ gradle.log
/bukkit19/build
/bukkit18/build
build
mvn/com/boydti/fawe-api/unknown/fawe-api-unknown.jar
/mvn

View File

@ -16,7 +16,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bukkit.BlockChangeDelegate;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@ -60,8 +59,8 @@ import org.bukkit.util.Vector;
*/
public class AsyncWorld implements World {
private final World parent;
private final FaweQueue queue;
private World parent;
private FaweQueue queue;
private BukkitImplAdapter adapter;
/**
@ -109,6 +108,12 @@ public class AsyncWorld implements World {
return new AsyncWorld(world, false);
}
public void changeWorld(World world, FaweQueue queue) {
flush();
this.parent = world;
this.queue = queue;
}
public World getParent() {
return parent;
}
@ -117,8 +122,6 @@ public class AsyncWorld implements World {
return queue;
}
private static AtomicBoolean loading = new AtomicBoolean(false);
/**
* Create a world async (untested)
* - Only optimized for 1.10
@ -140,7 +143,9 @@ public class AsyncWorld implements World {
}
public void flush() {
queue.flush();
if (queue != null) {
queue.flush();
}
}
@Override

View File

@ -75,14 +75,17 @@ public class Sniper {
}
// Added
private AsyncWorld tmpWorld;
private AsyncWorld permanentWorld;
private MaskedFaweQueue maskQueue;
private ChangeSetFaweQueue changeQueue;
private FaweQueue baseQueue;
// Added
public AsyncWorld getWorld() {
if (this.tmpWorld == null) {
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())) {
@ -96,9 +99,9 @@ public class Sniper {
changeSet = LoggingChangeSet.wrap(fp, changeSet);
}
this.changeQueue = new ChangeSetFaweQueue(changeSet, maskQueue);
tmpWorld = new AsyncWorld(player.getWorld(), changeQueue);
permanentWorld.changeWorld(player.getWorld(), changeQueue);
}
return tmpWorld;
return permanentWorld;
}
public Player getPlayer() {
@ -123,7 +126,7 @@ public class Sniper {
if (fp.getMeta("fawe_action") != null) {
return false;
}
tmpWorld = null;
maskQueue = null;
if (clickedBlock != null) {
clickedBlock = getWorld().getBlockAt(clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
}
@ -155,7 +158,6 @@ public class Sniper {
getPlayer().sendMessage("No Brush selected.");
return true;
}
if (!getPlayer().hasPermission(sniperTool.getCurrentBrush().getPermissionNode())) {
getPlayer().sendMessage("You are not allowed to use this brush. You're missing the permission node '" + sniperTool.getCurrentBrush().getPermissionNode() + "'");
return true;
@ -293,17 +295,7 @@ public class Sniper {
}
}
// if (sniperTool.getCurrentBrush() instanceof PerformBrush) {
// PerformBrush performerBrush = (PerformBrush) sniperTool.getCurrentBrush();
// performerBrush.initP(snipeData);
// }
//
// boolean result = sniperTool.getCurrentBrush().perform(snipeAction, snipeData, targetBlock, lastBlock);
// if (result) {
// MetricsManager.increaseBrushUsage(sniperTool.getCurrentBrush().getName());
// }
// return result;
final IBrush brush = sniperTool.getCurrentBrush();
final IBrush brush = sniperTool.getCurrentBrush();
if (sniperTool.getCurrentBrush() instanceof PerformBrush) {
PerformBrush performerBrush = (PerformBrush) sniperTool.getCurrentBrush();
performerBrush.initP(snipeData);
@ -401,7 +393,7 @@ public class Sniper {
changeSet = FaweChangeSet.getDefaultChangeSet(worldEditWorld, fp.getUUID());
changeQueue.setChangeSet(changeSet);
// NEW QUEUE?
tmpWorld = null;
maskQueue = null;
baseQueue = null;
changeQueue = null;
}