use of org.cubeengine.module.log.storage.ShowParameter in project modules-extra by CubeEngine.
the class LookupCommands method lookup.
@Command(desc = "Queries a lookup in the database\n Show availiable parameters with /lookup params")
public // TODO param for filter / chat / command / signtexts
void lookup(CommandContext context, @Label("params") @Optional String action, @Named({ "action", "a" }) @Complete(ActionTypeCompleter.class) String actions, @Named({ "radius", "r" }) String radius, @Named({ "player", "p" }) @Complete(PlayerListCompleter.class) String players, @Named({ "block", "b" }) @Complete(MaterialListCompleter.class) String blocks, @Named({ "entity", "e" }) String entities, @Named({ "since", "time", "t" }) String since, @Named({ "before" }) String before, @Named({ "world", "w", "in" }) @Complete(WorldCompleter.class) String world, @Named({ "limit", "pagelimit" }) Integer limit, @Named({ "page" }) Integer page, @Named("params") @Complete(ActionTypeCompleter.class) String params, @Flag(longName = "coordinates", name = "coords") boolean showCoord, @Flag(longName = "detailed", name = "det") boolean detailed, @Flag(longName = "nodate", name = "nd") boolean nodate, @Flag(longName = "descending", name = "desc") boolean descending) {
if ("params".equalsIgnoreCase(action) || params != null) {
this.params(context.getSource(), params);
return;
}
if (context.getSource() instanceof User) {
if (!context.hasNamed()) {
try {
context.sendTranslated(NEGATIVE, "You have to provide parameters");
// ((Dispatcher)context.getCommand()).getCommand("?").execute(context.getInvocation());
// TODO show all selected params of last lookup
} catch (Exception e) {
throw new IllegalStateException(e);
}
return;
}
User user = (User) context.getSource();
LogAttachment attachment = user.attachOrGet(LogAttachment.class, this.module);
// gets last OR new Showparameter
ShowParameter show = attachment.getLastShowParameter();
Lookup lookup = attachment.getLastLookup();
if (// /lookup show / page <page>
!this.fillShowOptions(attachment, lookup, show, context.getSource(), showCoord, nodate, detailed, descending, limit, page, action)) {
return;
}
lookup = attachment.createNewCommandLookup();
QueryParameter parameters = lookup.getQueryParameter();
if (!(readActions(parameters, actions, user) && readRadius(parameters, radius, user) && readUser(parameters, players, user) && readBlocks(parameters, blocks, user) && readEntities(parameters, entities, user) && readWorld(parameters, world, radius != null, user) && readTimeSince(parameters, since, user) && readTimeBefore(parameters, before, user))) {
return;
}
attachment.queueShowParameter(show);
this.module.getLogManager().fillLookupAndShow(lookup, user);
} else {
// TODO implement me
System.out.println("Not implemented yet");
}
}
Aggregations