forked from LogBlock/LogBlock
Advanced merging for queueBlockReplace.
This commit is contained in:
@@ -74,14 +74,22 @@ public class Consumer extends TimerTask implements Runnable
|
||||
* @param after Blockstate of the block after actually being placed.
|
||||
*/
|
||||
public void queueBlockReplace(String playerName, BlockState before, BlockState after) {
|
||||
if (before.getRawData() == 0) {
|
||||
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) {
|
||||
if (dataBefore == 0) {
|
||||
queueBlock(playerName, loc, typeBefore, typeAfter, dataAfter);
|
||||
} else {
|
||||
queueBlockBreak(playerName, loc, typeBefore, dataBefore);
|
||||
queueBlockPlace(playerName, loc, typeAfter, dataAfter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param before Blockstate of the block before actually being destroyed.
|
||||
|
@@ -19,6 +19,8 @@ public class LBBlockListener extends BlockListener
|
||||
consumer = logblock.getConsumer();
|
||||
}
|
||||
|
||||
//TODO Flow listener
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
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();
|
||||
if (before.getTypeId() == 0)
|
||||
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
|
||||
consumer.queueBlockReplace(event.getPlayer().getName(), before, after);
|
||||
}
|
||||
|
Reference in New Issue
Block a user