diff --git a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Listener/PluginChannelCommunicator.java b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Listener/PluginChannelCommunicator.java index 3a8de772..4c95209b 100644 --- a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Listener/PluginChannelCommunicator.java +++ b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Bukkit/Listener/PluginChannelCommunicator.java @@ -47,6 +47,8 @@ public class PluginChannelCommunicator extends PluginChannelCommunicatorBase implements PluginMessageListener, Listener { + private static final String CHANNEL_BUNGEE_CORD = "BungeeCord"; + @Getter @Setter(AccessLevel.PRIVATE) private static String serverName = null; private final MarriageMaster plugin; @@ -85,7 +87,7 @@ public void close() @Override protected void receiveUnknownChannel(@NotNull String channel, byte[] bytes) { - if (channel.equals(CHANNEL_BUNGEE_CORD)) + if (channel.equals(CHANNEL_BUNGEE_CORD) || channel.equals("bungeecord:main")) { try(DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes))) { @@ -196,8 +198,10 @@ public void onPlayerLoginEvent(PlayerJoinEvent event) { if(!serverNameUpdated) { - logger.info("Request server name from BungeeCord ..."); - sendMessage(CHANNEL_BUNGEE_CORD, buildStringMessage("GetServer")); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { + logger.info("Request server name from BungeeCord ..."); + sendMessage(CHANNEL_BUNGEE_CORD, buildStringMessage("GetServer")); + }, 20); } // If the server is empty and a player joins the server we have to do a re-sync if(plugin.getServer().getOnlinePlayers().size() == 1) @@ -216,7 +220,9 @@ public void sendMessage(final byte[] data) private void sendMessage(String channel, byte[] data) { if (Bukkit.isPrimaryThread()) + { performSendMessage(channel, data); + } else { Bukkit.getScheduler().runTask(plugin, () -> performSendMessage(channel, data)); diff --git a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Database/PluginChannelCommunicatorBase.java b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Database/PluginChannelCommunicatorBase.java index e9e5641a..49d09076 100644 --- a/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Database/PluginChannelCommunicatorBase.java +++ b/MarriageMaster/src/at/pcgamingfreaks/MarriageMaster/Database/PluginChannelCommunicatorBase.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 GeorgH93 + * Copyright (C) 2024 GeorgH93 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ public abstract class PluginChannelCommunicatorBase { private static final String MESSAGE_UNKNOWN_COMMAND = ConsoleColor.YELLOW + "Received unknown command via plugin channel! Command: {0} " + ConsoleColor.RESET; - protected static final String CHANNEL_MARRIAGE_MASTER = "marriagemaster:main", CHANNEL_BUNGEE_CORD = "BungeeCord"; + protected static final String CHANNEL_MARRIAGE_MASTER = "marriagemaster:main"; protected final Logger logger; protected final BaseDatabase database;