Search in sources :

Example 1 with Async

use of gg.projecteden.annotations.Async in project Nexus by ProjectEdenGG.

the class StoreCommand method coupon_create.

@Async
@SneakyThrows
@Path("coupons create <player> <amount>")
@Permission(Group.ADMIN)
void coupon_create(Contributor contributor, double amount) {
    String code = new CouponCreator(contributor, amount).create();
    send(json(PREFIX + "Created coupon &e" + code).copy(code).hover("&fClick to copy"));
}
Also used : CouponCreator(gg.projecteden.nexus.features.store.BuycraftUtils.CouponCreator) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) SneakyThrows(lombok.SneakyThrows)

Example 2 with Async

use of gg.projecteden.annotations.Async in project Nexus by ProjectEdenGG.

the class StoreCommand method coupon_list.

@Async
@SneakyThrows
@Path("coupons list <player>")
void coupon_list(@Arg(value = "self", permission = Group.STAFF) Contributor contributor) {
    final List<Coupon> coupons = Nexus.getBuycraft().getApiClient().getAllCoupons().execute().body().getData().stream().filter(coupon -> coupon.getUsername().equals(contributor.getName())).filter(coupon -> coupon.getExpire().getLimit() > 0).toList();
    if (coupons.isEmpty())
        error("No coupons found" + (isSelf(contributor) ? ". Create one with /store credit redeem <amount>" : " for " + contributor.getNickname()));
    send(PREFIX + "Available coupons (&eClick &3to copy)");
    line();
    for (Coupon coupon : coupons) send(json(" &e" + coupon.getCode() + " &7- $" + coupon.getDiscount().getValue()).copy(coupon.getCode()).hover("&fClick to copy"));
    line();
    send("&3Redeem at &e" + StoreCommand.URL);
}
Also used : StringUtils(gg.projecteden.nexus.utils.StringUtils) SneakyThrows(lombok.SneakyThrows) SmartInventory(fr.minuskube.inv.SmartInventory) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) DisplaySet(gg.projecteden.nexus.features.store.gallery.StoreGalleryNPCs.DisplaySet) TabCompleteIgnore(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleteIgnore) BiFunction(java.util.function.BiFunction) Async(gg.projecteden.annotations.Async) ContributorService(gg.projecteden.nexus.models.store.ContributorService) StoreGalleryNPCs(gg.projecteden.nexus.features.store.gallery.StoreGalleryNPCs) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Player(org.bukkit.entity.Player) Contributor(gg.projecteden.nexus.models.store.Contributor) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) WarpType(gg.projecteden.nexus.models.warps.WarpType) PlayerRankChangeEvent(gg.projecteden.nexus.utils.LuckPermsUtils.GroupChange.PlayerRankChangeEvent) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) ExtraPlotUserService(gg.projecteden.nexus.models.extraplots.ExtraPlotUserService) CouponCreator(gg.projecteden.nexus.features.store.BuycraftUtils.CouponCreator) StoreCategory(gg.projecteden.nexus.features.store.annotations.Category.StoreCategory) Nickname(gg.projecteden.nexus.models.nickname.Nickname) Purchase(gg.projecteden.nexus.models.store.Contributor.Purchase) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) Listener(org.bukkit.event.Listener) Nexus(gg.projecteden.nexus.Nexus) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) NPCListener(gg.projecteden.nexus.features.store.perks.NPCListener) Nerd(gg.projecteden.nexus.models.nerd.Nerd) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) UUID(java.util.UUID) StringUtils.prettyMoney(gg.projecteden.nexus.utils.StringUtils.prettyMoney) Coupon(net.buycraft.plugin.data.Coupon) Utils(gg.projecteden.nexus.utils.Utils) OfflinePlayer(org.bukkit.OfflinePlayer) Aliases(gg.projecteden.nexus.framework.commands.models.annotations.Aliases) List(java.util.List) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) MenuUtils(gg.projecteden.nexus.features.menus.MenuUtils) AllArgsConstructor(lombok.AllArgsConstructor) NoArgsConstructor(lombok.NoArgsConstructor) Coupon(net.buycraft.plugin.data.Coupon) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) SneakyThrows(lombok.SneakyThrows)

Example 3 with Async

use of gg.projecteden.annotations.Async in project Nexus by ProjectEdenGG.

the class FirstLoginCommand method stats.

@Async
@Path("stats")
@Permission(Group.ADMIN)
void stats() {
    StringBuilder data = new StringBuilder();
    for (Nerd nerd : new NerdService().getAll()) if (nerd.getFirstJoin() != null)
        data.append(nerd.getNickname()).append(",").append(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(nerd.getFirstJoin())).append(System.lineSeparator());
    IOUtils.fileAppend("joindates.csv", data.toString());
    send(PREFIX + "Generated joindates.csv");
}
Also used : Nerd(gg.projecteden.nexus.models.nerd.Nerd) NerdService(gg.projecteden.nexus.models.nerd.NerdService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 4 with Async

use of gg.projecteden.annotations.Async in project Nexus by ProjectEdenGG.

the class BadgeCommand method convert.

@Async
@Permission(Group.ADMIN)
@Path("convert")
void convert() {
    int i = 0;
    int owned = 0;
    int active = 0;
    final List<Nerd> nerds = new NerdService().getAll();
    send(PREFIX + "Converting checkmarks");
    for (Nerd nerd : nerds) {
        if (!LuckPermsUtils.hasPermission(nerd, "donated"))
            continue;
        final BadgeUser user = service.get(nerd);
        user.give(Badge.SUPPORTER);
        ++owned;
        if (nerd.isCheckmark()) {
            user.setActive(Badge.SUPPORTER);
            ++active;
        }
        if (++i % 25 == 0)
            send(PREFIX + "Converted &e" + i + "&3/&e" + nerds.size());
    }
    service.saveCache();
    send(PREFIX + "Completed; &e" + owned + " &3owned, &e" + active + " &3active");
}
Also used : Nerd(gg.projecteden.nexus.models.nerd.Nerd) BadgeUser(gg.projecteden.nexus.models.badge.BadgeUser) NerdService(gg.projecteden.nexus.models.nerd.NerdService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 5 with Async

use of gg.projecteden.annotations.Async in project Nexus by ProjectEdenGG.

the class AeveonProjectCommand method flora.

@Async
@Path("flora [radius]")
public void flora(@Arg("5") int radius) {
    final int finalRadius = Math.max(1, Math.min(radius, 25));
    List<Block> placeFloraOn = new ArrayList<>();
    List<Block> blocks = BlockUtils.getBlocksInRadius(location(), finalRadius);
    for (Block block : blocks) {
        Block above = block.getRelative(BlockFace.UP);
        if (allowedFloraMaterials.contains(block.getType()) && isNullOrAir(above))
            placeFloraOn.add(above);
    }
    for (Block block : placeFloraOn) {
        Material material = getWeightedRandom(floraChanceMap);
        Tasks.sync(() -> {
            block.setType(material);
            if (material.equals(Material.TWISTING_VINES_PLANT) && RandomUtils.chanceOf(75))
                block.getRelative(BlockFace.UP).setType(Material.TWISTING_VINES);
        });
    }
}
Also used : ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) Material(org.bukkit.Material) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async)

Aggregations

Async (gg.projecteden.annotations.Async)44 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)44 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)21 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)14 ArrayList (java.util.ArrayList)12 List (java.util.List)11 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)10 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)10 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)10 DiscordUser (gg.projecteden.nexus.models.discord.DiscordUser)10 Nerd (gg.projecteden.nexus.models.nerd.Nerd)10 HashMap (java.util.HashMap)10 BiFunction (java.util.function.BiFunction)10 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)8 Nickname (gg.projecteden.nexus.models.nickname.Nickname)8 Map (java.util.Map)7 Rank (gg.projecteden.nexus.models.nerd.Rank)6 StringUtils (gg.projecteden.nexus.utils.StringUtils)6 TickTime (gg.projecteden.utils.TimeUtils.TickTime)6 UUID (java.util.UUID)6