2021-05-13 12:11:59 +00:00
|
|
|
package com.alttd.chat;
|
2021-05-10 08:01:35 +00:00
|
|
|
|
2021-06-06 19:32:13 +00:00
|
|
|
import com.alttd.chat.config.Config;
|
|
|
|
|
import com.alttd.chat.database.DatabaseConnection;
|
|
|
|
|
import com.alttd.chat.database.Queries;
|
|
|
|
|
import com.alttd.chat.managers.ChatUserManager;
|
|
|
|
|
import com.alttd.chat.managers.RegexManager;
|
2021-05-10 08:01:35 +00:00
|
|
|
import net.luckperms.api.LuckPerms;
|
|
|
|
|
import net.luckperms.api.LuckPermsProvider;
|
|
|
|
|
|
|
|
|
|
public class ChatImplementation implements ChatAPI{
|
|
|
|
|
|
2021-05-15 10:34:19 +00:00
|
|
|
private static ChatAPI instance;
|
2021-05-10 08:01:35 +00:00
|
|
|
|
|
|
|
|
private LuckPerms luckPerms;
|
2021-06-06 19:32:13 +00:00
|
|
|
private DatabaseConnection databaseConnection; // todo this isn't needed can be removed
|
2021-05-10 08:01:35 +00:00
|
|
|
|
2021-05-13 12:11:29 +00:00
|
|
|
public ChatImplementation() {
|
2021-05-10 08:35:47 +00:00
|
|
|
instance = this;
|
2021-06-06 19:32:13 +00:00
|
|
|
Config.init();
|
2021-05-13 18:27:20 +00:00
|
|
|
|
|
|
|
|
luckPerms = getLuckPerms();
|
2021-07-03 18:11:31 +00:00
|
|
|
databaseConnection = getDataBase(); // todo fix sql
|
|
|
|
|
Queries.createTables(); // todo fix sql
|
2021-05-15 19:16:01 +00:00
|
|
|
|
2021-06-06 19:32:13 +00:00
|
|
|
ChatUserManager.initialize(); // loads all the users from the db and adds them.
|
|
|
|
|
RegexManager.initialize(); // load the filters and regexes from config
|
2021-05-10 08:01:35 +00:00
|
|
|
}
|
|
|
|
|
|
2021-05-15 10:34:19 +00:00
|
|
|
public static ChatAPI get() {
|
2021-05-10 08:35:47 +00:00
|
|
|
if(instance == null)
|
|
|
|
|
instance = new ChatImplementation();
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-10 08:01:35 +00:00
|
|
|
@Override
|
|
|
|
|
public LuckPerms getLuckPerms() {
|
|
|
|
|
if(luckPerms == null)
|
|
|
|
|
luckPerms = LuckPermsProvider.get();
|
|
|
|
|
return luckPerms;
|
|
|
|
|
}
|
2021-05-10 08:35:47 +00:00
|
|
|
|
2021-05-13 12:11:29 +00:00
|
|
|
@Override
|
2021-06-06 19:32:13 +00:00
|
|
|
public DatabaseConnection getDataBase() {
|
|
|
|
|
if(databaseConnection == null)
|
|
|
|
|
databaseConnection = new DatabaseConnection();
|
|
|
|
|
return databaseConnection;
|
2021-05-13 12:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
2021-05-10 08:01:35 +00:00
|
|
|
}
|