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

This commit is contained in:
asminme committed 2026-10-24 15:18:03 +02:00
commit bbccd4a815
454 files changed
+45050

No files matched your search

@@ -0,0 +1,44 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
public class AddCategoryPacket
implements Packet<AddCategoryPacket> {
public static final Key ADD_CATEGORY = Voicechat.compatibility.createNamespacedKey("add_category");
private VolumeCategoryImpl category;
public AddCategoryPacket() {
}
public AddCategoryPacket(VolumeCategoryImpl category) {
this.category = category;
}
public VolumeCategoryImpl getCategory() {
return this.category;
}
@Override
public Key getID() {
return ADD_CATEGORY;
}
@Override
public AddCategoryPacket fromBytes(FriendlyByteBuf buf) {
this.category = VolumeCategoryImpl.fromBytes(buf);
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
this.category.toBytes(buf);
}
}
@@ -0,0 +1,44 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import de.maxhenkel.voicechat.voice.common.ClientGroup;
public class AddGroupPacket
implements Packet<AddGroupPacket> {
public static final Key ADD_ADD_GROUP = Voicechat.compatibility.createNamespacedKey("add_group");
private ClientGroup group;
public AddGroupPacket() {
}
public AddGroupPacket(ClientGroup group) {
this.group = group;
}
public ClientGroup getGroup() {
return this.group;
}
@Override
public Key getID() {
return ADD_ADD_GROUP;
}
@Override
public AddGroupPacket fromBytes(FriendlyByteBuf buf) {
this.group = ClientGroup.fromBytes(buf);
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
this.group.toBytes(buf);
}
}
@@ -0,0 +1,80 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.api.Group;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.plugins.impl.GroupImpl;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import javax.annotation.Nullable;
import org.bukkit.entity.Player;
public class CreateGroupPacket
implements Packet<CreateGroupPacket> {
public static final Key CREATE_GROUP = Voicechat.compatibility.createNamespacedKey("create_group");
private String name;
@Nullable
private String password;
private Group.Type type;
public CreateGroupPacket() {
}
public CreateGroupPacket(String name, @Nullable String password, Group.Type type) {
this.name = name;
this.password = password;
this.type = type;
}
public String getName() {
return this.name;
}
@Nullable
public String getPassword() {
return this.password;
}
public Group.Type getType() {
return this.type;
}
@Override
public Key getID() {
return CREATE_GROUP;
}
@Override
public void onPacket(Player player) {
Voicechat.SERVER.getServer().getGroupManager().onCreateGroupPacket(player, this);
}
@Override
public CreateGroupPacket fromBytes(FriendlyByteBuf buf) {
this.name = buf.readUtf(24);
this.password = null;
if (buf.readBoolean()) {
this.password = buf.readUtf(24);
}
this.type = GroupImpl.TypeImpl.fromInt(buf.readShort());
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeUtf(this.name, 24);
buf.writeBoolean(this.password != null);
if (this.password != null) {
buf.writeUtf(this.password, 24);
}
buf.writeShort(GroupImpl.TypeImpl.toInt(this.type));
}
}
@@ -0,0 +1,70 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import java.util.UUID;
import javax.annotation.Nullable;
import org.bukkit.entity.Player;
public class JoinGroupPacket
implements Packet<JoinGroupPacket> {
public static final Key SET_GROUP = Voicechat.compatibility.createNamespacedKey("set_group");
private UUID group;
@Nullable
private String password;
public JoinGroupPacket() {
}
public JoinGroupPacket(UUID group, @Nullable String password) {
this.group = group;
this.password = password;
}
public UUID getGroup() {
return this.group;
}
@Nullable
public String getPassword() {
return this.password;
}
@Override
public Key getID() {
return SET_GROUP;
}
@Override
public void onPacket(Player player) {
Voicechat.SERVER.getServer().getGroupManager().onJoinGroupPacket(player, this);
}
@Override
public JoinGroupPacket fromBytes(FriendlyByteBuf buf) {
this.group = buf.readUUID();
if (buf.readBoolean()) {
this.password = buf.readUtf(512);
}
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeUUID(this.group);
buf.writeBoolean(this.password != null);
if (this.password != null) {
buf.writeUtf(this.password, 512);
}
}
}
@@ -0,0 +1,63 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import java.util.UUID;
import javax.annotation.Nullable;
public class JoinedGroupPacket
implements Packet<JoinedGroupPacket> {
public static final Key JOINED_GROUP = Voicechat.compatibility.createNamespacedKey("joined_group");
@Nullable
private UUID group;
private boolean wrongPassword;
public JoinedGroupPacket() {
}
public JoinedGroupPacket(@Nullable UUID group, boolean wrongPassword) {
this.group = group;
this.wrongPassword = wrongPassword;
}
@Nullable
public UUID getGroup() {
return this.group;
}
public boolean isWrongPassword() {
return this.wrongPassword;
}
@Override
public Key getID() {
return JOINED_GROUP;
}
@Override
public JoinedGroupPacket fromBytes(FriendlyByteBuf buf) {
if (buf.readBoolean()) {
this.group = buf.readUUID();
}
this.wrongPassword = buf.readBoolean();
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeBoolean(this.group != null);
if (this.group != null) {
buf.writeUUID(this.group);
}
buf.writeBoolean(this.wrongPassword);
}
}
@@ -0,0 +1,38 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import org.bukkit.entity.Player;
public class LeaveGroupPacket
implements Packet<LeaveGroupPacket> {
public static final Key LEAVE_GROUP = Voicechat.compatibility.createNamespacedKey("leave_group");
@Override
public Key getID() {
return LEAVE_GROUP;
}
@Override
public void onPacket(Player player) {
Voicechat.SERVER.getServer().getGroupManager().onLeaveGroupPacket(player, this);
}
@Override
public LeaveGroupPacket fromBytes(FriendlyByteBuf buf) {
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
}
}
@@ -0,0 +1,162 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* io.netty.buffer.Unpooled
* org.bukkit.Bukkit
* org.bukkit.entity.Player
* org.bukkit.event.EventHandler
* org.bukkit.event.Listener
* org.bukkit.event.player.PlayerJoinEvent
* org.bukkit.event.player.PlayerQuitEvent
* org.bukkit.plugin.Plugin
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.AddCategoryPacket;
import de.maxhenkel.voicechat.net.AddGroupPacket;
import de.maxhenkel.voicechat.net.CreateGroupPacket;
import de.maxhenkel.voicechat.net.JoinGroupPacket;
import de.maxhenkel.voicechat.net.JoinedGroupPacket;
import de.maxhenkel.voicechat.net.LeaveGroupPacket;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.net.PlayerStatePacket;
import de.maxhenkel.voicechat.net.PlayerStatesPacket;
import de.maxhenkel.voicechat.net.RemoveCategoryPacket;
import de.maxhenkel.voicechat.net.RemoveGroupPacket;
import de.maxhenkel.voicechat.net.RemovePlayerStatePacket;
import de.maxhenkel.voicechat.net.RequestSecretPacket;
import de.maxhenkel.voicechat.net.SecretPacket;
import de.maxhenkel.voicechat.net.UpdateStatePacket;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import io.netty.buffer.Unpooled;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
public class NetManager
implements Listener {
private final Set<String> packets = new HashSet<String>();
public void onEnable() {
this.packets.clear();
Bukkit.getPluginManager().registerEvents((Listener)this, (Plugin)Voicechat.INSTANCE);
try {
this.registerIncomingPacket(UpdateStatePacket.class);
this.registerIncomingPacket(RequestSecretPacket.class);
this.registerIncomingPacket(CreateGroupPacket.class);
this.registerIncomingPacket(JoinGroupPacket.class);
this.registerIncomingPacket(LeaveGroupPacket.class);
this.registerOutgoingPacket(SecretPacket.class);
this.registerOutgoingPacket(PlayerStatesPacket.class);
this.registerOutgoingPacket(PlayerStatePacket.class);
this.registerOutgoingPacket(RemovePlayerStatePacket.class);
this.registerOutgoingPacket(AddGroupPacket.class);
this.registerOutgoingPacket(RemoveGroupPacket.class);
this.registerOutgoingPacket(JoinedGroupPacket.class);
this.registerOutgoingPacket(AddCategoryPacket.class);
this.registerOutgoingPacket(RemoveCategoryPacket.class);
}
catch (Exception e) {
throw new IllegalStateException("Failed to register voice chat packets", e);
}
}
public void onDisable() {
Set incomingChannels = Bukkit.getMessenger().getIncomingChannels((Plugin)Voicechat.INSTANCE);
Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels((Plugin)Voicechat.INSTANCE);
for (String channel : incomingChannels) {
Bukkit.getMessenger().unregisterIncomingPluginChannel((Plugin)Voicechat.INSTANCE, channel);
}
for (String channel : outgoingChannels) {
Bukkit.getMessenger().unregisterOutgoingPluginChannel((Plugin)Voicechat.INSTANCE, channel);
}
this.packets.clear();
}
public Set<String> getPackets() {
return this.packets;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels((Plugin)Voicechat.INSTANCE);
for (String channel : outgoingChannels) {
Voicechat.compatibility.addChannel(event.getPlayer(), channel);
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels((Plugin)Voicechat.INSTANCE);
for (String channel : outgoingChannels) {
Voicechat.compatibility.removeChannel(event.getPlayer(), channel);
}
}
private <T extends Packet<?>> void registerIncomingPacket(Class<T> packetClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
Constructor c = packetClass.getDeclaredConstructor(new Class[0]);
String id = ((Packet)c.newInstance(new Object[0])).getID().toString();
this.packets.add(id);
Bukkit.getMessenger().registerIncomingPluginChannel((Plugin)Voicechat.INSTANCE, id, (s, player, bytes) -> {
Packet packet;
if (!Voicechat.SERVER.getRateLimiter().allow(player.getUniqueId())) {
Voicechat.LOGGER.warn("Player {} exceeded packet rate limit", player.getDisplayName());
player.kickPlayer(Voicechat.TRANSLATIONS.rateLimitKickMessage.get());
return;
}
try {
packet = (Packet)c.newInstance(new Object[0]);
}
catch (Exception e) {
Voicechat.LOGGER.error("Failed to create new packet instance of {}", packetClass.getSimpleName(), e);
return;
}
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer((byte[])bytes));
packet.fromBytes(buffer);
packet.onPacket(player);
});
}
private <T extends Packet<?>> void registerOutgoingPacket(Class<T> packetClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
String id = ((Packet)packetClass.getDeclaredConstructor(new Class[0]).newInstance(new Object[0])).getID().toString();
this.packets.add(id);
Bukkit.getMessenger().registerOutgoingPluginChannel((Plugin)Voicechat.INSTANCE, id);
}
public static void sendToClient(Player player, Packet<?> p) {
Voicechat.compatibility.runTask(() -> {
if (!Voicechat.SERVER.isCompatible(player)) {
return;
}
try {
FriendlyByteBuf buf = new FriendlyByteBuf();
p.toBytes(buf);
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
player.sendPluginMessage((Plugin)Voicechat.INSTANCE, p.getID().toString(), bytes);
}
catch (Exception e) {
Voicechat.LOGGER.error("Failed to send packet to '{}'", player.getName(), e);
}
});
}
public static void sendMessage(Player player, String key, String ... args) {
Voicechat.compatibility.sendTranslationMessage(player, key, args);
}
public static void sendStatusMessage(Player player, String key, String ... args) {
Voicechat.compatibility.sendStatusMessage(player, key, args);
}
}
@@ -0,0 +1,23 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import org.bukkit.entity.Player;
public interface Packet<T extends Packet> {
public Key getID();
public T fromBytes(FriendlyByteBuf var1);
public void toBytes(FriendlyByteBuf var1);
default public void onPacket(Player player) {
}
}
@@ -0,0 +1,66 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player;
public class PacketRateLimiter {
private final ConcurrentHashMap<UUID, RateLimiter> rateLimiters = new ConcurrentHashMap();
private final int maxPacketsPerSecond;
private final int timeWindowSeconds = 5;
public PacketRateLimiter(int maxPacketsPerSecond) {
this.maxPacketsPerSecond = maxPacketsPerSecond;
}
public boolean allow(UUID player) {
if (this.maxPacketsPerSecond <= 0) {
return true;
}
RateLimiter limiter = this.rateLimiters.computeIfAbsent(player, id -> new RateLimiter(this.maxPacketsPerSecond * 5, 5000L));
return limiter.tryAcquire();
}
public void onPlayerLoggedOut(Player player) {
this.rateLimiters.remove(player.getUniqueId());
}
private static class RateLimiter {
private final int threshold;
private final long timePerTokenNanos;
private long lastLeakNanos;
private long amount;
public RateLimiter(int threshold, long windowMillis) {
this.threshold = threshold;
this.timePerTokenNanos = windowMillis * 1000000L / (long)threshold;
this.lastLeakNanos = System.nanoTime();
this.amount = 0L;
}
public boolean tryAcquire() {
long currentTime = System.nanoTime();
long elapsed = currentTime - this.lastLeakNanos;
long leakedTokens = elapsed / this.timePerTokenNanos;
if (leakedTokens > 0L) {
this.amount -= leakedTokens;
if (this.amount < 0L) {
this.amount = 0L;
}
this.lastLeakNanos += leakedTokens * this.timePerTokenNanos;
}
if (this.amount >= (long)this.threshold) {
return false;
}
++this.amount;
return true;
}
}
}
@@ -0,0 +1,44 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import de.maxhenkel.voicechat.voice.common.PlayerState;
public class PlayerStatePacket
implements Packet<PlayerStatePacket> {
public static final Key PLAYER_STATE = Voicechat.compatibility.createNamespacedKey("state");
private PlayerState playerState;
public PlayerStatePacket() {
}
public PlayerStatePacket(PlayerState playerState) {
this.playerState = playerState;
}
public PlayerState getPlayerState() {
return this.playerState;
}
@Override
public Key getID() {
return PLAYER_STATE;
}
@Override
public PlayerStatePacket fromBytes(FriendlyByteBuf buf) {
this.playerState = PlayerState.fromBytes(buf);
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
this.playerState.toBytes(buf);
}
}
@@ -0,0 +1,54 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import de.maxhenkel.voicechat.voice.common.PlayerState;
import java.util.ArrayList;
import java.util.Collection;
public class PlayerStatesPacket
implements Packet<PlayerStatesPacket> {
public static final Key PLAYER_STATES = Voicechat.compatibility.createNamespacedKey("states");
private Collection<PlayerState> playerStates;
public PlayerStatesPacket() {
}
public PlayerStatesPacket(Collection<PlayerState> playerStates) {
this.playerStates = playerStates;
}
public Collection<PlayerState> getPlayerStates() {
return this.playerStates;
}
@Override
public Key getID() {
return PLAYER_STATES;
}
@Override
public PlayerStatesPacket fromBytes(FriendlyByteBuf buf) {
int count = buf.readInt();
this.playerStates = new ArrayList<PlayerState>(count);
for (int i = 0; i < count; ++i) {
PlayerState playerState = PlayerState.fromBytes(buf);
this.playerStates.add(playerState);
}
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeInt(this.playerStates.size());
for (PlayerState state : this.playerStates) {
state.toBytes(buf);
}
}
}
@@ -0,0 +1,43 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
public class RemoveCategoryPacket
implements Packet<RemoveCategoryPacket> {
public static final Key REMOVE_CATEGORY = Voicechat.compatibility.createNamespacedKey("remove_category");
private String categoryId;
public RemoveCategoryPacket() {
}
public RemoveCategoryPacket(String categoryId) {
this.categoryId = categoryId;
}
public String getCategoryId() {
return this.categoryId;
}
@Override
public Key getID() {
return REMOVE_CATEGORY;
}
@Override
public RemoveCategoryPacket fromBytes(FriendlyByteBuf buf) {
this.categoryId = buf.readUtf(16);
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeUtf(this.categoryId, 16);
}
}
@@ -0,0 +1,44 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import java.util.UUID;
public class RemoveGroupPacket
implements Packet<RemoveGroupPacket> {
public static final Key REMOVE_GROUP = Voicechat.compatibility.createNamespacedKey("remove_group");
private UUID groupId;
public RemoveGroupPacket() {
}
public RemoveGroupPacket(UUID groupId) {
this.groupId = groupId;
}
public UUID getGroupId() {
return this.groupId;
}
@Override
public Key getID() {
return REMOVE_GROUP;
}
@Override
public RemoveGroupPacket fromBytes(FriendlyByteBuf buf) {
this.groupId = buf.readUUID();
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeUUID(this.groupId);
}
}
@@ -0,0 +1,44 @@
/*
* Decompiled with CFR 0.152.
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import java.util.UUID;
public class RemovePlayerStatePacket
implements Packet<RemovePlayerStatePacket> {
public static final Key REMOVE_PLAYER_STATE = Voicechat.compatibility.createNamespacedKey("remove_state");
private UUID id;
public RemovePlayerStatePacket() {
}
public RemovePlayerStatePacket(UUID id) {
this.id = id;
}
public UUID getId() {
return this.id;
}
@Override
public Key getID() {
return REMOVE_PLAYER_STATE;
}
@Override
public RemovePlayerStatePacket fromBytes(FriendlyByteBuf buf) {
this.id = buf.readUUID();
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeUUID(this.id);
}
}
@@ -0,0 +1,52 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import org.bukkit.entity.Player;
public class RequestSecretPacket
implements Packet<RequestSecretPacket> {
public static final Key REQUEST_SECRET = Voicechat.compatibility.createNamespacedKey("request_secret");
private int compatibilityVersion;
public RequestSecretPacket() {
}
public RequestSecretPacket(int compatibilityVersion) {
this.compatibilityVersion = compatibilityVersion;
}
public int getCompatibilityVersion() {
return this.compatibilityVersion;
}
@Override
public Key getID() {
return REQUEST_SECRET;
}
@Override
public void onPacket(Player player) {
Voicechat.SERVER.onRequestSecretPacket(player, this);
}
@Override
public RequestSecretPacket fromBytes(FriendlyByteBuf buf) {
this.compatibilityVersion = buf.readInt();
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeInt(this.compatibilityVersion);
}
}
@@ -0,0 +1,122 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.config.ServerConfig;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import de.maxhenkel.voicechat.voice.common.Secret;
import java.util.UUID;
import org.bukkit.entity.Player;
public class SecretPacket
implements Packet<SecretPacket> {
public static final Key SECRET = Voicechat.compatibility.createNamespacedKey("secret");
private Secret secret;
private int serverPort;
private UUID playerUUID;
private ServerConfig.Codec codec;
private int mtuSize;
private double voiceChatDistance;
private int keepAlive;
private boolean groupsEnabled;
private String voiceHost;
private boolean allowRecording;
public SecretPacket() {
}
public SecretPacket(Player player, Secret secret, int port, ServerConfig serverConfig, String voiceHost) {
this.secret = secret;
this.serverPort = port;
this.playerUUID = player.getUniqueId();
this.codec = serverConfig.voiceChatCodec.get();
this.mtuSize = serverConfig.voiceChatMtuSize.get();
this.voiceChatDistance = serverConfig.voiceChatDistance.get();
this.keepAlive = serverConfig.keepAlive.get();
this.groupsEnabled = serverConfig.groupsEnabled.get();
this.voiceHost = voiceHost;
this.allowRecording = serverConfig.allowRecording.get();
}
public Secret getSecret() {
return this.secret;
}
public int getServerPort() {
return this.serverPort;
}
public UUID getPlayerUUID() {
return this.playerUUID;
}
public ServerConfig.Codec getCodec() {
return this.codec;
}
public int getMtuSize() {
return this.mtuSize;
}
public double getVoiceChatDistance() {
return this.voiceChatDistance;
}
public int getKeepAlive() {
return this.keepAlive;
}
public boolean groupsEnabled() {
return this.groupsEnabled;
}
public String getVoiceHost() {
return this.voiceHost;
}
@Override
public Key getID() {
return SECRET;
}
public boolean allowRecording() {
return this.allowRecording;
}
@Override
public SecretPacket fromBytes(FriendlyByteBuf buf) {
this.secret = Secret.fromBytes(buf);
this.serverPort = buf.readInt();
this.playerUUID = buf.readUUID();
this.codec = ServerConfig.Codec.values()[buf.readByte()];
this.mtuSize = buf.readInt();
this.voiceChatDistance = buf.readDouble();
this.keepAlive = buf.readInt();
this.groupsEnabled = buf.readBoolean();
this.voiceHost = buf.readUtf();
this.allowRecording = buf.readBoolean();
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
this.secret.toBytes(buf);
buf.writeInt(this.serverPort);
buf.writeUUID(this.playerUUID);
buf.writeByte(this.codec.ordinal());
buf.writeInt(this.mtuSize);
buf.writeDouble(this.voiceChatDistance);
buf.writeInt(this.keepAlive);
buf.writeBoolean(this.groupsEnabled);
buf.writeUtf(this.voiceHost);
buf.writeBoolean(this.allowRecording);
}
}
@@ -0,0 +1,52 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.bukkit.entity.Player
*/
package de.maxhenkel.voicechat.net;
import de.maxhenkel.voicechat.Voicechat;
import de.maxhenkel.voicechat.net.Packet;
import de.maxhenkel.voicechat.util.FriendlyByteBuf;
import de.maxhenkel.voicechat.util.Key;
import org.bukkit.entity.Player;
public class UpdateStatePacket
implements Packet<UpdateStatePacket> {
public static final Key PLAYER_STATE = Voicechat.compatibility.createNamespacedKey("update_state");
private boolean disabled;
public UpdateStatePacket() {
}
public UpdateStatePacket(boolean disabled) {
this.disabled = disabled;
}
public boolean isDisabled() {
return this.disabled;
}
@Override
public Key getID() {
return PLAYER_STATE;
}
@Override
public void onPacket(Player player) {
Voicechat.SERVER.getServer().getPlayerStateManager().onUpdateStatePacket(player, this);
}
@Override
public UpdateStatePacket fromBytes(FriendlyByteBuf buf) {
this.disabled = buf.readBoolean();
return this;
}
@Override
public void toBytes(FriendlyByteBuf buf) {
buf.writeBoolean(this.disabled);
}
}