use of gg.projecteden.nexus.framework.commands.models.annotations.Confirm in project Nexus by ProjectEdenGG.
the class BoostsCommand method start.
@Confirm
@Permission(Group.SENIOR_STAFF)
@Path("start <type> <multiplier> <duration>")
void start(Boostable type, double multiplier, int duration) {
if (config.hasBoost(type))
cancel(type, true);
Booster booster = service.get(Dev.KODA.getUuid());
Boost boost = booster.add(type, multiplier, duration);
boost.activate();
service.save(booster);
send(PREFIX + "Started a server " + boost.getMultiplierFormatted() + " " + camelCase(type) + " boost for " + Timespan.ofSeconds(boost.getDuration()).format(FormatType.LONG));
}
use of gg.projecteden.nexus.framework.commands.models.annotations.Confirm in project Nexus by ProjectEdenGG.
the class BoostsCommand method cancel.
@Confirm
@Permission(Group.STAFF)
@Path("cancel <type> [--refund]")
void cancel(Boostable type, @Switch boolean refund) {
if (!config.hasBoost(type))
error("There is no active " + camelCase(type) + " boost");
Boost boost = config.getBoost(type);
boost.cancel();
if (refund)
boost.getBooster().add(type, boost.getMultiplier(), boost.getDurationLeft());
service.save(boost.getBooster());
send(PREFIX + "Cancelled " + boost.getNickname() + "'s " + boost.getMultiplierFormatted() + " " + camelCase(type) + " boost" + (refund ? " and refunded the time left" : ""));
}
use of gg.projecteden.nexus.framework.commands.models.annotations.Confirm in project Nexus by ProjectEdenGG.
the class DatabaseCommand method copy.
@Async
@Confirm
@SneakyThrows
@Path("copy <service> <from> <to>")
<T extends DatabaseObject> void copy(MongoService<T> service, UUID from, UUID to) {
final T old = service.get(from);
final Field field = old.getClass().getDeclaredField("uuid");
field.setAccessible(true);
field.set(old, to);
service.getCache().remove(to);
service.save(old);
service.cache(old);
service.getCache().remove(from);
send(PREFIX + "Copied data from &e" + Nickname.of(from) + " &3to &e" + Nickname.of(to) + " &3in &e" + name(service));
}
use of gg.projecteden.nexus.framework.commands.models.annotations.Confirm in project Nexus by ProjectEdenGG.
the class ICustomCommand method invoke.
protected void invoke(Method method, CommandRunEvent event) {
Runnable function = () -> {
try {
Object[] objects = getMethodParameters(method, event, true);
method.setAccessible(true);
method.invoke(this, objects);
} catch (Exception ex) {
event.handleException(ex);
}
};
Runnable run = () -> {
if (method.getAnnotation(Async.class) != null)
Tasks.async(function);
else
function.run();
};
Confirm confirm = method.getAnnotation(Confirm.class);
if (event.getSender() instanceof Player && confirm != null) {
ConfirmationMenu.builder().onConfirm(e -> run.run()).title(confirm.title()).open(event.getPlayer());
} else
run.run();
}
use of gg.projecteden.nexus.framework.commands.models.annotations.Confirm in project Nexus by ProjectEdenGG.
the class DailyRewardsCommand method reset.
@Confirm
@Path("reset [player]")
void reset(@Arg(value = "self", permission = Group.ADMIN) DailyRewardUser user) {
try {
if (!new CooldownService().check(player(), resetCooldownType, TickTime.DAY))
throw new CommandCooldownException(player(), resetCooldownType);
user.endStreak();
service.save(user);
send(player(), PREFIX + "Your streak has been cleared");
player().closeInventory();
} catch (CommandCooldownException ex) {
send(player(), ex.getMessage());
}
}
Aggregations