2021-05-15 19:16:01 +00:00
|
|
|
package com.alttd.chat.managers;
|
|
|
|
|
|
|
|
|
|
import com.alttd.chat.database.Queries;
|
|
|
|
|
import com.alttd.chat.objects.ChatUser;
|
|
|
|
|
|
|
|
|
|
import java.util.UUID;
|
2021-05-15 19:17:24 +00:00
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
2021-05-15 19:16:01 +00:00
|
|
|
|
|
|
|
|
public final class ChatUserManager {
|
|
|
|
|
|
2021-05-15 19:17:24 +00:00
|
|
|
private static CopyOnWriteArrayList<ChatUser> chatUsers;// not sure on this, could cause errors later on
|
2021-05-15 19:16:01 +00:00
|
|
|
|
|
|
|
|
public static void initialize() {
|
2021-05-15 19:17:24 +00:00
|
|
|
chatUsers = new CopyOnWriteArrayList<>();
|
2021-05-15 19:16:01 +00:00
|
|
|
Queries.loadChatUsers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addUser(ChatUser user) {
|
|
|
|
|
if(getChatUser(user.getUuid()) != null)
|
|
|
|
|
chatUsers.add(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ChatUser getChatUser(UUID uuid) {
|
|
|
|
|
for(ChatUser user : chatUsers) {
|
|
|
|
|
if(user.getUuid() == uuid) {
|
|
|
|
|
return user;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|