Search in sources :

Example 16 with Action

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));
    }
}
Also used : Action(org.cubeengine.module.vigil.report.Action) TextActions.showText(org.spongepowered.api.text.action.TextActions.showText) Text(org.spongepowered.api.text.Text)

Example 17 with Action

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;
}
Also used : Action(org.cubeengine.module.vigil.report.Action)

Example 18 with 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());
    }
}
Also used : Action(org.cubeengine.module.vigil.report.Action) EntitySnapshot(org.spongepowered.api.entity.EntitySnapshot) Living(org.spongepowered.api.entity.living.Living) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) TextActions.showText(org.spongepowered.api.text.action.TextActions.showText) Text(org.spongepowered.api.text.Text) ItemStack(org.spongepowered.api.item.inventory.ItemStack)

Example 19 with Action

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());
}
Also used : Action(org.cubeengine.module.vigil.report.Action)

Example 20 with Action

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());
}
Also used : Action(org.cubeengine.module.vigil.report.Action)

Aggregations

Action (org.cubeengine.module.vigil.report.Action)24 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)5 Text (org.spongepowered.api.text.Text)4 ArrayList (java.util.ArrayList)3 Recall (org.cubeengine.module.vigil.report.Recall)3 Map (java.util.Map)2 ItemStack (org.spongepowered.api.item.inventory.ItemStack)2 SlotTransaction (org.spongepowered.api.item.inventory.transaction.SlotTransaction)2 TextActions.showText (org.spongepowered.api.text.action.TextActions.showText)2 Vector3i (com.flowpowered.math.vector.Vector3i)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 UUID (java.util.UUID)1 Document (org.bson.Document)1 Report (org.cubeengine.module.vigil.report.Report)1 ReportActions (org.cubeengine.module.vigil.report.ReportActions)1 Transaction (org.spongepowered.api.data.Transaction)1 MutableBoundedValue (org.spongepowered.api.data.value.mutable.MutableBoundedValue)1 EntitySnapshot (org.spongepowered.api.entity.EntitySnapshot)1 Living (org.spongepowered.api.entity.living.Living)1