Search in sources :

Example 11 with CooldownService

use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.

the class ShopUtils method giveItems.

public static void giveItems(UUID uuid, List<ItemStack> items) {
    Shop shop = new ShopService().get(uuid);
    if (shop.isOnline()) {
        List<ItemStack> excess = PlayerUtils.giveItemsAndGetExcess(shop.getOnlinePlayer(), items);
        shop.addHolding(excess);
        if (!excess.isEmpty())
            if (new CooldownService().check(uuid, "shop-excess-items", TickTime.SECOND.x(2)))
                PlayerUtils.send(uuid, new JsonBuilder(Shops.PREFIX + "Excess items added to item collection menu, click to view").command("/shops collect"));
    } else
        shop.addHolding(items);
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Shop(gg.projecteden.nexus.models.shop.Shop) ShopService(gg.projecteden.nexus.models.shop.ShopService) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) ItemStack(org.bukkit.inventory.ItemStack)

Example 12 with CooldownService

use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.

the class CandyCaneCannon method onPlayerInteract.

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (!ActionGroup.RIGHT_CLICK.applies(event))
        return;
    if (event.getHand() != EquipmentSlot.HAND)
        return;
    final Player player = event.getPlayer();
    final ItemStack item = player.getInventory().getItem(event.getHand());
    if (!isCannon(item))
        return;
    final ItemStack candyCaneItem = findCandyCane(player);
    if (candyCaneItem == null) {
        if (new CooldownService().check(player, "candycanecannonammo", TickTime.SECOND.x(3)))
            PlayerUtils.send(player, "&cYou are out of candy cane ammo!");
        event.setCancelled(true);
        return;
    }
    final Snowball snowball = player.launchProjectile(Snowball.class);
    snowball.setItem(candyCaneItem);
    snowball.setSilent(true);
    new SoundBuilder(Sound.ENTITY_SNOWBALL_THROW).location(player).pitch(2).play();
    if (!GameModeWrapper.of(player).isCreative())
        candyCaneItem.subtract();
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Snowball(org.bukkit.entity.Snowball) Player(org.bukkit.entity.Player) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 13 with CooldownService

use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.

the class MailCommand method onWorldChange.

@EventHandler
public void onWorldChange(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    WorldGroup worldGroup = WorldGroup.of(player);
    Mailer mailer = service.get(player);
    List<Mail> mails = new ArrayList<>(mailer.getMail(worldGroup));
    if (isNullOrEmpty(mails))
        return;
    if (!new CooldownService().check(player, "youhavemail", TickTime.MINUTE.x(5)))
        return;
    mailer.sendNotification();
}
Also used : Player(org.bukkit.entity.Player) Mail(gg.projecteden.nexus.models.mail.Mailer.Mail) WorldGroup(gg.projecteden.nexus.utils.WorldGroup) ArrayList(java.util.ArrayList) Mailer(gg.projecteden.nexus.models.mail.Mailer) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) EventHandler(org.bukkit.event.EventHandler)

Example 14 with CooldownService

use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.

the class Quests method onRightClickNPC.

@EventHandler
public void onRightClickNPC(NPCRightClickEvent event) {
    Player player = event.getClicker();
    if (event.getNPC().getId() != PARADE_MANAGER.getNpcId())
        return;
    CooldownService cooldownService = new CooldownService();
    if (!cooldownService.check(player, "Pride21_NPCInteract", TimeUtils.TickTime.SECOND.x(5)))
        return;
    int waitTicks = Talker.sendScript(player, PARADE_MANAGER);
    Pride21User user = service.get(player);
    if (user.isComplete()) {
        Tasks.wait(waitTicks, () -> player.teleportAsync(player.getLocation()));
        Tasks.waitAsync(waitTicks, () -> {
            player.resetPlayerTime();
            viewFloat(player, true);
            if (false && !user.isBonusTokenRewardClaimed()) {
                Trophy.PRIDE_2021.give(player);
                user.setBonusTokenRewardClaimed(true);
                service.save(user);
                EventUserService eventUserService = new EventUserService();
                EventUser eventUser = eventUserService.get(user);
                eventUser.giveTokens(50);
                eventUserService.save(eventUser);
                ItemStack dyeBomb = DyeBombCommand.getDyeBomb();
                dyeBomb.setAmount(16);
                PlayerUtils.giveItemAndMailExcess(player, dyeBomb, "Pride 2021 Reward", WorldGroup.SURVIVAL);
            }
        });
    }
}
Also used : Player(org.bukkit.entity.Player) Pride21User(gg.projecteden.nexus.models.pride21.Pride21User) EventUser(gg.projecteden.nexus.models.eventuser.EventUser) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) ItemStack(org.bukkit.inventory.ItemStack) EventUserService(gg.projecteden.nexus.models.eventuser.EventUserService) EventHandler(org.bukkit.event.EventHandler)

Example 15 with CooldownService

use of gg.projecteden.nexus.models.cooldown.CooldownService in project Nexus by ProjectEdenGG.

the class AACNotifyCommand method notify.

@Path("<player> <message...>")
void notify(Player player, String reason) {
    String name = player.getName();
    WorldGroup worldGroup = WorldGroup.of(player);
    int ping = player.getPing();
    double tps = Bukkit.getTPS()[1];
    if (ping < 300 && tps >= 15) {
        String message = "&a" + name + " &f" + reason.replace("{worldgroup}", camelCase(worldGroup)).replace("{ping}", String.valueOf(ping)).replace("{tps}", new DecimalFormat("0.00").format(tps));
        UUID uuid = player.getUniqueId();
        totalCounts.put(uuid, totalCounts.getOrDefault(uuid, 0) + 1);
        if (new CooldownService().check(player, "aac-notify-ingame", TickTime.SECOND.x(15))) {
            String ingame = message;
            if (ingameCounts.getOrDefault(uuid, 0) > 0)
                ingame += (" &c(" + ingameCounts.get(uuid) + " more...)");
            Broadcast.staffIngame().message("&7&l[&cRadar&7&l] " + ingame).send();
            ingameCounts.remove(uuid);
        } else
            ingameCounts.put(uuid, ingameCounts.getOrDefault(uuid, 0) + 1);
        if (new CooldownService().check(player, "aac-notify-discord", TickTime.MINUTE)) {
            String discord = message;
            if (discordCounts.getOrDefault(uuid, 0) > 0)
                discord += " (" + discordCounts.get(uuid) + " more...)";
            Broadcast.staffDiscord().prefix("Radar").message(discord).send();
            discordCounts.remove(uuid);
        } else
            discordCounts.put(uuid, discordCounts.getOrDefault(uuid, 0) + 1);
        if (Rank.getOnlineMods().stream().allMatch(nerd -> AFK.get(player.getPlayer()).isTimeAfk()))
            if (totalCounts.getOrDefault(uuid, 0) > 20)
                runCommandAsConsole("ban " + player.getName() + " 1d You have been automatically banned " + "by our anti cheat. Hacking is not allowed! (C: " + totalCounts.get(uuid) + ")");
    }
}
Also used : WorldGroup(gg.projecteden.nexus.utils.WorldGroup) DecimalFormat(java.text.DecimalFormat) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) UUID(java.util.UUID) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)20 Player (org.bukkit.entity.Player)11 EventHandler (org.bukkit.event.EventHandler)11 ItemStack (org.bukkit.inventory.ItemStack)5 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)4 SoundBuilder (gg.projecteden.nexus.utils.SoundBuilder)3 WorldGroup (gg.projecteden.nexus.utils.WorldGroup)3 UUID (java.util.UUID)3 CommandCooldownException (gg.projecteden.nexus.framework.exceptions.postconfigured.CommandCooldownException)2 Block (org.bukkit.block.Block)2 QuestNPC (gg.projecteden.nexus.features.events.y2020.halloween20.models.QuestNPC)1 SoundButton (gg.projecteden.nexus.features.events.y2020.halloween20.models.SoundButton)1 Match (gg.projecteden.nexus.features.minigames.models.Match)1 HoleInTheWallArena (gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena)1 HoleInTheWallMatchData (gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData)1 Track (gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track)1 PathParser.getPathString (gg.projecteden.nexus.framework.commands.models.PathParser.getPathString)1 Confirm (gg.projecteden.nexus.framework.commands.models.annotations.Confirm)1 PlayerNotOnlineException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException)1 EventUser (gg.projecteden.nexus.models.eventuser.EventUser)1