Search in sources :

Example 1 with Confirm

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));
}
Also used : Boost(gg.projecteden.nexus.models.boost.Booster.Boost) Booster(gg.projecteden.nexus.models.boost.Booster) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm)

Example 2 with Confirm

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" : ""));
}
Also used : Boost(gg.projecteden.nexus.models.boost.Booster.Boost) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm)

Example 3 with Confirm

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));
}
Also used : Field(java.lang.reflect.Field) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm) SneakyThrows(lombok.SneakyThrows)

Example 4 with Confirm

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();
}
Also used : Player(org.bukkit.entity.Player) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm) CommandCooldownException(gg.projecteden.nexus.framework.exceptions.postconfigured.CommandCooldownException) NexusException(gg.projecteden.nexus.framework.exceptions.NexusException) NoPermissionException(gg.projecteden.nexus.framework.exceptions.preconfigured.NoPermissionException) PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) MissingArgumentException(gg.projecteden.nexus.framework.exceptions.preconfigured.MissingArgumentException) PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)

Example 5 with Confirm

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());
    }
}
Also used : CommandCooldownException(gg.projecteden.nexus.framework.exceptions.postconfigured.CommandCooldownException) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm)

Aggregations

Confirm (gg.projecteden.nexus.framework.commands.models.annotations.Confirm)7 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)6 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)3 Async (gg.projecteden.annotations.Async)2 CommandCooldownException (gg.projecteden.nexus.framework.exceptions.postconfigured.CommandCooldownException)2 Boost (gg.projecteden.nexus.models.boost.Booster.Boost)2 NexusException (gg.projecteden.nexus.framework.exceptions.NexusException)1 InvalidInputException (gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException)1 PlayerNotFoundException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException)1 PlayerNotOnlineException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)1 MissingArgumentException (gg.projecteden.nexus.framework.exceptions.preconfigured.MissingArgumentException)1 NoPermissionException (gg.projecteden.nexus.framework.exceptions.preconfigured.NoPermissionException)1 Booster (gg.projecteden.nexus.models.boost.Booster)1 CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)1 EventUserService (gg.projecteden.nexus.models.eventuser.EventUserService)1 Home (gg.projecteden.nexus.models.home.Home)1 HomeOwner (gg.projecteden.nexus.models.home.HomeOwner)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SneakyThrows (lombok.SneakyThrows)1