diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java index 4d19de0b3..38d3fb6c6 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java @@ -42,6 +42,7 @@ import org.geysermc.connector.dump.BootstrapDumpInfo; import org.geysermc.connector.network.translators.world.WorldManager; import org.geysermc.connector.ping.GeyserLegacyPingPassthrough; import org.geysermc.connector.ping.IGeyserPingPassthrough; +import org.geysermc.connector.utils.Constants; import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.LanguageUtils; import org.geysermc.geyser.adapters.spigot.SpigotAdapters; @@ -126,7 +127,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap { // Remove this in like a year if (Bukkit.getPluginManager().getPlugin("floodgate-bukkit") != null) { - geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.outdated", "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/")); + geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.outdated", Constants.FLOODGATE_DOWNLOAD_LOCATION)); this.getPluginLoader().disablePlugin(this); return; } diff --git a/connector/pom.xml b/connector/pom.xml index b77a94a2e..8964f18c8 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -11,7 +11,7 @@ connector - 4.8.0 + 4.9.2 8.5.2 2.12.4 4.1.66.Final @@ -147,15 +147,11 @@ compile - com.github.RednedEpic + com.github.GeyserMC MCProtocolLib - e17787a + e7979c4 compile - - net.kyori - adventure-text-serializer-gson - com.github.steveice10 packetlib @@ -226,30 +222,12 @@ osx-x86_64 - - net.kyori - adventure-api - ${adventure.version} - compile - - - net.kyori - adventure-text-serializer-gson - ${adventure.version} - compile - net.kyori adventure-text-serializer-legacy ${adventure.version} compile - - net.kyori - adventure-text-serializer-gson-legacy-impl - ${adventure.version} - compile - junit diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 21730b230..e5009938d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -35,6 +35,7 @@ import com.github.steveice10.mc.auth.service.MsaAuthenticationService; import com.github.steveice10.mc.protocol.MinecraftConstants; import com.github.steveice10.mc.protocol.MinecraftProtocol; import com.github.steveice10.mc.protocol.data.SubProtocol; +import com.github.steveice10.mc.protocol.data.UnexpectedEncryptionException; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.recipe.Recipe; @@ -100,6 +101,7 @@ import org.geysermc.cumulus.util.FormBuilder; import org.geysermc.floodgate.crypto.FloodgateCipher; import org.geysermc.floodgate.util.BedrockData; +import java.net.ConnectException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; @@ -831,16 +833,44 @@ public class GeyserSession implements CommandSender { public void disconnected(DisconnectedEvent event) { loggingIn = false; loggedIn = false; - if (downstream != null && downstream.isInternallyConnecting()) { - connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.remote.disconnect_internal", authData.getName(), event.getReason())); + + String disconnectMessage; + Throwable cause = event.getCause(); + if (cause instanceof UnexpectedEncryptionException) { + if (remoteAuthType != AuthType.FLOODGATE) { + // Server expects online mode + disconnectMessage = LanguageUtils.getPlayerLocaleString("geyser.network.remote.authentication_type_mismatch", getLocale()); + // Explain that they may be looking for Floodgate. + connector.getLogger().warning(LanguageUtils.getLocaleStringLog( + connector.getPlatformType() == PlatformType.STANDALONE ? + "geyser.network.remote.floodgate_explanation_standalone" + : "geyser.network.remote.floodgate_explanation_plugin", + Constants.FLOODGATE_DOWNLOAD_LOCATION + )); + } else { + // Likely that Floodgate is not configured correctly. + disconnectMessage = LanguageUtils.getPlayerLocaleString("geyser.network.remote.floodgate_login_error", getLocale()); + if (connector.getPlatformType() == PlatformType.STANDALONE) { + connector.getLogger().warning(LanguageUtils.getLocaleStringLog("geyser.network.remote.floodgate_login_error_standalone")); + } + } + } else if (cause instanceof ConnectException) { + // Server is offline, probably + disconnectMessage = LanguageUtils.getPlayerLocaleString("geyser.network.remote.server_offline", getLocale()); } else { - connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.remote.disconnect", authData.getName(), remoteAddress, event.getReason())); - } - if (event.getCause() != null) { - event.getCause().printStackTrace(); + disconnectMessage = MessageTranslator.convertMessageLenient(event.getReason()); } - upstream.disconnect(MessageTranslator.convertMessageLenient(event.getReason())); + if (downstream != null && downstream.isInternallyConnecting()) { + connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.remote.disconnect_internal", authData.getName(), disconnectMessage)); + } else { + connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.remote.disconnect", authData.getName(), remoteAddress, disconnectMessage)); + } + if (cause != null) { + cause.printStackTrace(); + } + + upstream.disconnect(disconnectMessage); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/chat/MessageTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/chat/MessageTranslator.java index 7fa74d4cd..1f0380f2f 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/chat/MessageTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/chat/MessageTranslator.java @@ -30,7 +30,6 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.renderer.TranslatableComponentRenderer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import net.kyori.adventure.text.serializer.gson.legacyimpl.NBTLegacyHoverEventSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.session.GeyserSession; @@ -45,11 +44,8 @@ public class MessageTranslator { // Custom instead of TranslatableComponentRenderer#usingTranslationSource so we don't need to worry about finding a Locale class private static final TranslatableComponentRenderer RENDERER = new MinecraftTranslationRegistry(); - // Construct our own {@link GsonComponentSerializer} since we need to change a setting - private static final GsonComponentSerializer GSON_SERIALIZER = GsonComponentSerializer.builder() - // Specify that we may be expecting legacy hover events - .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get()) - .build(); + // Possible TODO: replace the legacy hover event serializer with an empty one since we have no use for hover events + private static final GsonComponentSerializer GSON_SERIALIZER = DefaultComponentSerializer.get(); // Store team colors for player names private static final Map TEAM_COLORS = new EnumMap<>(TeamColor.class); @@ -90,9 +86,6 @@ public class MessageTranslator { TEAM_COLORS.put(TeamColor.BOLD, BASE + "l"); TEAM_COLORS.put(TeamColor.STRIKETHROUGH, BASE + "m"); TEAM_COLORS.put(TeamColor.ITALIC, BASE + "o"); - - // Tell MCProtocolLib to use our serializer - DefaultComponentSerializer.set(GSON_SERIALIZER); } /** diff --git a/connector/src/main/java/org/geysermc/connector/utils/Constants.java b/connector/src/main/java/org/geysermc/connector/utils/Constants.java index 02f5c1ae4..0a6062a3b 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/Constants.java +++ b/connector/src/main/java/org/geysermc/connector/utils/Constants.java @@ -35,6 +35,8 @@ public final class Constants { public static final String NEWS_OVERVIEW_URL = "https://api.geysermc.org/v1/news"; public static final String NEWS_PROJECT_NAME = "geyser"; + public static final String FLOODGATE_DOWNLOAD_LOCATION = "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/"; + static { URI wsUri = null; try { diff --git a/connector/src/main/resources/languages b/connector/src/main/resources/languages index 1138a6462..b3ef0d567 160000 --- a/connector/src/main/resources/languages +++ b/connector/src/main/resources/languages @@ -1 +1 @@ -Subproject commit 1138a64627dec66fdb7f33c922ff6cd5636ec30a +Subproject commit b3ef0d567d2e088a3b900741a464ad00524e9beb