use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class Receiver method sendReport.
private void sendReport(List<Action> actions, Text trans) {
Action firstAction = actions.get(0);
Action lastAction = actions.get(actions.size() - 1);
Text date = getDatePrefix(firstAction, lastAction);
Text loc = getLocation(firstAction, lastAction);
if (!date.isEmpty() && !loc.isEmpty()) {
lines.add(Text.of(date, WHITE, " ", i18n.translate(cmdSource, NONE, "at"), " ", loc, Text.NEW_LINE, " ", trans));
} else {
Text prefix = Text.EMPTY;
if (!date.isEmpty()) {
prefix = Text.of(date, RED_SEPARATOR);
} else if (!loc.isEmpty()) {
prefix = Text.of(loc, RED_SEPARATOR);
}
lines.add(Text.of(prefix, trans));
}
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class DestructReport method observe.
@Override
public Action observe(DestructEntityEvent event) {
Action action = newReport();
action.addData(ENTITY, Observe.entity(event.getTargetEntity().createSnapshot()));
action.addData(CAUSE, Observe.causes(event.getCause()));
action.addData(LOCATION, Observe.location(event.getTargetEntity().getLocation()));
return action;
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class DestructReport 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).get(0);
Text cause = Recall.cause(action);
EntitySnapshot entity = Recall.entity(action);
if (entity.getType() == EntityTypes.ITEM) {
Text name = ReportUtil.name(entity);
ItemStack i = entity.get(Keys.REPRESENTED_ITEM).map(ItemStackSnapshot::createStack).orElse(null);
Text item = Text.of("?");
if (i != null) {
item = Text.of(i.getTranslation().get(receiver.getLocale())).toBuilder().onHover(showText(Text.of(i.getType().getId()))).build();
}
int count = 0;
for (Action a : actions) {
count += Recall.entity(a).get(Keys.REPRESENTED_ITEM).map(ItemStackSnapshot::getQuantity).orElse(0);
}
if (count == 0) {
count = actions.size();
}
receiver.sendReport(this, actions, count, "{txt} destroyed {txt}", "{txt} destroyed {txt} x{}", cause, Text.of(name, ": ", item), count);
} else if (Living.class.isAssignableFrom(entity.getType().getEntityClass())) {
receiver.sendReport(this, actions, actions.size(), "{txt} killed {txt}", "{txt} killed {txt} x{}", cause, ReportUtil.name(entity), actions.size());
} else if (ExperienceOrb.class.isAssignableFrom(entity.getType().getEntityClass())) {
Integer exp = 0;
for (Action a : actions) {
EntitySnapshot orb = Recall.entity(a);
exp += orb.get(Keys.CONTAINED_EXPERIENCE).orElse(0);
}
receiver.sendReport(this, actions, actions.size(), "{txt} picked up an ExpOrb worth {2:amount} points", "{txt} picked up {amount} ExpOrbs worth {amount} points", cause, actions.size(), exp);
} else {
receiver.sendReport(this, actions, actions.size(), "{txt} destroyed {txt}", "{txt} destroyed {txt} x{}", cause, ReportUtil.name(entity), actions.size());
}
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class ChatReport method showReport.
@Override
public void showReport(List<Action> actions, Receiver receiver) {
Action action = actions.get(0);
receiver.sendReport(this, actions, actions.size(), "{txt} wrote {input}", "{txt} spammed {input} x{}", Recall.cause(action), action.getData(CHAT), actions.size());
}
use of org.cubeengine.module.vigil.report.Action in project modules-extra by CubeEngine.
the class CommandReport method showReport.
@Override
public void showReport(List<Action> actions, Receiver receiver) {
Action action = actions.get(0);
receiver.sendReport(this, actions, actions.size(), "{txt} used {input}", "{txt} used {input} x{}", Recall.cause(action), action.getData(COMMAND), actions.size());
}
Aggregations