use of ivorius.mcopts.commands.parameters.Parameters in project RecurrentComplex by Ivorforce.
the class CommandSearchStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
List<ToDoubleFunction<String>> ranks = new ArrayList<>();
consider(ranks, parameters.get(0), Parameter::varargsList, (s, t) -> StructureSearch.searchRank(t, StructureSearch.keywords(StructureRegistry.INSTANCE.id(s), s)));
consider(ranks, parameters.get("containing"), e -> RCP.expression(e, new BlockExpression(RecurrentComplex.specialRegistry)), StructureSearch::containedBlocks);
consider(ranks, parameters.get("biome"), MCP::biome, StructureSearch::biome);
consider(ranks, parameters.get("dimension"), MCP.dimension(server, sender), StructureSearch::dimension);
consider(ranks, parameters.get("maze"), p -> p, StructureSearch::maze);
consider(ranks, parameters.get("list"), p -> p, StructureSearch::list);
consider(ranks, parameters.get("author"), p -> p, StructureSearch::author);
boolean all = parameters.has("all");
if (ranks.stream().noneMatch(Objects::nonNull))
throw new WrongUsageException(getUsage(sender));
postResultMessage("Results: ", sender, RCTextStyle::structure, search(all ? StructureRegistry.INSTANCE.ids() : StructureRegistry.INSTANCE.activeIDs(), name -> ranks.stream().filter(Objects::nonNull).mapToDouble(f -> f.applyAsDouble(name)).reduce(1, (a, b) -> a * b)));
}
use of ivorius.mcopts.commands.parameters.Parameters in project RecurrentComplex by Ivorforce.
the class CommandAnd method execute.
@Override
public void execute(MockWorld world, ICommandSender sender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
for (String param : parameters.get(0).varargsList().require()) {
String[] commandArgs = param.split(" ");
CommandVirtual command = Parameter.makeUp("command", 0, commandArgs[0]).to(RCP::virtualCommand, server).require();
command.execute(world, sender, Arrays.stream(commandArgs).skip(1).toArray(String[]::new));
}
}
use of ivorius.mcopts.commands.parameters.Parameters in project RecurrentComplex by Ivorforce.
the class CommandEval method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
DependencyExpression matcher = parameters.get(0).rest(NaP::join).to(RCP::expression, new DependencyExpression()).require();
boolean result = matcher.test(RecurrentComplex.saver);
commandSender.sendMessage(RecurrentComplex.translations.get(result ? "commands.rceval.result.true" : "commands.rceval.result.false"));
}
Aggregations