use of com.karanumcoding.adamantineshield.db.queue.BlockQueueEntry in project AdamantineShield by Karanum.
the class EntityBlockChangeListener method onBlockPlace.
// @Listener(order = Order.POST)
// public void onTileEntityBlockPlace(ChangeBlockEvent.Place e, @Root TileEntity te) {
// System.out.println("PLACE EVENT:");
// long time = new Date().getTime();
// for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
// BlockType orig = transaction.getOriginal().getState().getType();
// BlockType result = transaction.getFinal().getState().getType();
// if (orig != BlockTypes.AIR && !technicalBlocks.contains(orig)) {
// System.out.println(transaction);
// //db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, te.getType().getName(), time));
// }
// if (!technicalBlocks.contains(result))
// System.out.println(transaction);
// //db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.MOB_PLACE, te.getType().getName(), time));
// }
// }
//
// @Listener(order = Order.POST)
// public void onTileEntityBlockBreak(ChangeBlockEvent.Break e, @Root TileEntity te) {
// System.out.println("BREAK EVENT:");
// long time = new Date().getTime();
// for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
// if (technicalBlocks.contains(transaction.getOriginal().getState().getType()))
// return;
// System.out.println(transaction);
// //db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_PLACE, te.getType().getName(), time));
// }
// }
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Entity ent) {
if (ent instanceof Player || ent instanceof Agent)
return;
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
String name = ent.getType().getName();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, name, time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.MOB_PLACE, name, time));
}
}
use of com.karanumcoding.adamantineshield.db.queue.BlockQueueEntry in project AdamantineShield by Karanum.
the class LiquidFlowListener method onLiquidFlow.
@Listener(order = Order.POST)
public void onLiquidFlow(ChangeBlockEvent.Pre e) {
if (e.getLocations().isEmpty())
return;
Location<World> loc = e.getLocations().get(0);
BlockSnapshot snapshot = loc.getExtent().createSnapshot(loc.getBlockPosition());
Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
String name = "Water";
BlockType type = snapshot.getState().getType();
if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA)
name = "Lava";
db.addToQueue(new BlockQueueEntry(snapshot, ActionType.FLOW, name, new Date().getTime()));
}
}
use of com.karanumcoding.adamantineshield.db.queue.BlockQueueEntry in project AdamantineShield by Karanum.
the class PlantGrowthListener method onGrowth.
@Listener(order = Order.POST)
public void onGrowth(ChangeBlockEvent.Place e, @Root LocatableBlock b) {
BlockType type = b.getBlockState().getType();
if (!acceptedBlocks.contains(type))
return;
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.MOB_PLACE, "block_growth", time));
}
}
use of com.karanumcoding.adamantineshield.db.queue.BlockQueueEntry in project AdamantineShield by Karanum.
the class PlayerBlockChangeListener method onBlockPlace.
@Listener(order = Order.POST)
public void onBlockPlace(ChangeBlockEvent.Place e, @Root Player p) {
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
UUID id = p.getUniqueId();
if (transaction.getOriginal().getState().getType() != BlockTypes.AIR) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.DESTROY, id.toString(), time));
}
db.addToQueue(new BlockQueueEntry(transaction.getFinal(), ActionType.PLACE, id.toString(), time));
}
}
use of com.karanumcoding.adamantineshield.db.queue.BlockQueueEntry in project AdamantineShield by Karanum.
the class EntityBlockChangeListener method onBlockBreak.
@Listener
public void onBlockBreak(ChangeBlockEvent.Break e, @Root Explosion expl) {
if (!expl.getSourceExplosive().isPresent())
return;
String source = expl.getSourceExplosive().get().getType().getName();
long time = new Date().getTime();
for (Transaction<BlockSnapshot> transaction : e.getTransactions()) {
db.addToQueue(new BlockQueueEntry(transaction.getOriginal(), ActionType.MOB_DESTROY, source, time));
}
}
Aggregations