Advanced merging for queueBlockReplace.

This commit is contained in:
Robin Kupper
2011-04-26 23:34:25 +02:00
parent a964d69e4a
commit 36050383ec
2 changed files with 14 additions and 6 deletions

View File

@@ -74,13 +74,21 @@ public class Consumer extends TimerTask implements Runnable
* @param after Blockstate of the block after actually being placed. * @param after Blockstate of the block after actually being placed.
*/ */
public void queueBlockReplace(String playerName, BlockState before, BlockState after) { public void queueBlockReplace(String playerName, BlockState before, BlockState after) {
queueBlockBreak(playerName, before); if (before.getRawData() == 0) {
queueBlockPlace(playerName, after); queueBlock(playerName, new Location(before.getWorld(), before.getX(), before.getY(), before.getZ()), before.getTypeId(), after.getTypeId(), after.getRawData());
} else {
queueBlockBreak(playerName, before);
queueBlockPlace(playerName, after);
}
} }
public void queueBlockReplace(String playerName, Location loc, int typeBefore, byte dataBefore, int typeAfter, byte dataAfter) { public void queueBlockReplace(String playerName, Location loc, int typeBefore, byte dataBefore, int typeAfter, byte dataAfter) {
queueBlockBreak(playerName, loc, typeBefore, dataBefore); if (dataBefore == 0) {
queueBlockPlace(playerName, loc, typeAfter, dataAfter); queueBlock(playerName, loc, typeBefore, typeAfter, dataAfter);
} else {
queueBlockBreak(playerName, loc, typeBefore, dataBefore);
queueBlockPlace(playerName, loc, typeAfter, dataAfter);
}
} }
/** /**

View File

@@ -19,6 +19,8 @@ public class LBBlockListener extends BlockListener
consumer = logblock.getConsumer(); consumer = logblock.getConsumer();
} }
//TODO Flow listener
@Override @Override
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if (!event.isCancelled() && !(config.logSignTexts && (event.getBlock().getType() == Material.WALL_SIGN || event.getBlock().getType() == Material.SIGN_POST))) { if (!event.isCancelled() && !(config.logSignTexts && (event.getBlock().getType() == Material.WALL_SIGN || event.getBlock().getType() == Material.SIGN_POST))) {
@@ -26,8 +28,6 @@ public class LBBlockListener extends BlockListener
final BlockState after = event.getBlockPlaced().getState(); final BlockState after = event.getBlockPlaced().getState();
if (before.getTypeId() == 0) if (before.getTypeId() == 0)
consumer.queueBlockPlace(event.getPlayer().getName(), after); consumer.queueBlockPlace(event.getPlayer().getName(), after);
else if (before.getRawData() == 0)
consumer.queueBlock(event.getPlayer().getName(), event.getBlock().getLocation(), before.getTypeId(), after.getTypeId(), after.getRawData());
else else
consumer.queueBlockReplace(event.getPlayer().getName(), before, after); consumer.queueBlockReplace(event.getPlayer().getName(), before, after);
} }