use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class BlockReport method observe.
@Override
protected Action observe(ChangeBlockEvent event) {
Action action = newReport();
action.addData(CAUSE, Observe.causes(event.getCause()));
return action;
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class BlockReport method report.
protected void report(ChangeBlockEvent event) {
UUID multi = UUID.randomUUID();
for (Map.Entry<Vector3i, List<Transaction<BlockSnapshot>>> entry : event.getTransactions().stream().collect(Collectors.groupingBy(t -> t.getOriginal().getPosition())).entrySet()) {
// Only get one transaction for one block
Transaction<BlockSnapshot> trans = entry.getValue().get(0);
if (!isActive(trans.getOriginal().getLocation().get().getExtent())) {
continue;
}
if (isRedstoneChange(trans.getOriginal().getState(), trans.getFinal().getState())) {
continue;
}
Action action = observe(event);
action.addData(BLOCK_CHANGES, Observe.transactions(trans));
action.addData(LOCATION, Observe.location(trans.getOriginal().getLocation().get()));
if (event.getTransactions().size() > 1) {
action.addData(MULTIACTION, multi.toString());
}
report(action);
}
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class BreakBlockReport method showReport.
@Override
public void showReport(List<Action> actions, Receiver receiver) {
Action action = actions.get(0);
Optional<BlockSnapshot> orig = action.getCached(BLOCKS_ORIG, Recall::origSnapshot);
if (!orig.isPresent()) {
throw new IllegalStateException();
}
showReport(actions, receiver, action, orig.get());
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class ExplosionReport method showReport.
@Override
public void showReport(List<Action> actions, Receiver receiver) {
// TODO test
Action action = actions.get(0);
BlockSnapshot snap = action.getCached(BLOCKS_ORIG, Recall::origSnapshot).get();
receiver.sendReport(this, actions, actions.size(), "{txt} made boom {txt}", "{txt} made boom {txt} x{}", Recall.cause(action), name(snap, receiver), actions.size());
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class ModifyBlockReport method showReport.
@Override
public void showReport(List<Action> actions, Receiver receiver) {
Action action = actions.get(0);
Optional<BlockSnapshot> orig = action.getCached(BLOCKS_ORIG, Recall::origSnapshot);
Optional<BlockSnapshot> repl = action.getCached(BLOCKS_REPL, Recall::replSnapshot);
Text cause = Recall.cause(action);
if (!repl.isPresent() || !orig.isPresent()) {
throw new IllegalStateException();
}
Optional<MutableBoundedValue<Integer>> growth = repl.get().getValue(Keys.GROWTH_STAGE);
if (growth.isPresent()) {
if (growth.get().get().equals(growth.get().getMaxValue())) {
receiver.sendReport(this, actions, actions.size(), "{txt} let {txt} grow to maturity", "{txt} let {txt} grow to maturity x{}", cause, name(orig.get(), receiver), actions.size());
return;
}
receiver.sendReport(this, actions, actions.size(), "{txt} let {txt} grow", "{txt} let {txt} grow x{}", cause, name(orig.get(), receiver), actions.size());
return;
}
// TODO other modifyables
receiver.sendReport(this, actions, actions.size(), "{txt} modified {txt}", "{txt} modified {txt} x{}", cause, name(orig.get(), receiver), actions.size());
}
Aggregations