/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.bukkit.entity.Entity * org.bukkit.entity.Player */ package de.maxhenkel.voicechat.plugins.impl.audiochannel; import de.maxhenkel.voicechat.api.Entity; import de.maxhenkel.voicechat.api.audiochannel.EntityAudioChannel; import de.maxhenkel.voicechat.api.packets.MicrophonePacket; import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioChannelImpl; import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; import de.maxhenkel.voicechat.voice.common.Utils; import de.maxhenkel.voicechat.voice.server.Server; import de.maxhenkel.voicechat.voice.server.ServerPlayerManager; import java.util.UUID; import org.bukkit.entity.Player; public class EntityAudioChannelImpl extends AudioChannelImpl implements EntityAudioChannel { protected Entity entity; protected boolean whispering; protected float distance; public EntityAudioChannelImpl(UUID channelId, Server server, Entity entity) { super(channelId, server); this.entity = entity; this.whispering = false; this.distance = Utils.getDefaultDistance(); } @Override public void setWhispering(boolean whispering) { this.whispering = whispering; } @Override public boolean isWhispering() { return this.whispering; } @Override public void updateEntity(Entity entity) { this.entity = entity; } @Override public Entity getEntity() { return this.entity; } @Override public float getDistance() { return this.distance; } @Override public void setDistance(float distance) { this.distance = distance; } @Override public void send(byte[] opusData) { this.broadcast(new PlayerSoundPacket(this.channelId, this.entity.getUuid(), opusData, this.sequenceNumber.getAndIncrement(), this.whispering, this.distance, this.category)); } @Override public void send(MicrophonePacket microphonePacket) { this.broadcast(new PlayerSoundPacket(this.channelId, this.entity.getUuid(), microphonePacket.getOpusEncodedData(), this.sequenceNumber.getAndIncrement(), this.whispering, this.distance, this.category)); } @Override public void flush() { this.broadcast(new PlayerSoundPacket(this.channelId, this.entity.getUuid(), new byte[0], this.sequenceNumber.getAndIncrement(), this.whispering, this.distance, this.category)); } private void broadcast(PlayerSoundPacket packet) { if (this.entity.getEntity() instanceof org.bukkit.entity.Entity) { org.bukkit.entity.Entity entity = (org.bukkit.entity.Entity)this.entity.getEntity(); this.server.broadcast(ServerPlayerManager.getPlayersInRange(entity.getWorld(), entity.getLocation(), this.server.getBroadcastRange(this.distance), this.filter == null ? null : player -> this.filter.test(new ServerPlayerImpl((Player)player))), packet, null, null, null, "plugin"); } } }