Merge branch 'main' of https://github.com/Altitude-Devs/Chat
This commit is contained in:
commit
e7072a409e
|
|
@ -45,7 +45,12 @@ public class PartyManager {
|
|||
}
|
||||
|
||||
public static Party getParty(UUID uuid) {
|
||||
return getParty(ChatUserManager.getChatUser(uuid).getPartyId());
|
||||
for(Party party : parties) {
|
||||
if(party.getPartyUsers().containsKey(uuid)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void loadParties() {
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ public class ChatParty implements CommandExecutor, TabCompleter {
|
|||
|
||||
sender.sendMessage(Utility.applyColor(stringBuilder.toString()));
|
||||
}
|
||||
// TODO: 08/08/2021 add a way to change the password and owner (and name?)
|
||||
default -> {
|
||||
helpMessage(sender);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.alttd.chat.ChatPlugin;
|
|||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.alttd.chat.objects.channels.Channel;
|
||||
import com.alttd.chat.objects.channels.CustomChannel;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
|
|
@ -11,6 +13,7 @@ import com.alttd.chat.util.ALogger;
|
|||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -84,6 +87,48 @@ public class PluginMessage implements PluginMessageListener {
|
|||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
break;
|
||||
}
|
||||
case "partylogin": {
|
||||
int id = Integer.parseInt(in.readUTF());
|
||||
Party party = PartyManager.getParty(id);
|
||||
if (party == null) {
|
||||
ALogger.warn("Received invalid party id.");
|
||||
return;
|
||||
}
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Component component = MiniMessage.get().parse("<dark_aqua>* " + party.getPartyUsers().get(uuid) + " logged onto the proxy.");
|
||||
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(p -> party.getPartyUsers().containsKey(p.getUniqueId()))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid))
|
||||
.forEach(p -> p.sendMessage(component));
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
break;
|
||||
}
|
||||
case "partylogout": {
|
||||
int id = Integer.parseInt(in.readUTF());
|
||||
Party party = PartyManager.getParty(id);
|
||||
if (party == null) {
|
||||
ALogger.warn("Received invalid party id.");
|
||||
return;
|
||||
}
|
||||
UUID uuid = UUID.fromString(in.readUTF());
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Component component = MiniMessage.get().parse("<dark_aqua>* " + party.getPartyUsers().get(uuid) + " logged out.");
|
||||
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.filter(p -> party.getPartyUsers().containsKey(p.getUniqueId()))
|
||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid))
|
||||
.forEach(p -> p.sendMessage(component));
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ import com.alttd.chat.VelocityChat;
|
|||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.data.ServerWrapper;
|
||||
import com.alttd.chat.handlers.ServerHandler;
|
||||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.Party;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
|
|
@ -16,17 +20,34 @@ import net.kyori.adventure.text.minimessage.Template;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProxyPlayerListener {
|
||||
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void onPlayerLogin(LoginEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
Party party = PartyManager.getParty(event.getPlayer().getUniqueId());
|
||||
if (party == null) return;
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("partylogin");
|
||||
out.writeUTF(String.valueOf(party.getPartyId()));
|
||||
out.writeUTF(uuid.toString());
|
||||
VelocityChat.getPlugin().getProxy().getAllServers().forEach(registeredServer -> registeredServer.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), out.toByteArray()));
|
||||
// TODO setup ChatUser on Proxy
|
||||
//VelocityChat.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer().getUniqueId()));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void quitEvent(DisconnectEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
Party party = PartyManager.getParty(event.getPlayer().getUniqueId());
|
||||
if (party == null) return;
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("partylogout");
|
||||
out.writeUTF(String.valueOf(party.getPartyId()));
|
||||
out.writeUTF(uuid.toString());
|
||||
VelocityChat.getPlugin().getProxy().getAllServers().forEach(registeredServer -> registeredServer.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), out.toByteArray()));
|
||||
// TODO setup ChatUser on Proxy
|
||||
//VelocityChat.getPlugin().getChatHandler().removePlayer(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user