use of org.spongepowered.api.data.Transaction in project TriggerReactor by wysohn.
the class LocationBasedTriggerManager method onSignBreak.
@Listener(order = Order.LATE)
public void onSignBreak(ChangeBlockEvent.Break e) {
if (e.isCancelled())
return;
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
BlockSnapshot snapshot = transaction.getOriginal();
Location<World> loc = snapshot.getLocation().orElse(null);
BlockState state = snapshot.getState();
BlockState above = loc.getExtent().getBlock(0, 1, 0);
if (above.getType() != BlockTypes.STANDING_SIGN && above.getType() != BlockTypes.WALL_SIGN)
return;
ChangeBlockEvent.Break bbe = new ChangeBlockEvent.Break() {
private boolean cancelled = false;
@SuppressWarnings("serial")
@Override
public List<Transaction<BlockSnapshot>> getTransactions() {
return new ArrayList<Transaction<BlockSnapshot>>() {
{
add(transaction);
}
};
}
@Override
public Cause getCause() {
return e.getCause();
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
};
onBreak(bbe);
e.setCancelled(bbe.isCancelled());
}
}
Aggregations