Finished party command, and sub commands

This commit is contained in:
2021-08-08 11:36:06 +02:00
parent 0932bf8d51
commit 2cb843b68c
18 changed files with 462 additions and 142 deletions
@@ -3,9 +3,12 @@ package com.alttd.chat.handlers;
import com.alttd.chat.VelocityChat;
import com.alttd.chat.config.Config;
import com.alttd.chat.managers.ChatUserManager;
import com.alttd.chat.managers.PartyManager;
import com.alttd.chat.managers.RegexManager;
import com.alttd.chat.objects.ChatUser;
import com.alttd.chat.objects.Mail;
import com.alttd.chat.objects.Party;
import com.alttd.chat.util.ALogger;
import com.alttd.chat.util.Utility;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@@ -142,4 +145,17 @@ public class ChatHandler {
}
public void partyChat(String partyId, UUID uuid, Component message) {
Party party = PartyManager.getParty(Integer.parseInt(partyId));
if (party == null) {
ALogger.warn("Received a non existent party");
return;
}
List<UUID> ignoredPlayers = ChatUserManager.getChatUser(uuid).getIgnoredPlayers();
List<UUID> partyUsersUuid = party.getPartyUsersUuid();
VelocityChat.getPlugin().getProxy().getAllPlayers().stream()
.filter(p -> partyUsersUuid.contains(p.getUniqueId()))
.filter(p -> !ignoredPlayers.contains(p.getUniqueId()))
.forEach(p -> p.sendMessage(message));
}
}
@@ -1,10 +1,9 @@
package com.alttd.chat.listeners;
import com.alttd.chat.VelocityChat;
import com.alttd.chat.objects.Channel;
import com.alttd.chat.objects.channels.CustomChannel;
import com.alttd.chat.util.ALogger;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
@@ -15,7 +14,6 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import java.util.Optional;
import java.util.UUID;
public class PluginMessageListener {
@@ -52,7 +50,7 @@ public class PluginMessageListener {
break;
case "chatchannel": {
String channelName = in.readUTF();
Channel chatChannel = Channel.getChatChannel(channelName);
CustomChannel chatChannel = (CustomChannel) CustomChannel.getChatChannel(channelName);
if (chatChannel == null) {
ALogger.warn("Received non existent channel" + channelName +".");
@@ -64,6 +62,10 @@ public class PluginMessageListener {
registeredServer.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), event.getData())));
break;
}
case "party": {
VelocityChat.getPlugin().getChatHandler().partyChat(in.readUTF(), UUID.fromString(in.readUTF()), GsonComponentSerializer.gson().deserialize(in.readUTF()));
break;
}
default:
VelocityChat.getPlugin().getLogger().info("server " + event.getSource());
ProxyServer proxy = VelocityChat.getPlugin().getProxy();