mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 12:42:05 -07:00
Catch async usage of playsound (#10021)
This commit is contained in:
@@ -3447,6 +3447,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper start - adventure sounds
|
||||
+ @Override
|
||||
+ public void playSound(final net.kyori.adventure.sound.Sound sound) {
|
||||
+ if (sound.seed().isEmpty()) org.spigotmc.AsyncCatcher.catchOp("play sound; cannot generate seed with world random"); // Paper
|
||||
+ final long seed = sound.seed().orElseGet(this.console.overworld().getRandom()::nextLong);
|
||||
+ for (ServerPlayer player : this.playerList.getPlayers()) {
|
||||
+ player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player.getX(), player.getY(), player.getZ(), seed, null));
|
||||
@@ -3455,17 +3456,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public void playSound(final net.kyori.adventure.sound.Sound sound, final double x, final double y, final double z) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
||||
+ io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, x, y, z, sound.seed().orElseGet(this.console.overworld().getRandom()::nextLong), this.playSound0(x, y, z, this.console.getAllLevels()));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void playSound(final net.kyori.adventure.sound.Sound sound, final net.kyori.adventure.sound.Sound.Emitter emitter) {
|
||||
+ if (sound.seed().isEmpty()) org.spigotmc.AsyncCatcher.catchOp("play sound; cannot generate seed with world random"); // Paper
|
||||
+ final long seed = sound.seed().orElseGet(this.console.overworld().getRandom()::nextLong);
|
||||
+ if (emitter == net.kyori.adventure.sound.Sound.Emitter.self()) {
|
||||
+ for (ServerPlayer player : this.playerList.getPlayers()) {
|
||||
+ player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player, seed, null));
|
||||
+ }
|
||||
+ } else if (emitter instanceof org.bukkit.craftbukkit.entity.CraftEntity craftEntity) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("play sound; cannot use entity emitter"); // Paper
|
||||
+ final net.minecraft.world.entity.Entity entity = craftEntity.getHandle();
|
||||
+ io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, entity, seed, this.playSound0(entity.getX(), entity.getY(), entity.getZ(), List.of((ServerLevel) entity.level())));
|
||||
+ } else {
|
||||
@@ -3512,6 +3516,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper start - Adventure
|
||||
+ @Override
|
||||
+ public void playSound(final net.kyori.adventure.sound.Sound sound) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
||||
+ final long seed = sound.seed().orElseGet(this.world.getRandom()::nextLong);
|
||||
+ for (ServerPlayer player : this.getHandle().players()) {
|
||||
+ player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player.getX(), player.getY(), player.getZ(), seed, null));
|
||||
@@ -3520,11 +3525,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public void playSound(final net.kyori.adventure.sound.Sound sound, final double x, final double y, final double z) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
||||
+ io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, x, y, z, sound.seed().orElseGet(this.world.getRandom()::nextLong), this.playSound0(x, y, z));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void playSound(final net.kyori.adventure.sound.Sound sound, final net.kyori.adventure.sound.Sound.Emitter emitter) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper
|
||||
+ final long seed = sound.seed().orElseGet(this.getHandle().getRandom()::nextLong);
|
||||
+ if (emitter == net.kyori.adventure.sound.Sound.Emitter.self()) {
|
||||
+ for (ServerPlayer player : this.getHandle().players()) {
|
||||
|
Reference in New Issue
Block a user