Search in sources :

Example 26 with Permission

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

the class AltBanCommand method bots.

@Permission(Group.ADMIN)
@Path("bots <names> [--dryrun]")
void bots(@Arg(type = String.class) List<String> names, @Switch boolean dryrun) {
    int banned = 0;
    int ignored = 0;
    for (String name : names) {
        try {
            Nerd nerd = Nerd.of(name);
            if (!nerd.getPastNames().contains(name))
                throw new PlayerNotFoundException(name);
            ++banned;
            if (dryrun)
                send("Banning " + name);
            else
                Punishments.of(nerd).add(Punishment.ofType(PunishmentType.ALT_BAN).punisher(uuid()).input("Spam bot").now(true));
        } catch (PlayerNotFoundException ex) {
            send("Ignoring " + name);
            ++ignored;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    send("Banned " + banned + ", ignored " + ignored);
}
Also used : PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) Nerd(gg.projecteden.nexus.models.nerd.Nerd) PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 27 with Permission

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

the class Easter21Command method topLocations.

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

        {
            for (Easter21User user : new Easter21UserService().getAll()) for (Location location : user.getFound()) put(location, getOrDefault(location, 0) + 1);
        }
    };
    send(PREFIX + "Most found eggs");
    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, "/easter topLocations", page);
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) ActionGroup(gg.projecteden.nexus.utils.Utils.ActionGroup) 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) EventHandler(org.bukkit.event.EventHandler) WarpType(gg.projecteden.nexus.models.warps.WarpType) 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) WorldGuardUtils(gg.projecteden.nexus.utils.WorldGuardUtils) Material(org.bukkit.Material) Listener(org.bukkit.event.Listener) Warp(gg.projecteden.nexus.models.warps.Warps.Warp) 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) Easter21User(gg.projecteden.nexus.models.easter21.Easter21User) Utils(gg.projecteden.nexus.utils.Utils) Easter21UserService(gg.projecteden.nexus.models.easter21.Easter21UserService) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) LocalDate(java.time.LocalDate) Comparator(java.util.Comparator) Disabled(gg.projecteden.annotations.Disabled) BlockFromToEvent(org.bukkit.event.block.BlockFromToEvent) NoArgsConstructor(lombok.NoArgsConstructor) HashMap(java.util.HashMap) Easter21User(gg.projecteden.nexus.models.easter21.Easter21User) Easter21UserService(gg.projecteden.nexus.models.easter21.Easter21UserService) StringUtils.getCoordinateString(gg.projecteden.nexus.utils.StringUtils.getCoordinateString) Location(org.bukkit.Location) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 28 with Permission

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

the class Easter21Command method start.

@Path("start")
@Permission(Group.ADMIN)
void start() {
    List<Warp> locations = WarpType.EASTER21.getAll();
    for (Warp warp : locations) warp.getLocation().getBlock().setType(Material.DRAGON_EGG);
    send(PREFIX + "Created " + locations.size() + " easter eggs");
}
Also used : Warp(gg.projecteden.nexus.models.warps.Warps.Warp) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 29 with Permission

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

the class Easter21Command method end.

@Path("end")
@Permission(Group.ADMIN)
void end() {
    List<Warp> locations = WarpType.EASTER21.getAll();
    for (Warp warp : locations) warp.getLocation().getBlock().setType(Material.AIR);
    send(PREFIX + "Deleted " + locations.size() + " easter eggs");
}
Also used : Warp(gg.projecteden.nexus.models.warps.Warps.Warp) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 30 with Permission

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

the class ItemTagsCommand method getTags.

@Path("get")
@Description("Get item tags on held item")
@Permission(Group.ADMIN)
void getTags() {
    ItemStack tool = getToolRequired();
    send("");
    send("Item Tags: ");
    Condition condition = Condition.of(tool);
    if (condition != null)
        send(condition.getTag());
    Rarity rarity = Rarity.of(tool, condition);
    if (rarity != null)
        send(rarity.getTag());
    send("");
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

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