Search in sources :

Example 1 with SoundBuilder

use of gg.projecteden.nexus.utils.SoundBuilder in project Nexus by ProjectEdenGG.

the class AmbientSounds method startLoop.

private void startLoop(Player player, AmbientSoundType type) {
    if (type.equals(UNDERGROUND)) {
        int taskId = Tasks.repeat(0, TickTime.SECOND.x(37), () -> new SoundBuilder(undergroundLoop).receiver(player).category(SoundCategory.AMBIENT).volume(5).play());
        undergroundTaskMap.put(player, taskId);
    }
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder)

Example 2 with SoundBuilder

use of gg.projecteden.nexus.utils.SoundBuilder in project Nexus by ProjectEdenGG.

the class AmbientSounds method onStart.

@Override
public void onStart() {
    // Random sounds
    Tasks.repeat(startDelay, TickTime.SECOND.x(15), () -> {
        if (RandomUtils.chanceOf(50)) {
            Sound sound = RandomUtils.randomElement(undergroundSounds);
            Map<Player, Integer> tempMap = new HashMap<>(undergroundTaskMap);
            tempMap.forEach((player, integer) -> new SoundBuilder(sound).receiver(player).category(SoundCategory.AMBIENT).volume(1).pitch(.1).play());
        }
    });
    // Looping Sound Management
    Tasks.repeat(startDelay, TickTime.SECOND.x(1), () -> {
        for (Player player : OnlinePlayers.getAll()) {
            boolean inArea;
            boolean onList;
            // Underground
            inArea = isApplicable(player, UNDERGROUND);
            onList = undergroundTaskMap.containsKey(player);
            if (inArea && !onList) {
                startLoop(player, UNDERGROUND);
            } else if (!inArea && onList) {
                stopLoop(player, UNDERGROUND);
            }
        }
    });
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Player(org.bukkit.entity.Player) HashMap(java.util.HashMap) Sound(org.bukkit.Sound)

Example 3 with SoundBuilder

use of gg.projecteden.nexus.utils.SoundBuilder in project Nexus by ProjectEdenGG.

the class GiftGiver method openGift.

public static void openGift(Player player, ItemStack gift) {
    if (!ItemUtils.isFuzzyMatch(gift_unlocked, gift)) {
        PlayerUtils.send(player, locked);
        Quests.sound_villagerNo(player);
        return;
    }
    Location loc = RandomUtils.randomElement(lootChestList);
    Chest chest = (Chest) loc.getBlock().getState();
    ItemStack[] contents = chest.getBlockInventory().getContents();
    if (!Quests.hasRoomFor(player, contents)) {
        PlayerUtils.send(player, Quests.fullInvError_open);
        Quests.sound_villagerNo(player);
        return;
    }
    Inventory inventory = Bukkit.createInventory(null, 3 * 9, invTitle);
    inventory.setContents(contents);
    player.openInventory(inventory);
    new SoundBuilder(Sound.BLOCK_CHEST_OPEN).receiver(player).play();
    player.getInventory().removeItem(gift);
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Chest(org.bukkit.block.Chest) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) Location(org.bukkit.Location)

Example 4 with SoundBuilder

use of gg.projecteden.nexus.utils.SoundBuilder in project Nexus by ProjectEdenGG.

the class ReflectionGame method endLaser.

private static void endLaser() {
    Tasks.cancel(laserTaskId);
    Tasks.cancel(soundTaskId);
    Collection<Player> players = BearFair21.worldguard().getPlayersInRegion(gameRg);
    for (Player player : players) player.stopSound(Sound.BLOCK_BEACON_AMBIENT);
    new SoundBuilder(Sound.BLOCK_BEACON_DEACTIVATE).location(center).play();
    Tasks.wait(TickTime.SECOND.x(2), () -> active = false);
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Player(org.bukkit.entity.Player)

Example 5 with SoundBuilder

use of gg.projecteden.nexus.utils.SoundBuilder in project Nexus by ProjectEdenGG.

the class ReflectionGame method startLaser.

static void startLaser(Player player, BlockFace startFace) {
    active = true;
    ReflectionGameUtils.clearLamps();
    AtomicInteger cooldown = new AtomicInteger(5);
    AtomicInteger lifespan = new AtomicInteger(750);
    final BlockFace[] blockFace = { startFace };
    final Location[] loc = { laserStart.clone() };
    AtomicReference<Color> laserColor = new AtomicReference<>(getMinigolfUserColor(player));
    AtomicInteger reflections = new AtomicInteger(0);
    new SoundBuilder(Sound.BLOCK_BEACON_ACTIVATE).location(laserStart).volume(2.0).play();
    laserSound();
    laserTaskId = Tasks.repeat(0, 1, () -> {
        if (active) {
            laserSoundLoc = loc[0].clone();
            DotEffect.builder().player(player).location(loc[0].clone()).speed(0.1).ticks(10).color(laserColor.get()).start();
            Block block = loc[0].getBlock();
            Material blockType = block.getType();
            double middle = loc[0].getX() - loc[0].getBlockX();
            if (middle == 0.5 && !blockType.equals(Material.AIR) && cooldown.get() == 0) {
                boolean broadcast = true;
                if (blockType.equals(Material.REDSTONE_LAMP)) {
                    if (ReflectionGameUtils.checkObjective(reflections.get(), block.getRelative(0, 1, 0).getType())) {
                        BlockData blockData = block.getBlockData();
                        Lightable lightable = (Lightable) blockData;
                        lightable.setLit(true);
                        block.setBlockData(lightable);
                        Block block1 = block.getRelative(0, -6, 0);
                        BlockData blockData1 = block1.getBlockData();
                        Lightable lightable1 = (Lightable) blockData1;
                        lightable1.setLit(true);
                        block1.setBlockData(lightable1);
                        ReflectionGameUtils.win(reflections.get());
                        broadcast = false;
                    }
                }
                if (broadcast)
                    ReflectionGameUtils.broadcastObjective();
                endLaser();
                return;
            }
            Block below = block.getRelative(0, -1, 0);
            Material bannerType = below.getType();
            if (middle == 0.5 && MaterialTag.STANDING_BANNERS.isTagged(bannerType) && cooldown.get() == 0) {
                loc[0] = LocationUtils.getCenteredLocation(loc[0]);
                loc[0].setY(loc[0].getY() + 0.25);
                Rotatable rotatable = (Rotatable) below.getBlockData();
                BlockFace newFace = getReflection(blockFace[0], rotatable.getRotation());
                if (newFace == null) {
                    endLaser();
                    return;
                }
                if (!blockFace[0].equals(newFace))
                    reflections.incrementAndGet();
                blockFace[0] = newFace;
                cooldown.set(5);
            }
            loc[0] = loc[0].clone().add(blockFace[0].getDirection().multiply(0.25));
            lifespan.getAndDecrement();
            if (cooldown.get() > 0) {
                cooldown.getAndDecrement();
            }
            int currentLife = lifespan.get();
            if (currentLife <= 0) {
                endLaser();
            }
            if (currentLife <= 300) {
                if (currentLife <= 100)
                    laserColor.set(Color.YELLOW);
                else
                    laserColor.set(Color.ORANGE);
            }
        } else {
            endLaser();
        }
    });
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) BlockFace(org.bukkit.block.BlockFace) Lightable(org.bukkit.block.data.Lightable) Color(org.bukkit.Color) AtomicReference(java.util.concurrent.atomic.AtomicReference) Material(org.bukkit.Material) Rotatable(org.bukkit.block.data.Rotatable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Block(org.bukkit.block.Block) BlockData(org.bukkit.block.data.BlockData) Location(org.bukkit.Location)

Aggregations

SoundBuilder (gg.projecteden.nexus.utils.SoundBuilder)26 ItemStack (org.bukkit.inventory.ItemStack)11 Location (org.bukkit.Location)9 Player (org.bukkit.entity.Player)8 Block (org.bukkit.block.Block)6 EventHandler (org.bukkit.event.EventHandler)6 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)4 Material (org.bukkit.Material)4 CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Sound (org.bukkit.Sound)3 ClickableItem (fr.minuskube.inv.ClickableItem)2 Minigamer (gg.projecteden.nexus.features.minigames.models.Minigamer)2 EventUser (gg.projecteden.nexus.models.eventuser.EventUser)2 EventUserService (gg.projecteden.nexus.models.eventuser.EventUserService)2 Pride21User (gg.projecteden.nexus.models.pride21.Pride21User)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 SoundCategory (org.bukkit.SoundCategory)2 BlockData (org.bukkit.block.data.BlockData)2 Inventory (org.bukkit.inventory.Inventory)2