Add server state mapping for web integration.
This commit is contained in:
parent
5eb470cfb6
commit
e72f79cb29
|
|
@ -20,13 +20,13 @@ import java.util.concurrent.*;
|
|||
@Slf4j
|
||||
public class ChatLogHandler {
|
||||
|
||||
private final WebHandler webHandler = new WebHandler();
|
||||
private final WebHandler webHandler;
|
||||
private static ChatLogHandler instance = null;
|
||||
private ScheduledExecutorService executorService = null;
|
||||
|
||||
public static ChatLogHandler getInstance(boolean enableLogging) {
|
||||
public static ChatLogHandler getInstance(WebHandler webHandler, boolean enableLogging) {
|
||||
if (instance == null) {
|
||||
instance = new ChatLogHandler(enableLogging);
|
||||
instance = new ChatLogHandler(webHandler, enableLogging);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
|
@ -35,7 +35,8 @@ public class ChatLogHandler {
|
|||
private final Queue<ChatLog> chatLogQueue = new ConcurrentLinkedQueue<>();
|
||||
private final HashMap<UUID, List<ChatLog>> chatLogs = new HashMap<>();
|
||||
|
||||
public ChatLogHandler(boolean enableLogging) {
|
||||
public ChatLogHandler(WebHandler webHandler, boolean enableLogging) {
|
||||
this.webHandler = webHandler;
|
||||
if (!enableLogging) {
|
||||
ALogger.info("Logging is not enabled on this server.");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.alttd.chat.nicknames.NicknamesEvents;
|
|||
import com.alttd.chat.objects.channels.Channel;
|
||||
import com.alttd.chat.objects.channels.CustomChannel;
|
||||
import com.alttd.chat.objects.chat_log.ChatLogHandler;
|
||||
import com.alttd.chat.objects.chat_log.WebHandler;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
import com.alttd.chat.util.ServerName;
|
||||
import com.alttd.chat.util.Utility;
|
||||
|
|
@ -42,12 +43,13 @@ public class ChatPlugin extends JavaPlugin {
|
|||
instance = this;
|
||||
ALogger.init(getSLF4JLogger());
|
||||
chatAPI = new ChatImplementation();
|
||||
ChatLogHandler chatLogHandler = ChatLogHandler.getInstance(true);
|
||||
WebHandler webHandler = new WebHandler();
|
||||
ChatLogHandler chatLogHandler = ChatLogHandler.getInstance(webHandler, true);
|
||||
chatHandler = new ChatHandler(chatLogHandler);
|
||||
DatabaseConnection.initialize();
|
||||
serverConfig = new ServerConfig(ServerName.getServerName());
|
||||
ChatMessageSender chatMessageSender = new ChatMessageSender(chatLogHandler, chatAPI.getLuckPerms());
|
||||
registerListener(new PlayerListener(serverConfig),
|
||||
registerListener(new PlayerListener(webHandler, serverConfig),
|
||||
new ChatListener(chatMessageSender),
|
||||
new BookListener(),
|
||||
new ShutdownListener(chatLogHandler, this)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ public class PlayerListener implements Listener {
|
|||
private final ServerConfig serverConfig;
|
||||
private final WebHandler webHandler;
|
||||
|
||||
public PlayerListener(ServerConfig serverConfig) {
|
||||
public PlayerListener(WebHandler webHandler, ServerConfig serverConfig) {
|
||||
this.webHandler = webHandler;
|
||||
this.serverConfig = serverConfig;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.alttd.chat.managers.ChatUserManager;
|
|||
import com.alttd.chat.managers.PartyManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.objects.chat_log.ChatLogHandler;
|
||||
import com.alttd.chat.objects.chat_log.WebHandler;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
import com.alttd.velocitychat.commands.*;
|
||||
import com.alttd.velocitychat.handlers.ChatHandler;
|
||||
|
|
@ -67,7 +68,9 @@ public class VelocityChat {
|
|||
PartyManager.initialize(); // load the parties from the db and add the previously loaded users to them
|
||||
|
||||
serverHandler = new ServerHandler();
|
||||
ChatLogHandler chatLogHandler = new ChatLogHandler(true);
|
||||
WebHandler webHandler = new WebHandler();
|
||||
|
||||
ChatLogHandler chatLogHandler = new ChatLogHandler(webHandler, true);
|
||||
chatHandler = new ChatHandler(chatLogHandler);
|
||||
server.getEventManager().register(this, new ChatListener());
|
||||
server.getEventManager().register(this, new ProxyPlayerListener());
|
||||
|
|
@ -76,7 +79,7 @@ public class VelocityChat {
|
|||
channelIdentifier = MinecraftChannelIdentifier.create(channels[0], channels[1]);
|
||||
server.getChannelRegistrar().register(channelIdentifier);
|
||||
server.getEventManager().register(this, new PluginMessageListener(channelIdentifier));
|
||||
loadCommands();
|
||||
loadCommands(webHandler);
|
||||
// setup console chatuser
|
||||
ChatUser console = new ChatUser(Config.CONSOLEUUID, -1, null);
|
||||
console.setDisplayName(Config.CONSOLENAME);
|
||||
|
|
@ -113,8 +116,8 @@ public class VelocityChat {
|
|||
return server;
|
||||
}
|
||||
|
||||
public void loadCommands() {
|
||||
ChatLogHandler instance = ChatLogHandler.getInstance(false);
|
||||
public void loadCommands(WebHandler webHandler) {
|
||||
ChatLogHandler instance = ChatLogHandler.getInstance(webHandler, false);
|
||||
new SilentJoinCommand(server);
|
||||
new GlobalAdminChat(server);
|
||||
new Reload(server);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user