Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
89 lines
3.0 KiB
Java
89 lines
3.0 KiB
Java
/*
|
|
* 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");
|
|
}
|
|
}
|
|
}
|
|
|