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;
|
2021-08-04 13:07:25 +00:00
|
|
|
import com.alttd.chat.managers.PartyManager;
|
2021-06-06 19:32:13 +00:00
|
|
|
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-07-17 22:48:55 +00:00
|
|
|
private DatabaseConnection databaseConnection;
|
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-08-14 17:55:32 +00:00
|
|
|
ReloadConfig();
|
2021-05-13 18:27:20 +00:00
|
|
|
|
|
|
|
|
luckPerms = getLuckPerms();
|
2021-07-17 22:48:55 +00:00
|
|
|
databaseConnection = getDataBase();
|
|
|
|
|
Queries.createTables();
|
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-08-04 13:07:25 +00:00
|
|
|
PartyManager.initialize(); // load the parties from the db and add the previously loaded users to them
|
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-08-14 17:55:32 +00:00
|
|
|
@Override
|
|
|
|
|
public void ReloadConfig() {
|
|
|
|
|
Config.init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void ReloadChatFilters() {
|
|
|
|
|
RegexManager.initialize();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-10 08:01:35 +00:00
|
|
|
}
|