remove chatplayer instnaces
This commit is contained in:
parent
c1db6c1e39
commit
f5066d4a9e
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +1,46 @@
|
||||||
package com.alttd.chat.handlers;
|
package com.alttd.chat.handlers;
|
||||||
|
|
||||||
import com.alttd.chat.VelocityChat;
|
|
||||||
import com.alttd.chat.api.PrivateMessageEvent;
|
import com.alttd.chat.api.PrivateMessageEvent;
|
||||||
import com.alttd.chat.config.Config;
|
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.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
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.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ChatHandler {
|
public class ChatHandler {
|
||||||
|
|
||||||
private List<ChatPlayer> chatPlayers;
|
private List<ChatUser> chatUsers;
|
||||||
|
|
||||||
public ChatHandler() {
|
public ChatHandler() {
|
||||||
chatPlayers = new ArrayList<>();
|
chatUsers = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(ChatPlayer chatPlayer) {
|
public void addPlayer(ChatUser chatuser) {
|
||||||
chatPlayers.add(chatPlayer);
|
chatUsers.add(chatuser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(ChatPlayer chatPlayer) {
|
public void removePlayer(ChatUser chatUser) {
|
||||||
if(chatPlayer != null)
|
if(chatUser != null)
|
||||||
chatPlayers.remove(chatPlayer);
|
chatUsers.remove(chatUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(UUID uuid) {
|
public void removePlayer(UUID uuid) {
|
||||||
removePlayer(getChatPlayer(uuid));
|
removePlayer(getChatUser(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatPlayer getChatPlayer(UUID uuid) {
|
public ChatUser getChatUser(UUID uuid) {
|
||||||
for(ChatPlayer p: chatPlayers) {
|
for(ChatUser p: chatUsers) {
|
||||||
if(p.getUuid() == uuid)
|
if(p.getUuid() == uuid)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChatPlayer> getChatPlayers() {
|
public List<ChatUser> getChatPlayers() {
|
||||||
return Collections.unmodifiableList(chatPlayers);
|
return Collections.unmodifiableList(chatUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void privateMessage(PrivateMessageEvent event) {
|
public void privateMessage(PrivateMessageEvent event) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import com.alttd.chat.VelocityChat;
|
||||||
import com.alttd.chat.config.Config;
|
import com.alttd.chat.config.Config;
|
||||||
import com.alttd.chat.data.ServerWrapper;
|
import com.alttd.chat.data.ServerWrapper;
|
||||||
import com.alttd.chat.handlers.ServerHandler;
|
import com.alttd.chat.handlers.ServerHandler;
|
||||||
import com.alttd.chat.objects.ChatPlayer;
|
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
|
|
@ -22,12 +21,14 @@ public class ProxyPlayerListener {
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
public void onPlayerLogin(LoginEvent event) {
|
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
|
@Subscribe
|
||||||
public void quitEvent(DisconnectEvent event) {
|
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
|
// Server Join and Leave messages
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user