remove chatplayer instnaces

This commit is contained in:
len 2021-05-15 13:31:53 +02:00
parent c1db6c1e39
commit f5066d4a9e
3 changed files with 17 additions and 57 deletions

View File

@ -1,36 +0,0 @@
package com.alttd.chat.objects;
import java.util.UUID;
public class ChatPlayer {
// todo merge partyuser here, or make party user extend this?
// todo gctoggle?
// todo cache prefixes?
private UUID uuid;
private UUID replyTarget;
private boolean globalChatEnabled; // this vs permission?
public ChatPlayer(UUID p) {
uuid = p;
replyTarget = null;
}
public UUID getUuid() {
return uuid;
}
public boolean isGlobalChatEnabled() {
return globalChatEnabled;
}
public UUID getReplyTarget() {
return replyTarget;
}
public void setReplyTarget(UUID uuid) {
if (!replyTarget.equals(uuid))
replyTarget = uuid;
}
}

View File

@ -1,51 +1,46 @@
package com.alttd.chat.handlers;
import com.alttd.chat.VelocityChat;
import com.alttd.chat.api.PrivateMessageEvent;
import com.alttd.chat.config.Config;
import com.alttd.chat.objects.ChatPlayer;
import com.alttd.chat.objects.ChatUser;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.group.Group;
import net.luckperms.api.model.user.User;
import java.util.*;
public class ChatHandler {
private List<ChatPlayer> chatPlayers;
private List<ChatUser> chatUsers;
public ChatHandler() {
chatPlayers = new ArrayList<>();
chatUsers = new ArrayList<>();
}
public void addPlayer(ChatPlayer chatPlayer) {
chatPlayers.add(chatPlayer);
public void addPlayer(ChatUser chatuser) {
chatUsers.add(chatuser);
}
public void removePlayer(ChatPlayer chatPlayer) {
if(chatPlayer != null)
chatPlayers.remove(chatPlayer);
public void removePlayer(ChatUser chatUser) {
if(chatUser != null)
chatUsers.remove(chatUser);
}
public void removePlayer(UUID uuid) {
removePlayer(getChatPlayer(uuid));
removePlayer(getChatUser(uuid));
}
public ChatPlayer getChatPlayer(UUID uuid) {
for(ChatPlayer p: chatPlayers) {
public ChatUser getChatUser(UUID uuid) {
for(ChatUser p: chatUsers) {
if(p.getUuid() == uuid)
return p;
}
return null;
}
public List<ChatPlayer> getChatPlayers() {
return Collections.unmodifiableList(chatPlayers);
public List<ChatUser> getChatPlayers() {
return Collections.unmodifiableList(chatUsers);
}
public void privateMessage(PrivateMessageEvent event) {

View File

@ -4,7 +4,6 @@ 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.objects.ChatPlayer;
import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
@ -22,12 +21,14 @@ public class ProxyPlayerListener {
@Subscribe(order = PostOrder.FIRST)
public void onPlayerLogin(LoginEvent event) {
VelocityChat.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer().getUniqueId()));
// TODO setup ChatUser on Proxy
//VelocityChat.getPlugin().getChatHandler().addPlayer(new ChatPlayer(event.getPlayer().getUniqueId()));
}
@Subscribe
public void quitEvent(DisconnectEvent event) {
VelocityChat.getPlugin().getChatHandler().removePlayer(event.getPlayer().getUniqueId());
// TODO setup ChatUser on Proxy
//VelocityChat.getPlugin().getChatHandler().removePlayer(event.getPlayer().getUniqueId());
}
// Server Join and Leave messages