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
82 lines
2.9 KiB
Java
82 lines
2.9 KiB
Java
/*
|
|
* 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");
|
|
}
|
|
}
|
|
|