use of org.cubeengine.libcube.service.config.ConfigWorld in project modules-extra by CubeEngine.
the class VigilConfig method getDisabledReports.
public List<Class<? extends Report>> getDisabledReports(World world) {
List<Class<? extends Report>> reports = disabledReportsMap.get(world.getUniqueId());
if (reports == null) {
reports = new ArrayList<>();
disabledReportsMap.put(world.getUniqueId(), reports);
ConfigWorld cWorld = new ConfigWorld(world);
for (String name : disabledReports.getOrDefault(cWorld, Collections.emptyList())) {
if ("*".equals(name)) {
name = "Report";
}
Report.getReport(name).ifPresent(reports::add);
}
if (!reports.isEmpty()) {
List<String> list = new ArrayList<>();
disabledReports.put(cWorld, list);
// Save long names
reports.forEach(c -> list.add(c.getClass().getName()));
this.save();
}
}
return reports;
}
use of org.cubeengine.libcube.service.config.ConfigWorld in project modules-extra by CubeEngine.
the class VigilAdminCommands method setReportActive.
@Command(desc = "enables or disables reports in a world")
public // TODO completer
void setReportActive(// TODO completer
CommandSource ctx, // TODO completer
World world, // TODO completer
String name, // TODO completer
@Default boolean enable) {
Class<? extends Report> report = "*".equals(name) ? Report.class : Report.getReport(name).orElse(null);
if (report == null) {
// TODO suggest?
i18n.send(ctx, NEGATIVE, "Unknown Report: {name}", name);
return;
}
List<String> list = module.getConfig().disabledReports.computeIfAbsent(new ConfigWorld(world), w -> new ArrayList<>());
if (enable) {
i18n.send(ctx, POSITIVE, "Report {name} is now enabled in {world}", name, world);
list.remove(name);
} else {
i18n.send(ctx, POSITIVE, "Report {name} is now disabled in {world}", name, world);
list.add(name);
}
module.getConfig().markDirty(world);
module.getConfig().save();
}
Aggregations