Only clone sounds when needed, minor cleanup. Thanks again Jok on discord for pointing this out!
This commit is contained in:
parent
90f23f92d3
commit
e7b370733f
@ -38,17 +38,9 @@ public class PacketListenerSounds extends PacketAdapter {
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
if (event.isCancelled() || event.isAsync() || event.isPlayerTemporary()) {
|
||||
return;
|
||||
}
|
||||
if (event.isAsync()) {
|
||||
return;
|
||||
}
|
||||
if (event.getPlayer().getName().contains("UNKNOWN[")) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setPacket(event.getPacket().shallowClone());
|
||||
|
||||
if (event.getPacketType() == Server.ENTITY_STATUS) {
|
||||
handleEntityStatus(event);
|
||||
@ -106,6 +98,7 @@ public class PacketListenerSounds extends PacketAdapter {
|
||||
soundType = SoundType.DEATH;
|
||||
}
|
||||
}
|
||||
|
||||
if (disguise != null) {
|
||||
break;
|
||||
}
|
||||
@ -169,6 +162,9 @@ public class PacketListenerSounds extends PacketAdapter {
|
||||
|
||||
event.setPacket(newPacket);
|
||||
} else {
|
||||
event.setPacket(event.getPacket().shallowClone());
|
||||
mods = event.getPacket().getModifier();
|
||||
|
||||
mods.write(0, sound);
|
||||
mods.write(1, soundCat);
|
||||
mods.write(5, volume);
|
||||
@ -214,6 +210,7 @@ public class PacketListenerSounds extends PacketAdapter {
|
||||
if (entity == event.getPlayer() && !disguise.getType().isPlayer()) {
|
||||
if (!disguise.isSelfDisguiseSoundsReplaced()) {
|
||||
cancelSound = !cancelSound;
|
||||
|
||||
if (cancelSound) {
|
||||
return;
|
||||
}
|
||||
@ -226,17 +223,21 @@ public class PacketListenerSounds extends PacketAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (disSound.getSound(soundType) != null) {
|
||||
Object sound = disSound.getSound(soundType);
|
||||
|
||||
if (sound == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
disSound = SoundGroup.getGroup(disguise);
|
||||
|
||||
if (disSound != null) {
|
||||
Object sound = disSound.getSound(soundType);
|
||||
if (disSound == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sound != null) {
|
||||
Location loc = entity.getLocation();
|
||||
PacketContainer packet = new PacketContainer(
|
||||
sound.getClass().getSimpleName().equals("MinecraftKey") ? Server.CUSTOM_SOUND_EFFECT : Server.NAMED_SOUND_EFFECT);
|
||||
PacketContainer packet =
|
||||
new PacketContainer(sound.getClass().getSimpleName().equals("MinecraftKey") ? Server.CUSTOM_SOUND_EFFECT : Server.NAMED_SOUND_EFFECT);
|
||||
|
||||
mods = packet.getModifier();
|
||||
|
||||
@ -268,6 +269,3 @@ public class PacketListenerSounds extends PacketAdapter {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user