first commit
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
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
This commit is contained in:
commit
bbccd4a815
454 files changed
+45050
No files matched your search
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.annotation.Nullable
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.audiochannel;
|
||||
|
||||
import de.maxhenkel.voicechat.api.ServerPlayer;
|
||||
import de.maxhenkel.voicechat.api.audiochannel.AudioChannel;
|
||||
import de.maxhenkel.voicechat.voice.server.Server;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class AudioChannelImpl
|
||||
implements AudioChannel {
|
||||
protected UUID channelId;
|
||||
protected Server server;
|
||||
protected AtomicLong sequenceNumber;
|
||||
@Nullable
|
||||
protected Predicate<ServerPlayer> filter;
|
||||
@Nullable
|
||||
protected String category;
|
||||
|
||||
public AudioChannelImpl(UUID channelId, Server server) {
|
||||
this.channelId = channelId;
|
||||
this.server = server;
|
||||
this.sequenceNumber = new AtomicLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilter(Predicate<ServerPlayer> filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return this.channelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return this.server.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategory(@Nullable String category) {
|
||||
this.category = category;
|
||||
}
|
||||
}
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.annotation.Nonnull
|
||||
* javax.annotation.Nullable
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.audiochannel;
|
||||
|
||||
import de.maxhenkel.voicechat.Voicechat;
|
||||
import de.maxhenkel.voicechat.api.audiochannel.AudioChannel;
|
||||
import de.maxhenkel.voicechat.api.audiochannel.AudioPlayer;
|
||||
import de.maxhenkel.voicechat.api.opus.OpusEncoder;
|
||||
import de.maxhenkel.voicechat.debug.VoicechatUncaughtExceptionHandler;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AudioPlayerImpl
|
||||
extends Thread
|
||||
implements AudioPlayer {
|
||||
private static final long FRAME_SIZE_NS = 20000000L;
|
||||
public static final int FRAME_SIZE = 960;
|
||||
private final AudioChannel audioChannel;
|
||||
private final OpusEncoder encoder;
|
||||
private final Supplier<short[]> audioSupplier;
|
||||
private boolean started;
|
||||
@Nullable
|
||||
private Runnable onStopped;
|
||||
|
||||
public AudioPlayerImpl(AudioChannel audioChannel, @Nonnull OpusEncoder encoder, Supplier<short[]> audioSupplier) {
|
||||
this.audioChannel = audioChannel;
|
||||
this.encoder = encoder;
|
||||
this.audioSupplier = audioSupplier;
|
||||
this.setDaemon(true);
|
||||
this.setName(String.format("AudioPlayer-%s", audioChannel.getId()));
|
||||
this.setUncaughtExceptionHandler(new VoicechatUncaughtExceptionHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPlaying() {
|
||||
if (this.started) {
|
||||
return;
|
||||
}
|
||||
this.start();
|
||||
this.started = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopPlaying() {
|
||||
this.interrupt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlaying() {
|
||||
return this.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStopped() {
|
||||
return this.started && !this.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStopped(Runnable onStopped) {
|
||||
this.onStopped = onStopped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
short[] frame;
|
||||
int framePosition = 0;
|
||||
long startTime = System.nanoTime();
|
||||
while ((frame = this.audioSupplier.get()) != null) {
|
||||
if (frame.length != 960) {
|
||||
Voicechat.LOGGER.error("Got invalid audio frame size {}!={}", frame.length, 960);
|
||||
break;
|
||||
}
|
||||
this.audioChannel.send(this.encoder.encode(frame));
|
||||
long waitTimestamp = startTime + (long)(++framePosition) * 20000000L;
|
||||
long waitNanos = waitTimestamp - System.nanoTime();
|
||||
try {
|
||||
if (waitNanos <= 0L) continue;
|
||||
Thread.sleep(waitNanos / 1000000L, (int)(waitNanos % 1000000L));
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.encoder.close();
|
||||
this.audioChannel.flush();
|
||||
if (this.onStopped != null) {
|
||||
this.onStopped.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.audiochannel;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class AudioSupplier
|
||||
implements Supplier<short[]> {
|
||||
private final short[] audioData;
|
||||
private final short[] frame;
|
||||
private int framePosition;
|
||||
|
||||
public AudioSupplier(short[] audioData) {
|
||||
this.audioData = audioData;
|
||||
this.frame = new short[960];
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[] get() {
|
||||
if (this.framePosition >= this.audioData.length) {
|
||||
return null;
|
||||
}
|
||||
Arrays.fill(this.frame, (short)0);
|
||||
System.arraycopy(this.audioData, this.framePosition, this.frame, 0, Math.min(this.frame.length, this.audioData.length - this.framePosition));
|
||||
this.framePosition += this.frame.length;
|
||||
return this.frame;
|
||||
}
|
||||
}
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.bukkit.World
|
||||
* org.bukkit.entity.Player
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.audiochannel;
|
||||
|
||||
import de.maxhenkel.voicechat.api.Position;
|
||||
import de.maxhenkel.voicechat.api.ServerLevel;
|
||||
import de.maxhenkel.voicechat.api.audiochannel.LocationalAudioChannel;
|
||||
import de.maxhenkel.voicechat.api.packets.MicrophonePacket;
|
||||
import de.maxhenkel.voicechat.plugins.impl.PositionImpl;
|
||||
import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl;
|
||||
import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioChannelImpl;
|
||||
import de.maxhenkel.voicechat.voice.common.LocationSoundPacket;
|
||||
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.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LocationalAudioChannelImpl
|
||||
extends AudioChannelImpl
|
||||
implements LocationalAudioChannel {
|
||||
protected ServerLevel level;
|
||||
protected PositionImpl position;
|
||||
protected float distance;
|
||||
|
||||
public LocationalAudioChannelImpl(UUID channelId, Server server, ServerLevel level, PositionImpl position) {
|
||||
super(channelId, server);
|
||||
this.level = level;
|
||||
this.position = position;
|
||||
this.distance = Utils.getDefaultDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Position position) {
|
||||
if (!(position instanceof PositionImpl)) {
|
||||
throw new IllegalArgumentException("position is not an instance of PositionImpl");
|
||||
}
|
||||
this.position = (PositionImpl)position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getLocation() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
@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 LocationSoundPacket(this.channelId, this.channelId, this.position.getPosition(), opusData, this.sequenceNumber.getAndIncrement(), this.distance, this.category));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(MicrophonePacket packet) {
|
||||
this.send(packet.getOpusEncodedData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
this.broadcast(new LocationSoundPacket(this.channelId, this.channelId, this.position.getPosition(), new byte[0], this.sequenceNumber.getAndIncrement(), this.distance, this.category));
|
||||
}
|
||||
|
||||
private void broadcast(LocationSoundPacket packet) {
|
||||
this.server.broadcast(ServerPlayerManager.getPlayersInRange((World)this.level.getServerLevel(), this.position.getPosition(), this.server.getBroadcastRange(this.distance), this.filter == null ? null : player -> this.filter.test(new ServerPlayerImpl((Player)player))), packet, null, null, null, "plugin");
|
||||
}
|
||||
}
|
||||
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.bukkit.Bukkit
|
||||
* org.bukkit.entity.Player
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.audiochannel;
|
||||
|
||||
import de.maxhenkel.voicechat.api.VoicechatConnection;
|
||||
import de.maxhenkel.voicechat.api.audiochannel.StaticAudioChannel;
|
||||
import de.maxhenkel.voicechat.api.packets.MicrophonePacket;
|
||||
import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl;
|
||||
import de.maxhenkel.voicechat.plugins.impl.VoicechatServerApiImpl;
|
||||
import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioChannelImpl;
|
||||
import de.maxhenkel.voicechat.voice.common.GroupSoundPacket;
|
||||
import de.maxhenkel.voicechat.voice.server.ClientConnection;
|
||||
import de.maxhenkel.voicechat.voice.server.Group;
|
||||
import de.maxhenkel.voicechat.voice.server.Server;
|
||||
import de.maxhenkel.voicechat.voice.server.ServerGroupManager;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class StaticAudioChannelImpl
|
||||
extends AudioChannelImpl
|
||||
implements StaticAudioChannel {
|
||||
protected boolean bypassGroupIsolation;
|
||||
protected final Set<UUID> targets = new HashSet<UUID>();
|
||||
|
||||
public StaticAudioChannelImpl(UUID channelId, Server server) {
|
||||
super(channelId, server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(byte[] opusData) {
|
||||
this.broadcast(new GroupSoundPacket(this.channelId, this.channelId, opusData, this.sequenceNumber.getAndIncrement(), this.category));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(MicrophonePacket packet) {
|
||||
this.send(packet.getOpusEncodedData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
GroupSoundPacket packet = new GroupSoundPacket(this.channelId, this.channelId, new byte[0], this.sequenceNumber.getAndIncrement(), this.category);
|
||||
this.broadcast(packet);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
private void broadcast(GroupSoundPacket packet) {
|
||||
Set<UUID> set = this.targets;
|
||||
synchronized (set) {
|
||||
ServerGroupManager groupManager = this.server.getGroupManager();
|
||||
for (UUID target : this.targets) {
|
||||
Group playerGroup;
|
||||
Player player;
|
||||
ClientConnection connection = this.server.getConnection(target);
|
||||
if (connection == null || (player = Bukkit.getPlayer((UUID)target)) == null || !this.bypassGroupIsolation && (playerGroup = groupManager.getPlayerGroup(player)) != null && playerGroup.isIsolated() || this.filter != null && !this.filter.test(new ServerPlayerImpl(player))) continue;
|
||||
VoicechatServerApiImpl.sendPacket(player, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBypassGroupIsolation(boolean bypassGroupIsolation) {
|
||||
this.bypassGroupIsolation = bypassGroupIsolation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bypassesGroupIsolation() {
|
||||
return this.bypassGroupIsolation;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public void addTarget(VoicechatConnection target) {
|
||||
Set<UUID> set = this.targets;
|
||||
synchronized (set) {
|
||||
this.targets.add(target.getPlayer().getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public void removeTarget(VoicechatConnection target) {
|
||||
Set<UUID> set = this.targets;
|
||||
synchronized (set) {
|
||||
this.targets.remove(target.getPlayer().getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
@Override
|
||||
public void clearTargets() {
|
||||
Set<UUID> set = this.targets;
|
||||
synchronized (set) {
|
||||
this.targets.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user