Load ChatUsers async
This commit is contained in:
parent
097541e86f
commit
2d7d39a86d
|
|
@ -7,11 +7,12 @@ import com.alttd.chat.objects.Mail;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class ChatUserManager {
|
||||
|
||||
private static ArrayList<ChatUser> chatUsers;// not sure on this, could cause errors later on
|
||||
private static ArrayList<ChatUser> chatUsers;
|
||||
|
||||
public static void initialize() {
|
||||
chatUsers = new ArrayList<>();
|
||||
|
|
@ -31,11 +32,14 @@ public final class ChatUserManager {
|
|||
return user;
|
||||
}
|
||||
}
|
||||
ChatUser chatUser = Queries.loadChatUser(uuid);
|
||||
if (chatUser != null) {
|
||||
ChatUserManager.addUser(chatUser);
|
||||
}
|
||||
return chatUser;
|
||||
// todo move the CompletableFuture to Queries
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
ChatUser loadChatUser = Queries.loadChatUser(uuid);
|
||||
if (loadChatUser != null) {
|
||||
ChatUserManager.addUser(loadChatUser);
|
||||
}
|
||||
return loadChatUser;
|
||||
}).join();
|
||||
// if(user == null) user = new ChatUser(uuid, -1, false, false);
|
||||
// Queries.saveUser(user);
|
||||
// chatUsers.add(user);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,15 @@
|
|||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dv8tion</id>
|
||||
<name>m2-dv8tion</name>
|
||||
<url>https://m2.dv8tion.net/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
@ -70,12 +79,30 @@
|
|||
<version>1.7.30</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.3.0_291</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>opus-java</artifactId>
|
||||
<groupId>club.minnced</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gitlab.ruany</groupId>
|
||||
<artifactId>LiteBansAPI</artifactId>
|
||||
<version>0.3.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class PlayerListener implements Listener {
|
|||
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||
if(user != null) return;
|
||||
|
||||
// todo actually load the users from db
|
||||
// user failed to load - create a new one
|
||||
ChatUser chatUser = new ChatUser(uuid, -1, false, false);
|
||||
ChatUserManager.addUser(chatUser);
|
||||
Queries.saveUser(chatUser);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user