summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-11-19 14:27:18 +1100
committermd_5 <git@md-5.net>2016-11-19 14:27:18 +1100
commit7564d602419f10af5c1b5b1758eb0455250ea169 (patch)
treea86a09fee1b19eea07dfa8ccf7ba7278657065a6
parent63c13c5e628eaa82fb95c5e21d8cc39f4b49ed42 (diff)
downloadcraftbukkit-7564d602419f10af5c1b5b1758eb0455250ea169.tar
craftbukkit-7564d602419f10af5c1b5b1758eb0455250ea169.tar.gz
craftbukkit-7564d602419f10af5c1b5b1758eb0455250ea169.tar.lz
craftbukkit-7564d602419f10af5c1b5b1758eb0455250ea169.tar.xz
craftbukkit-7564d602419f10af5c1b5b1758eb0455250ea169.zip
Add stopSound for specific sound category & unit test for SoundCategory
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java14
-rw-r--r--src/test/java/org/bukkit/SoundTest.java14
2 files changed, 26 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 1904fa72..ab638ba7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -322,15 +322,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void stopSound(Sound sound) {
- stopSound(CraftSound.getSound(sound));
+ stopSound(sound, null);
}
@Override
public void stopSound(String sound) {
+ stopSound(sound, null);
+ }
+
+ @Override
+ public void stopSound(Sound sound, org.bukkit.SoundCategory category) {
+ stopSound(CraftSound.getSound(sound), category);
+ }
+
+ @Override
+ public void stopSound(String sound, org.bukkit.SoundCategory category) {
if (getHandle().playerConnection == null) return;
PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer());
- packetdataserializer.a("");
+ packetdataserializer.a(category == null ? "" : net.minecraft.server.SoundCategory.valueOf(category.name()).a());
packetdataserializer.a(sound);
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|StopSound", packetdataserializer));
}
diff --git a/src/test/java/org/bukkit/SoundTest.java b/src/test/java/org/bukkit/SoundTest.java
index 8bb093da..ea1d0c84 100644
--- a/src/test/java/org/bukkit/SoundTest.java
+++ b/src/test/java/org/bukkit/SoundTest.java
@@ -24,4 +24,18 @@ public class SoundTest {
assertNotNull(effect + "", Sound.valueOf(effect.a().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH)));
}
}
+
+ @Test
+ public void testCategory() {
+ for (SoundCategory category : SoundCategory.values()) {
+ assertNotNull(category + "", net.minecraft.server.SoundCategory.valueOf(category.name()));
+ }
+ }
+
+ @Test
+ public void testCategoryReverse() {
+ for (net.minecraft.server.SoundCategory category : net.minecraft.server.SoundCategory.values()) {
+ assertNotNull(category + "", SoundCategory.valueOf(category.name()));
+ }
+ }
}