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
193 lines
6.7 KiB
Java
193 lines
6.7 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* javax.annotation.Nullable
|
|
*/
|
|
package de.maxhenkel.voicechat.plugins.impl.packets;
|
|
|
|
import de.maxhenkel.voicechat.api.Position;
|
|
import de.maxhenkel.voicechat.api.packets.ConvertablePacket;
|
|
import de.maxhenkel.voicechat.api.packets.EntitySoundPacket;
|
|
import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket;
|
|
import de.maxhenkel.voicechat.api.packets.SoundPacket;
|
|
import de.maxhenkel.voicechat.api.packets.StaticSoundPacket;
|
|
import de.maxhenkel.voicechat.plugins.impl.PositionImpl;
|
|
import de.maxhenkel.voicechat.plugins.impl.packets.EntitySoundPacketImpl;
|
|
import de.maxhenkel.voicechat.plugins.impl.packets.LocationalSoundPacketImpl;
|
|
import de.maxhenkel.voicechat.plugins.impl.packets.StaticSoundPacketImpl;
|
|
import de.maxhenkel.voicechat.voice.common.GroupSoundPacket;
|
|
import de.maxhenkel.voicechat.voice.common.LocationSoundPacket;
|
|
import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket;
|
|
import de.maxhenkel.voicechat.voice.common.Utils;
|
|
import java.util.UUID;
|
|
import javax.annotation.Nullable;
|
|
|
|
public class ConvertablePacketImpl
|
|
implements ConvertablePacket {
|
|
@Override
|
|
public EntitySoundPacket.Builder<?> entitySoundPacketBuilder() {
|
|
return new GenericEntitySoundPacketBuilder();
|
|
}
|
|
|
|
@Override
|
|
public LocationalSoundPacket.Builder<?> locationalSoundPacketBuilder() {
|
|
return new GenericLocationalSoundPacketBuilder();
|
|
}
|
|
|
|
@Override
|
|
public StaticSoundPacket.Builder<?> staticSoundPacketBuilder() {
|
|
return new GenericStaticSoundPacketBuilder();
|
|
}
|
|
|
|
@Override
|
|
public EntitySoundPacket toEntitySoundPacket(UUID entityUuid, boolean whispering) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public LocationalSoundPacket toLocationalSoundPacket(Position position) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override
|
|
public StaticSoundPacket toStaticSoundPacket() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public static class GenericEntitySoundPacketBuilder
|
|
extends GenericSoundPacketBuilder<GenericEntitySoundPacketBuilder, EntitySoundPacket>
|
|
implements EntitySoundPacket.Builder<GenericEntitySoundPacketBuilder> {
|
|
protected UUID entityUuid;
|
|
protected boolean whispering;
|
|
protected Float distance;
|
|
|
|
@Override
|
|
public GenericEntitySoundPacketBuilder entityUuid(UUID entityUuid) {
|
|
this.entityUuid = entityUuid;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public GenericEntitySoundPacketBuilder whispering(boolean whispering) {
|
|
this.whispering = whispering;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public GenericEntitySoundPacketBuilder distance(float distance) {
|
|
this.distance = Float.valueOf(distance);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public EntitySoundPacket build() {
|
|
this.checkRequiredFields();
|
|
if (this.entityUuid == null) {
|
|
throw new IllegalStateException("Entity UUID must be set");
|
|
}
|
|
if (this.distance == null) {
|
|
this.distance = Float.valueOf(Utils.getDefaultDistance());
|
|
}
|
|
return new EntitySoundPacketImpl(new PlayerSoundPacket(this.channelId, this.entityUuid, this.opusEncodedData, this.sequenceNumber, this.whispering, this.distance.floatValue(), this.category));
|
|
}
|
|
}
|
|
|
|
public static class GenericLocationalSoundPacketBuilder
|
|
extends GenericSoundPacketBuilder<GenericLocationalSoundPacketBuilder, LocationalSoundPacket>
|
|
implements LocationalSoundPacket.Builder<GenericLocationalSoundPacketBuilder> {
|
|
protected PositionImpl position;
|
|
protected Float distance;
|
|
|
|
@Override
|
|
public GenericLocationalSoundPacketBuilder position(Position position) {
|
|
this.position = (PositionImpl)position;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public GenericLocationalSoundPacketBuilder distance(float distance) {
|
|
this.distance = Float.valueOf(distance);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public LocationalSoundPacket build() {
|
|
this.checkRequiredFields();
|
|
if (this.position == null) {
|
|
throw new IllegalStateException("Position must be set");
|
|
}
|
|
if (this.distance == null) {
|
|
this.distance = Float.valueOf(Utils.getDefaultDistance());
|
|
}
|
|
return new LocationalSoundPacketImpl(new LocationSoundPacket(this.channelId, this.sender, this.position.getPosition(), this.opusEncodedData, this.sequenceNumber, this.distance.floatValue(), this.category));
|
|
}
|
|
}
|
|
|
|
public static class GenericStaticSoundPacketBuilder
|
|
extends GenericSoundPacketBuilder<GenericStaticSoundPacketBuilder, StaticSoundPacket>
|
|
implements StaticSoundPacket.Builder<GenericStaticSoundPacketBuilder> {
|
|
@Override
|
|
public StaticSoundPacket build() {
|
|
return new StaticSoundPacketImpl(new GroupSoundPacket(this.channelId, this.sender, this.opusEncodedData, this.sequenceNumber, this.category));
|
|
}
|
|
}
|
|
|
|
public static abstract class GenericSoundPacketBuilder<T extends SoundPacket.Builder<T, P>, P extends SoundPacket>
|
|
implements SoundPacket.Builder<T, P> {
|
|
@Nullable
|
|
protected UUID channelId;
|
|
@Nullable
|
|
protected UUID sender;
|
|
@Nullable
|
|
protected byte[] opusEncodedData;
|
|
@Nullable
|
|
protected Long sequenceNumber;
|
|
@Nullable
|
|
protected String category;
|
|
|
|
@Override
|
|
public T channelId(UUID channelId) {
|
|
this.channelId = channelId;
|
|
return (T)this;
|
|
}
|
|
|
|
@Override
|
|
public T sender(UUID sender) {
|
|
this.sender = sender;
|
|
return (T)this;
|
|
}
|
|
|
|
@Override
|
|
public T opusEncodedData(byte[] data) {
|
|
this.opusEncodedData = data;
|
|
return (T)this;
|
|
}
|
|
|
|
@Override
|
|
public T sequenceNumber(long sequenceNumber) {
|
|
this.sequenceNumber = sequenceNumber;
|
|
return (T)this;
|
|
}
|
|
|
|
@Override
|
|
public T category(@Nullable String category) {
|
|
this.category = category;
|
|
return (T)this;
|
|
}
|
|
|
|
public void checkRequiredFields() {
|
|
if (this.channelId == null) {
|
|
throw new IllegalStateException("Channel id must be set");
|
|
}
|
|
if (this.sequenceNumber == null) {
|
|
throw new IllegalStateException("Sequence number must be set");
|
|
}
|
|
if (this.opusEncodedData == null) {
|
|
throw new IllegalStateException("Opus encoded data must be set");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|