Search in sources :

Example 1 with CooldownService

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

the class Pride20Listener method onSecretCatClick.

@EventHandler
public void onSecretCatClick(NPCRightClickEvent event) {
    if (event.getNPC().getId() != 2776)
        return;
    Player player = event.getClicker();
    SettingService service = new SettingService();
    Setting setting = service.get(player, "pride20Secret");
    if (setting.getBoolean()) {
        CooldownService cooldownService = new CooldownService();
        if (!cooldownService.check(player, "pride20Cat", TickTime.SECOND.x(10)))
            return;
        player.playSound(player.getLocation(), Sound.ENTITY_CAT_PURREOW, 5f, .08f);
        return;
    }
    player.playSound(player.getLocation(), Sound.ENTITY_CAT_PURREOW, 5f, .08f);
    PlayerUtils.giveItem(player, new ItemBuilder(Material.ORANGE_BANNER).pattern(DyeColor.RED, PatternType.STRIPE_TOP).pattern(DyeColor.YELLOW, PatternType.STRIPE_MIDDLE).pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR).pattern(DyeColor.YELLOW, PatternType.STRIPE_MIDDLE).pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM).build());
    setting.setBoolean(true);
    service.save(setting);
    PlayerUtils.send(player, "&eHow did you even get here? I mean.... meow");
}
Also used : Player(org.bukkit.entity.Player) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) SettingService(gg.projecteden.nexus.models.setting.SettingService) Setting(gg.projecteden.nexus.models.setting.Setting) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) EventHandler(org.bukkit.event.EventHandler)

Example 2 with CooldownService

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

the class Pugmas20 method onNPCClick.

@EventHandler
public void onNPCClick(NPCRightClickEvent event) {
    Player player = event.getClicker();
    if (!isAtPugmas(player))
        return;
    if (!new CooldownService().check(event.getClicker(), "Pugmas20_NPC", TickTime.SECOND.x(10)))
        return;
    int id = event.getNPC().getId();
    QuestNPC.startScript(player, id);
    Merchants.openMerchant(player, id);
}
Also used : Player(org.bukkit.entity.Player) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) EventHandler(org.bukkit.event.EventHandler)

Example 3 with CooldownService

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

the class Pugmas20 method onNpcLeftClick.

@EventHandler
public void onNpcLeftClick(NPCLeftClickEvent event) {
    Player player = event.getClicker();
    if (!isAtPugmas(player))
        return;
    if (!new CooldownService().check(player, "pugmas20-elf-punch", TickTime.SECOND.x(3)))
        return;
    String message = RandomUtils.randomElement("Ow!", "Stop that!", "Rude!");
    PlayerUtils.send(player, QuestNPC.format(event.getNPC().getName(), message));
}
Also used : Player(org.bukkit.entity.Player) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) EventHandler(org.bukkit.event.EventHandler)

Example 4 with CooldownService

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

the class Halloween20 method onButtonClick.

@EventHandler
public void onButtonClick(PlayerInteractEvent event) {
    if (!ActionGroup.CLICK_BLOCK.applies(event))
        return;
    if (event.getHand() != EquipmentSlot.HAND)
        return;
    SoundButton button = SoundButton.getByLocation(event.getClickedBlock().getLocation());
    if (button == null)
        return;
    new SoundBuilder(button.getSound()).receiver(event.getPlayer()).play();
    Halloween20Service service = new Halloween20Service();
    Halloween20User user = service.get(event.getPlayer());
    if (user.getFoundButtons().contains(button)) {
        if (new CooldownService().check(event.getPlayer(), "halloween20-button-alreadyfound", TickTime.SECOND.x(10)))
            user.sendMessage(PREFIX + "You've already found this button!");
        return;
    }
    user.getFoundButtons().add(button);
    service.save(user);
    user.sendMessage(PREFIX + "You have found a spooky button! &e(" + user.getFoundButtons().size() + "/" + SoundButton.values().length + ")");
    if (user.getFoundButtons().size() != SoundButton.values().length)
        return;
    PermissionChange.set().player(event.getPlayer()).permissions("powder.powder.spookyscaryskeletons").runAsync();
    user.sendMessage(PREFIX + "You have unlocked the Spooky Scary Skeletons song! &c/songs");
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Halloween20User(gg.projecteden.nexus.models.halloween20.Halloween20User) Halloween20Service(gg.projecteden.nexus.models.halloween20.Halloween20Service) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) SoundButton(gg.projecteden.nexus.features.events.y2020.halloween20.models.SoundButton) EventHandler(org.bukkit.event.EventHandler)

Example 5 with CooldownService

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

the class Mining method breakBlock.

public static boolean breakBlock(BlockBreakEvent event) {
    Player player = event.getPlayer();
    Block block = event.getBlock();
    Material type = block.getType();
    if (!OreType.getOres().contains(type))
        return false;
    OreType oreType = OreType.ofOre(type);
    if (oreType == null)
        return false;
    ItemStack tool = player.getInventory().getItemInMainHand();
    if (!oreType.canBeMinedBy(tool.getType())) {
        if (new CooldownService().check(player, "BF21_cantbreak_tool", TickTime.SECOND.x(15))) {
            send(Errors.CANT_BREAK + " with this tool. Needs either: " + oreType.getCanBreak(), player);
            Quests.sound_villagerNo(player);
        }
        return true;
    }
    Quests.giveExp(player);
    new SoundBuilder(Sound.BLOCK_STONE_BREAK).location(player.getLocation()).category(SoundCategory.BLOCKS).play();
    PlayerUtils.giveItem(player, oreType.getIngotItemStack(tool));
    new BlockRegenJob(block.getLocation(), block.getType()).schedule(randomInt(3 * 60, 5 * 60));
    block.setType(Material.STONE);
    return true;
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Player(org.bukkit.entity.Player) BlockRegenJob(gg.projecteden.nexus.models.scheduledjobs.jobs.BlockRegenJob) Block(org.bukkit.block.Block) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack)

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