diff options
author | LukBukkit <luk.bukkit@gmail.com> | 2016-11-19 14:20:13 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-11-19 14:20:13 +1100 |
commit | 63c13c5e628eaa82fb95c5e21d8cc39f4b49ed42 (patch) | |
tree | ea7b7dd93ba943964787ad10f14c61b81e8cd53c /src | |
parent | 32048c46904db321719d30a9ed2312e361f8d889 (diff) | |
download | craftbukkit-63c13c5e628eaa82fb95c5e21d8cc39f4b49ed42.tar craftbukkit-63c13c5e628eaa82fb95c5e21d8cc39f4b49ed42.tar.gz craftbukkit-63c13c5e628eaa82fb95c5e21d8cc39f4b49ed42.tar.lz craftbukkit-63c13c5e628eaa82fb95c5e21d8cc39f4b49ed42.tar.xz craftbukkit-63c13c5e628eaa82fb95c5e21d8cc39f4b49ed42.zip |
Implement SoundCategory for playing sounds.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 21 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 26 |
2 files changed, 33 insertions, 14 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 260f72f7..3cbf09e6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1358,25 +1358,34 @@ public class CraftWorld implements World { ambientSpawn = limit; } - public void playSound(Location loc, Sound sound, float volume, float pitch) { - if (loc == null || sound == null) return; + playSound(loc, sound, org.bukkit.SoundCategory.MASTER, volume, pitch); + } + + public void playSound(Location loc, String sound, float volume, float pitch) { + playSound(loc, sound, org.bukkit.SoundCategory.MASTER, volume, pitch); + } + + @Override + public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { + if (loc == null || sound == null || category == null) return; double x = loc.getX(); double y = loc.getY(); double z = loc.getZ(); - getHandle().a(null, x, y, z, CraftSound.getSoundEffect(CraftSound.getSound(sound)), SoundCategory.MASTER, volume, pitch); // PAIL: rename + getHandle().a(null, x, y, z, CraftSound.getSoundEffect(CraftSound.getSound(sound)), SoundCategory.valueOf(category.name()), volume, pitch); // PAIL: rename } - public void playSound(Location loc, String sound, float volume, float pitch) { - if (loc == null || sound == null) return; + @Override + public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) { + if (loc == null || sound == null || category == null) return; double x = loc.getX(); double y = loc.getY(); double z = loc.getZ(); - PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, SoundCategory.MASTER, x, y, z, volume, pitch); + PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, SoundCategory.valueOf(category.name()), x, y, z, volume, pitch); world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension, packet); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index bdd1aa0e..1904fa72 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -265,7 +265,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D); - getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note." + instrumentName), SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); + getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note." + instrumentName), net.minecraft.server.SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); } @Override @@ -291,22 +291,32 @@ public class CraftPlayer extends CraftHumanEntity implements Player { break; } float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); - getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note." + instrumentName), SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); + getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note." + instrumentName), net.minecraft.server.SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); } @Override public void playSound(Location loc, Sound sound, float volume, float pitch) { - if (loc == null || sound == null || getHandle().playerConnection == null) return; + playSound(loc, sound, org.bukkit.SoundCategory.MASTER, volume, pitch); + } + + @Override + public void playSound(Location loc, String sound, float volume, float pitch) { + playSound(loc, sound, org.bukkit.SoundCategory.MASTER, volume, pitch); + } - PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(CraftSound.getSound(sound)), SoundCategory.MASTER, loc.getX(), loc.getY(), loc.getZ(), volume, pitch); + @Override + public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) { + if (loc == null || sound == null || category == null || getHandle().playerConnection == null) return; + + PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(CraftSound.getSound(sound)), net.minecraft.server.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch); getHandle().playerConnection.sendPacket(packet); } @Override - public void playSound(Location loc, String sound, float volume, float pitch) { - if (loc == null || sound == null || getHandle().playerConnection == null) return; + public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) { + if (loc == null || sound == null || category == null || getHandle().playerConnection == null) return; - PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, SoundCategory.MASTER, loc.getX(), loc.getY(), loc.getZ(), volume, pitch); + PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, net.minecraft.server.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch); getHandle().playerConnection.sendPacket(packet); } @@ -769,7 +779,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (event.isCancelled()) { return; } - + getHandle().setSpectatorTarget(getHandle()); getHandle().playerInteractManager.setGameMode(EnumGamemode.getById(mode.getValue())); getHandle().fallDistance = 0; |