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);
}
}
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);
}
}
});
}
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);
}
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);
}
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();
}
});
}
Aggregations