Search in sources :

Example 6 with CooldownService

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

the class WelcomeCommand method welcome.

@Path("[player]")
void welcome(Player player) {
    if (player != null) {
        if (Rank.of(player) != Rank.GUEST)
            error("Prevented accidental welcome");
        if (new HoursService().get(player).has(TickTime.HOUR))
            error("Prevented accidental welcome");
    }
    if (new CooldownService().check(UUID0, "welc", TickTime.SECOND.x(20))) {
        String message = getMessage();
        if (player == null)
            message = message.replaceAll(" \\[player]", "");
        else
            message = message.replaceAll("\\[player]", player.getName());
        runCommand("ch qm g " + message);
    } else {
        if (player == null)
            runCommand("ch qm g Welcome to the server!");
        else
            runCommand("ch qm g Welcome to the server, " + player.getName());
    }
}
Also used : CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) HoursService(gg.projecteden.nexus.models.hours.HoursService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 7 with CooldownService

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

the class KitCommand method kit.

@Path("<kit>")
void kit(Kit kit) {
    WorldGroup worldGroup = worldGroup();
    if (worldGroup != WorldGroup.SURVIVAL && worldGroup != WorldGroup.CREATIVE)
        error("Kits may only be claimed in survival and creative");
    if (!player().hasPermission("kit." + kit.getName()))
        error("You do not have permission to use this kit");
    CooldownService service = new CooldownService();
    if (!service.check(player(), "kit-" + kit.getName(), kit.getDelay()))
        error("You must wait " + service.getDiff(player(), "kit-" + kit.getName()) + " before you can receive that kit again");
    PlayerUtils.giveItems(player(), Arrays.asList(kit.getItems()));
    send(PREFIX + "You have been given the &e" + StringUtils.camelCase(kit.getName()) + " &3kit");
}
Also used : WorldGroup(gg.projecteden.nexus.utils.WorldGroup) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 8 with CooldownService

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

the class HoleInTheWall method onPlayerInteract.

@Override
public void onPlayerInteract(Minigamer minigamer, PlayerInteractEvent event) {
    Match match = minigamer.getMatch();
    HoleInTheWallArena arena = match.getArena();
    HoleInTheWallMatchData matchData = match.getMatchData();
    if (event.getClickedBlock() != null) {
        if (event.getAction() == Action.LEFT_CLICK_BLOCK)
            if (MaterialTag.STAINED_GLASS.isTagged(event.getClickedBlock().getType())) {
                if (isInAnswerRegion(minigamer, event.getClickedBlock().getLocation())) {
                    Player player = event.getPlayer();
                    player.playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, SoundCategory.BLOCKS, 1F, 1F);
                    player.getInventory().addItem(new ItemStack(event.getClickedBlock().getType()));
                    event.getClickedBlock().setType(Material.AIR);
                }
            }
        if (ActionGroup.CLICK_BLOCK.applies(event))
            if (MaterialTag.SIGNS.isTagged(event.getClickedBlock().getType())) {
                Sign sign = (Sign) event.getClickedBlock().getState();
                if (stripColor(sign.getLine(2)).contains("Fast Forward")) {
                    Track track = matchData.getTrack(minigamer);
                    if (track != null) {
                        UUID uuid = minigamer.getPlayer().getUniqueId();
                        String type = "HoleInTheWall-Skip";
                        if (new CooldownService().check(uuid, type, TickTime.SECOND.x(3)))
                            track.skip();
                        else
                            minigamer.tell("You must wait &e" + new CooldownService().getDiff(uuid, type));
                    }
                }
            }
    }
}
Also used : Player(org.bukkit.entity.Player) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Sign(org.bukkit.block.Sign) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) StringUtils.getLocationString(gg.projecteden.nexus.utils.StringUtils.getLocationString) ItemStack(org.bukkit.inventory.ItemStack) UUID(java.util.UUID) HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track) Match(gg.projecteden.nexus.features.minigames.models.Match)

Example 9 with CooldownService

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

the class ICustomCommand method checkCooldown.

private void checkCooldown(CustomCommand command, Cooldown cooldown, String commandId) {
    if (cooldown != null) {
        boolean bypass = false;
        if (!(command.getEvent().getSender() instanceof Player))
            bypass = true;
        else if (cooldown.bypass().length() > 0 && command.getEvent().getPlayer().hasPermission(cooldown.bypass()))
            bypass = true;
        if (!bypass) {
            int ticks = cooldown.value().x(cooldown.x());
            CooldownService service = new CooldownService();
            UUID uuid = cooldown.global() ? UUID0 : ((Player) command.getEvent().getSender()).getUniqueId();
            String type = "command:" + commandId;
            if (!service.check(uuid, type, ticks))
                throw new CommandCooldownException(uuid, type);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) CommandCooldownException(gg.projecteden.nexus.framework.exceptions.postconfigured.CommandCooldownException) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) PathParser.getPathString(gg.projecteden.nexus.framework.commands.models.PathParser.getPathString) UUID(java.util.UUID)

Example 10 with CooldownService

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

the class DailyRewardsCommand method reset.

@Confirm
@Path("reset [player]")
void reset(@Arg(value = "self", permission = Group.ADMIN) DailyRewardUser user) {
    try {
        if (!new CooldownService().check(player(), resetCooldownType, TickTime.DAY))
            throw new CommandCooldownException(player(), resetCooldownType);
        user.endStreak();
        service.save(user);
        send(player(), PREFIX + "Your streak has been cleared");
        player().closeInventory();
    } catch (CommandCooldownException ex) {
        send(player(), ex.getMessage());
    }
}
Also used : CommandCooldownException(gg.projecteden.nexus.framework.exceptions.postconfigured.CommandCooldownException) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Confirm(gg.projecteden.nexus.framework.commands.models.annotations.Confirm)

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