mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 18:27:41 +01:00
Add stopSound for specific sound category & unit test for SoundCategory
By: md_5 <git@md-5.net>
This commit is contained in:
parent
de0b8db8ad
commit
38fb5c2469
@ -322,15 +322,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopSound(Sound sound) {
|
public void stopSound(Sound sound) {
|
||||||
stopSound(CraftSound.getSound(sound));
|
stopSound(sound, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopSound(String sound) {
|
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;
|
if (getHandle().playerConnection == null) return;
|
||||||
PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer());
|
PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer());
|
||||||
|
|
||||||
packetdataserializer.a("");
|
packetdataserializer.a(category == null ? "" : net.minecraft.server.SoundCategory.valueOf(category.name()).a());
|
||||||
packetdataserializer.a(sound);
|
packetdataserializer.a(sound);
|
||||||
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|StopSound", packetdataserializer));
|
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|StopSound", packetdataserializer));
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,18 @@ public class SoundTest {
|
|||||||
assertNotNull(effect + "", Sound.valueOf(effect.a().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH)));
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user