forked from ChomeNS/chomens-bot-java
remove from group
This commit is contained in:
parent
59a8b5dc2d
commit
cdb1a4a41d
2 changed files with 19 additions and 0 deletions
|
@ -2,9 +2,11 @@ package land.chipmunk.chayapak.chomens_bot.data.voiceChat;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.util.FriendlyByteBuf;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public record ClientGroup(UUID id, String name, boolean hasPassword, boolean persistent, GroupType type) {
|
||||
|
||||
public static ClientGroup fromBytes(FriendlyByteBuf buf) {
|
||||
return new ClientGroup(
|
||||
buf.readUUID(),
|
||||
|
@ -14,4 +16,13 @@ public record ClientGroup(UUID id, String name, boolean hasPassword, boolean per
|
|||
GroupType.values()[buf.readShort()]
|
||||
);
|
||||
}
|
||||
|
||||
public void toBytes(FriendlyByteBuf buf) {
|
||||
buf.writeUUID(id);
|
||||
buf.writeUtf(name, 512);
|
||||
buf.writeBoolean(hasPassword);
|
||||
buf.writeBoolean(persistent);
|
||||
buf.writeShort(Arrays.stream(GroupType.values()).toList().indexOf(type));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*;
|
|||
import java.net.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
// ALMOST ALL of these codes are from the simple voice chat mod itself including the other voicechat classes
|
||||
// mic packet exists but is never sent because i am too lazy to implement the player + evilbot already has a voicechat music player
|
||||
|
@ -117,6 +118,13 @@ public class VoiceChatPlugin extends Bot.Listener {
|
|||
final ClientGroup group = ClientGroup.fromBytes(buf);
|
||||
|
||||
groups.add(group);
|
||||
} else if (_packet.getChannel().equals("voicechat:remove_group")) {
|
||||
final byte[] bytes = _packet.getData();
|
||||
final FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
|
||||
|
||||
final UUID id = buf.readUUID();
|
||||
|
||||
groups.removeIf((group) -> group.id().equals(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue