Search in sources :

Example 66 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class BirthdayEventCommand method topLocations.

@Path("topLocations [page]")
@Permission(Group.ADMIN)
void topLocations(@Arg("1") int page) {
    Map<Location, Integer> counts = new HashMap<>() {

        {
            for (Birthday21User user : new Birthday21UserService().getAll()) for (Location location : user.getFound()) put(location, getOrDefault(location, 0) + 1);
        }
    };
    send(PREFIX + "Most found cakes");
    BiFunction<Location, String, JsonBuilder> formatter = (location, index) -> json(index + " &e" + getCoordinateString(location) + " &7- " + counts.get(location)).command(getTeleportCommand(location)).hover("&eClick to teleport");
    paginate(Utils.sortByValueReverse(counts).keySet(), formatter, "/birthdayevent topLocations", page);
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Birthday21UserService(gg.projecteden.nexus.models.birthday21.Birthday21UserService) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) BiFunction(java.util.function.BiFunction) LocalDateTime(java.time.LocalDateTime) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) HashMap(java.util.HashMap) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Action(org.bukkit.event.block.Action) EventHandler(org.bukkit.event.EventHandler) Block(org.bukkit.block.Block) Location(org.bukkit.Location) StringUtils.getTeleportCommand(gg.projecteden.nexus.utils.StringUtils.getTeleportCommand) Map(java.util.Map) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) LocationUtils(gg.projecteden.nexus.utils.LocationUtils) Listener(org.bukkit.event.Listener) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) StringUtils.getCoordinateString(gg.projecteden.nexus.utils.StringUtils.getCoordinateString) NonNull(lombok.NonNull) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Set(java.util.Set) Utils(gg.projecteden.nexus.utils.Utils) Vector(org.bukkit.util.Vector) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) LocalDate(java.time.LocalDate) Birthday21User(gg.projecteden.nexus.models.birthday21.Birthday21User) Comparator(java.util.Comparator) NoArgsConstructor(lombok.NoArgsConstructor) HashMap(java.util.HashMap) Birthday21UserService(gg.projecteden.nexus.models.birthday21.Birthday21UserService) StringUtils.getCoordinateString(gg.projecteden.nexus.utils.StringUtils.getCoordinateString) Birthday21User(gg.projecteden.nexus.models.birthday21.Birthday21User) Location(org.bukkit.Location) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 67 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class WitherCommand method maintenance.

@Path("maintenance")
@Permission(Group.STAFF)
void maintenance() {
    new WitherArenaConfigService().edit0(config -> config.setMaintenance(!isMaintenance()));
    send(PREFIX + "Wither arena maintenance mode " + (isMaintenance() ? "&aenabled" : "&cdisabled"));
}
Also used : WitherArenaConfigService(gg.projecteden.nexus.models.witherarena.WitherArenaConfigService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 68 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class WitherCommand method beta.

@Path("beta")
@Permission(Group.ADMIN)
void beta() {
    new WitherArenaConfigService().edit0(config -> config.setBeta(!isBeta()));
    send(PREFIX + "Wither arena beta mode " + (isBeta() ? "&aenabled" : "&cdisabled"));
}
Also used : WitherArenaConfigService(gg.projecteden.nexus.models.witherarena.WitherArenaConfigService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 69 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class TicketsCommand method statsClosed.

@Path("stats closed [page]")
@Permission(Group.MODERATOR)
void statsClosed(@Arg("1") int page) {
    Map<UUID, Integer> closers = new HashMap<>();
    for (Ticket ticket : tickets.getAll()) {
        if (ticket.isOpen())
            continue;
        if (ticket.getClosedBy() == null)
            continue;
        if (ticket.getClosedBy().equals(ticket.getUuid()))
            continue;
        closers.put(ticket.getClosedBy(), closers.getOrDefault(ticket.getClosedBy(), 0) + 1);
    }
    BiFunction<UUID, String, JsonBuilder> formatter = (uuid, index) -> json(index + " &e" + Nerd.of(uuid).getColoredName() + " &7- " + closers.get(uuid));
    paginate(Utils.sortByValueReverse(closers).keySet(), formatter, "/tickets stats closed", page);
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) BiFunction(java.util.function.BiFunction) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) ConverterFor(gg.projecteden.nexus.framework.commands.models.annotations.ConverterFor) HashMap(java.util.HashMap) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Tickets(gg.projecteden.nexus.models.ticket.Tickets) TicketsService(gg.projecteden.nexus.models.ticket.TicketsService) Map(java.util.Map) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Nerd(gg.projecteden.nexus.models.nerd.Nerd) TeleportCause(org.bukkit.event.player.PlayerTeleportEvent.TeleportCause) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Tasks(gg.projecteden.nexus.utils.Tasks) UUID(java.util.UUID) TicketAction(gg.projecteden.nexus.features.tickets.TicketFeature.TicketAction) Collectors(java.util.stream.Collectors) Ticket(gg.projecteden.nexus.models.ticket.Tickets.Ticket) Utils(gg.projecteden.nexus.utils.Utils) List(java.util.List) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) UUIDUtils.isUUID0(gg.projecteden.utils.UUIDUtils.isUUID0) Comparator(java.util.Comparator) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm) Ticket(gg.projecteden.nexus.models.ticket.Tickets.Ticket) HashMap(java.util.HashMap) UUID(java.util.UUID) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 70 with Permission

use of gg.projecteden.nexus.framework.commands.models.annotations.Permission in project Nexus by ProjectEdenGG.

the class CommandMapUtils method register.

void register(String name, CustomCommand customCommand) throws IllegalAccessException, InvocationTargetException, InstantiationException {
    if (customCommand.getClass().getAnnotation(DoubleSlash.class) != null)
        name = "/" + name;
    name = name.toLowerCase();
    CommandHandler handler = new CommandHandler(customCommand);
    PluginCommand pluginCommand = COMMAND_CONSTRUCTOR.newInstance(name, plugin);
    pluginCommand.setLabel(name);
    pluginCommand.setAliases(customCommand.getAliases());
    pluginCommand.setExecutor(handler);
    Description description = customCommand.getClass().getAnnotation(Description.class);
    if (description != null)
        pluginCommand.setDescription(description.value());
    Permission permission = customCommand.getClass().getAnnotation(Permission.class);
    if (permission != null)
        pluginCommand.setPermission(permission.value());
    commandMap.register(plugin.getDescription().getName(), pluginCommand);
    knownCommandMap.put(plugin.getDescription().getName().toLowerCase() + ":" + name, pluginCommand);
    knownCommandMap.put(name, pluginCommand);
    registerRedirects(customCommand);
}
Also used : Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) DoubleSlash(gg.projecteden.nexus.framework.commands.models.annotations.DoubleSlash) PluginCommand(org.bukkit.command.PluginCommand)

Aggregations

Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)94 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)93 Async (gg.projecteden.annotations.Async)15 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)13 ItemStack (org.bukkit.inventory.ItemStack)13 List (java.util.List)10 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)9 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)9 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)9 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)8 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)8 ArrayList (java.util.ArrayList)8 Nerd (gg.projecteden.nexus.models.nerd.Nerd)7 NerdService (gg.projecteden.nexus.models.nerd.NerdService)7 Utils (gg.projecteden.nexus.utils.Utils)7 HashMap (java.util.HashMap)7 BiFunction (java.util.function.BiFunction)7 Map (java.util.Map)6 Location (org.bukkit.Location)6 Aliases (gg.projecteden.nexus.framework.commands.models.annotations.Aliases)5