use of org.cubeengine.butler.parametric.Command 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();
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class ShoutCommand method list.
@Alias(value = { "announcements" })
@Command(alias = "announcements", desc = "List all announcements")
public void list(CommandSource context) {
Collection<Announcement> list = this.module.getManager().getAllAnnouncements();
if (list.isEmpty()) {
i18n.send(context, NEGATIVE, "There are no announcements loaded!");
return;
}
i18n.send(context, POSITIVE, "Here is the list of announcements:");
for (Announcement announcement : list) {
context.sendMessage(Text.of(" - ", announcement.getName()));
}
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class EditModeCommand method copy.
@Restricted(Player.class)
@Command(desc = "Copies the settings from the previous sign")
public void copy(Player context) {
ImmutableMarketSignData data = manager.getPreviousData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No previous market sign");
return;
}
if (data.getOwner().equals(IMarketSignData.ADMIN_SIGN)) {
if (!context.hasPermission(module.perms().EDIT_ADMIN.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_ADMIN);
}
} else {
if (!context.hasPermission(module.perms().EDIT_USE.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_USE);
}
}
MarketSignData copy = data.asMutable();
if (!copy.isAdminOwner()) {
copy.setStock(0);
}
Location<World> loc = manager.updateData(copy, context);
manager.executeShowInfo(copy, context, loc);
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class EditModeCommand method setstock.
@Command(desc = "Sets the signs stock")
public void setstock(Player context, Integer amount) {
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
if (data.getStock() == null) {
i18n.send(context, NEGATIVE, "This sign has no stock! Use \"stock\" first to enable it!");
return;
}
data.setStock(amount);
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class EditModeCommand method player.
@Command(desc = "Changes the sign to an player-sign")
public void player(Player context) {
if (!context.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_PLAYER_SELF);
}
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
if (data.isAdminOwner()) {
data.setSize(6);
}
data.setOwner(context.getUniqueId());
data.setStock(0);
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
Aggregations