From 41c42ed3bb6cb4cc973a435f0dd3f68e84b982b0 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 6 May 2024 12:04:58 +0200 Subject: [PATCH 1/9] Update cloud (#505) --- build-logic/src/main/kotlin/Versions.kt | 3 ++- core/build.gradle.kts | 3 ++- .../floodgate/player/audience/PlayerAudienceArgument.java | 4 ++-- spigot/build.gradle.kts | 4 +--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build-logic/src/main/kotlin/Versions.kt b/build-logic/src/main/kotlin/Versions.kt index 183655f4..406c8e1f 100644 --- a/build-logic/src/main/kotlin/Versions.kt +++ b/build-logic/src/main/kotlin/Versions.kt @@ -33,7 +33,8 @@ object Versions { const val guiceVersion = "6.0.0" const val nettyVersion = "4.1.49.Final" const val snakeyamlVersion = "1.28" - const val cloudVersion = "2.0.0-beta.2" + // TODO move to cloud release once those have 1.20.5 support + const val cloudVersion = "2.0.0-20240503.183307-62" // for cloud-minecraft const val bstatsVersion = "3.0.2" const val javaWebsocketVersion = "1.5.2" diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 7d3d4632..e2e75259 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -15,7 +15,8 @@ dependencies { api("com.nukkitx.fastutil", "fastutil-short-object-maps", Versions.fastutilVersion) api("com.nukkitx.fastutil", "fastutil-int-object-maps", Versions.fastutilVersion) api("org.java-websocket", "Java-WebSocket", Versions.javaWebsocketVersion) - api("org.incendo", "cloud-core", Versions.cloudVersion) + // TODO move to cloud release + api("org.incendo", "cloud-core", "2.0.0-20240503.181645-64") api("org.bstats", "bstats-base", Versions.bstatsVersion) } diff --git a/core/src/main/java/org/geysermc/floodgate/player/audience/PlayerAudienceArgument.java b/core/src/main/java/org/geysermc/floodgate/player/audience/PlayerAudienceArgument.java index 3829db3a..765fa75f 100644 --- a/core/src/main/java/org/geysermc/floodgate/player/audience/PlayerAudienceArgument.java +++ b/core/src/main/java/org/geysermc/floodgate/player/audience/PlayerAudienceArgument.java @@ -102,10 +102,10 @@ private static CommandComponent.Builder of(String CommandUtil commandUtil = context.get("CommandUtil"); boolean quoted = input.remainingInput().startsWith("\""); - List suggestions = new ArrayList(); + List suggestions = new ArrayList<>(); for (final String player : commandUtil.getOnlineUsernames(limitTo)) { suggestions.add( - Suggestion.simple(BrigadierUtils.escapeIfRequired(player, quoted))); + Suggestion.suggestion(BrigadierUtils.escapeIfRequired(player, quoted))); } return CompletableFuture.completedFuture(suggestions); }); diff --git a/spigot/build.gradle.kts b/spigot/build.gradle.kts index 193fc27e..6e95bae1 100644 --- a/spigot/build.gradle.kts +++ b/spigot/build.gradle.kts @@ -13,9 +13,7 @@ indra { dependencies { api(projects.core) - // TODO move to release once cloud-paper releases for 1.20.5 - // https://repo.papermc.io/#browse/browse:maven-public:org%2Fincendo%2Fcloud-paper%2F2.0.0-SNAPSHOT%2F2.0.0-20240427.220226-58 - implementation("org.incendo", "cloud-paper", "2.0.0-20240427.220226-58") + implementation("org.incendo", "cloud-paper", Versions.cloudVersion) // hack to make pre 1.12 work implementation("com.google.guava", "guava", guavaVersion) From 4404c15f1a0ae0c19ff3a763654f7a29b27c1d02 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 8 May 2024 17:15:44 +0200 Subject: [PATCH 2/9] Allow Floodgate-Fabric to provide it's own TemplateReader (#507) --- .../org/geysermc/floodgate/config/ConfigLoader.java | 5 +++-- .../org/geysermc/floodgate/module/CommonModule.java | 10 +++++++++- .../geysermc/floodgate/module/ServerCommonModule.java | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/geysermc/floodgate/config/ConfigLoader.java b/core/src/main/java/org/geysermc/floodgate/config/ConfigLoader.java index e4311058..739e1767 100644 --- a/core/src/main/java/org/geysermc/floodgate/config/ConfigLoader.java +++ b/core/src/main/java/org/geysermc/floodgate/config/ConfigLoader.java @@ -33,7 +33,7 @@ import lombok.RequiredArgsConstructor; import org.geysermc.configutils.ConfigUtilities; import org.geysermc.configutils.file.codec.PathFileCodec; -import org.geysermc.configutils.file.template.ResourceTemplateReader; +import org.geysermc.configutils.file.template.TemplateReader; import org.geysermc.configutils.updater.change.Changes; import org.geysermc.floodgate.crypto.FloodgateCipher; import org.geysermc.floodgate.crypto.KeyProducer; @@ -46,6 +46,7 @@ public final class ConfigLoader { private final KeyProducer keyProducer; private final FloodgateCipher cipher; + private final TemplateReader reader; @SuppressWarnings("unchecked") public T load() { @@ -64,7 +65,7 @@ public T load() { ConfigUtilities.builder() .fileCodec(PathFileCodec.of(dataDirectory)) .configFile("config.yml") - .templateReader(ResourceTemplateReader.of(getClass())) + .templateReader(reader) .template(templateFile) .changes(Changes.builder() .version(1, Changes.versionBuilder() diff --git a/core/src/main/java/org/geysermc/floodgate/module/CommonModule.java b/core/src/main/java/org/geysermc/floodgate/module/CommonModule.java index 881f3ede..cddb93f7 100644 --- a/core/src/main/java/org/geysermc/floodgate/module/CommonModule.java +++ b/core/src/main/java/org/geysermc/floodgate/module/CommonModule.java @@ -40,6 +40,8 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import lombok.RequiredArgsConstructor; +import org.geysermc.configutils.file.template.ResourceTemplateReader; +import org.geysermc.configutils.file.template.TemplateReader; import org.geysermc.event.PostOrder; import org.geysermc.floodgate.addon.data.HandshakeHandlersImpl; import org.geysermc.floodgate.api.FloodgateApi; @@ -75,6 +77,12 @@ public class CommonModule extends AbstractModule { private final EventBus eventBus = new EventBus(); private final Path dataDirectory; + private final TemplateReader reader; + + public CommonModule(Path dataDirectory) { + this.dataDirectory = dataDirectory; + this.reader = ResourceTemplateReader.of(ConfigLoader.class); + } @Override protected void configure() { @@ -154,7 +162,7 @@ public ConfigLoader configLoader( @Named("configClass") Class configClass, KeyProducer producer, FloodgateCipher cipher) { - return new ConfigLoader(dataDirectory, configClass, producer, cipher); + return new ConfigLoader(dataDirectory, configClass, producer, cipher, reader); } @Provides diff --git a/core/src/main/java/org/geysermc/floodgate/module/ServerCommonModule.java b/core/src/main/java/org/geysermc/floodgate/module/ServerCommonModule.java index 23514824..9afb2253 100644 --- a/core/src/main/java/org/geysermc/floodgate/module/ServerCommonModule.java +++ b/core/src/main/java/org/geysermc/floodgate/module/ServerCommonModule.java @@ -29,6 +29,7 @@ import com.google.inject.Singleton; import com.google.inject.name.Named; import java.nio.file.Path; +import org.geysermc.configutils.file.template.TemplateReader; import org.geysermc.floodgate.api.SimpleFloodgateApi; import org.geysermc.floodgate.config.FloodgateConfig; @@ -37,6 +38,11 @@ public ServerCommonModule(Path dataDirectory) { super(dataDirectory); } + // Used in floodgate-fabric to provide it's own reader implementation + public ServerCommonModule(Path dataDirectory, TemplateReader reader) { + super(dataDirectory, reader); + } + @Override protected void configure() { super.configure(); From f8c84182d618cfd450f585b17c94dbebfceac019 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 14 May 2024 17:41:00 +0200 Subject: [PATCH 3/9] Deal with getLocale being nullable during login on BungeeCord (#511) * Temporary fix for https://github.com/GeyserMC/Floodgate/issues/510, bump cloud to rc candidate * apparently it is supposed to be nullable. okay then. --- build-logic/src/main/kotlin/Versions.kt | 3 ++- .../java/org/geysermc/floodgate/util/BungeeCommandUtil.java | 4 +++- core/build.gradle.kts | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build-logic/src/main/kotlin/Versions.kt b/build-logic/src/main/kotlin/Versions.kt index 406c8e1f..d04e0f59 100644 --- a/build-logic/src/main/kotlin/Versions.kt +++ b/build-logic/src/main/kotlin/Versions.kt @@ -34,7 +34,8 @@ object Versions { const val nettyVersion = "4.1.49.Final" const val snakeyamlVersion = "1.28" // TODO move to cloud release once those have 1.20.5 support - const val cloudVersion = "2.0.0-20240503.183307-62" // for cloud-minecraft + const val cloudVersion = "2.0.0-beta.7" // for cloud-minecraft + const val cloudCore = "2.0.0-rc.1" const val bstatsVersion = "3.0.2" const val javaWebsocketVersion = "1.5.2" diff --git a/bungee/src/main/java/org/geysermc/floodgate/util/BungeeCommandUtil.java b/bungee/src/main/java/org/geysermc/floodgate/util/BungeeCommandUtil.java index 8d1e7c1c..322a0332 100644 --- a/bungee/src/main/java/org/geysermc/floodgate/util/BungeeCommandUtil.java +++ b/bungee/src/main/java/org/geysermc/floodgate/util/BungeeCommandUtil.java @@ -26,6 +26,7 @@ package org.geysermc.floodgate.util; import java.util.Collection; +import java.util.Locale; import java.util.UUID; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; @@ -63,7 +64,8 @@ public BungeeCommandUtil(LanguageManager manager, ProxyServer server, FloodgateA ProxiedPlayer player = (ProxiedPlayer) source; UUID uuid = player.getUniqueId(); String username = player.getName(); - String locale = Utils.getLocale(player.getLocale()); + Locale playerLocale = player.getLocale(); // Is null during the PostLoginEvent, which can cause https://github.com/GeyserMC/Floodgate/issues/510 + String locale = Utils.getLocale(playerLocale != null ? playerLocale : Locale.getDefault()); return new PlayerAudience(uuid, username, locale, source, this, true); } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index e2e75259..20a9233c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -15,8 +15,7 @@ dependencies { api("com.nukkitx.fastutil", "fastutil-short-object-maps", Versions.fastutilVersion) api("com.nukkitx.fastutil", "fastutil-int-object-maps", Versions.fastutilVersion) api("org.java-websocket", "Java-WebSocket", Versions.javaWebsocketVersion) - // TODO move to cloud release - api("org.incendo", "cloud-core", "2.0.0-20240503.181645-64") + api("org.incendo", "cloud-core", Versions.cloudCore) api("org.bstats", "bstats-base", Versions.bstatsVersion) } From 00b8b1b6364116ff4bc9b00e2015ce35bae8abb1 Mon Sep 17 00:00:00 2001 From: Bridge <29434554+bridgelol@users.noreply.github.com> Date: Sat, 18 May 2024 15:01:55 +0200 Subject: [PATCH 4/9] Reduce session server lookups (#509) * fix: add default skin to gameprofiles * fix: add signatures by default to prevent issues * cleanup * no longer apply empty textures * revert formatting change * fix(spigot): linked player textures * fix(velocity): linked player textures * fix(bungeecord): apply linked textures * Made the MojangUtils class instance based, removed some unneeded code * Don't block Velocity event threads, made the Bungee variant work * Add some comments --------- Co-authored-by: bridge Co-authored-by: Tim203 --- .../floodgate/listener/BungeeListener.java | 34 ++++-- .../pluginmessage/BungeeSkinApplier.java | 2 - .../geysermc/floodgate/skin/SkinDataImpl.java | 6 + .../geysermc/floodgate/util/MojangUtils.java | 110 ++++++++++++++++++ .../geysermc/floodgate/util/Constants.java | 6 + .../addon/data/SpigotDataHandler.java | 15 +++ .../listener/PaperProfileListener.java | 32 ++--- .../floodgate/listener/VelocityListener.java | 54 +++++++-- 8 files changed, 214 insertions(+), 45 deletions(-) create mode 100644 core/src/main/java/org/geysermc/floodgate/util/MojangUtils.java diff --git a/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java b/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java index 9723cf58..f7e4b6fd 100644 --- a/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java +++ b/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java @@ -39,6 +39,7 @@ import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.PreLoginEvent; import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.connection.InitialHandler; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventPriority; @@ -46,10 +47,10 @@ import org.geysermc.floodgate.api.ProxyFloodgateApi; import org.geysermc.floodgate.api.logger.FloodgateLogger; import org.geysermc.floodgate.api.player.FloodgatePlayer; -import org.geysermc.floodgate.config.ProxyFloodgateConfig; import org.geysermc.floodgate.skin.SkinApplier; import org.geysermc.floodgate.skin.SkinDataImpl; import org.geysermc.floodgate.util.LanguageManager; +import org.geysermc.floodgate.util.MojangUtils; import org.geysermc.floodgate.util.ReflectionUtils; @SuppressWarnings("ConstantConditions") @@ -66,7 +67,7 @@ public final class BungeeListener implements Listener { checkNotNull(PLAYER_NAME, "Initial name field cannot be null"); } - @Inject private ProxyFloodgateConfig config; + @Inject private Plugin plugin; @Inject private ProxyFloodgateApi api; @Inject private LanguageManager languageManager; @Inject private FloodgateLogger logger; @@ -80,6 +81,8 @@ public final class BungeeListener implements Listener { @Named("kickMessageAttribute") private AttributeKey kickMessageAttribute; + @Inject private MojangUtils mojangUtils; + @EventHandler(priority = EventPriority.LOWEST) public void onPreLogin(PreLoginEvent event) { // well, no reason to check if the player will be kicked anyway @@ -127,13 +130,28 @@ public void onLogin(LoginEvent event) { @EventHandler(priority = EventPriority.LOWEST) public void onPostLogin(PostLoginEvent event) { - // To fix the February 2 2022 Mojang authentication changes - if (!config.isSendFloodgateData()) { - FloodgatePlayer player = api.getPlayer(event.getPlayer().getUniqueId()); - if (player != null && !player.isLinked()) { - skinApplier.applySkin(player, new SkinDataImpl("", "")); - } + FloodgatePlayer player = api.getPlayer(event.getPlayer().getUniqueId()); + + // Skin look up (on Spigot and friends) would result in it failing, so apply a default skin + if (!player.isLinked()) { + skinApplier.applySkin(player, SkinDataImpl.DEFAULT_SKIN); + return; } + + // Floodgate players are seen as offline mode players, meaning we have to look up + // the linked player's textures ourselves + + event.registerIntent(plugin); + + mojangUtils.skinFor(player.getJavaUniqueId()) + .exceptionally(exception -> { + logger.debug("Unexpected skin fetch error for " + player.getJavaUniqueId(), exception); + return SkinDataImpl.DEFAULT_SKIN; + }) + .thenAccept(skin -> { + skinApplier.applySkin(player, skin); + event.completeIntent(plugin); + }); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/bungee/src/main/java/org/geysermc/floodgate/pluginmessage/BungeeSkinApplier.java b/bungee/src/main/java/org/geysermc/floodgate/pluginmessage/BungeeSkinApplier.java index ce6105ec..fa2aaad2 100644 --- a/bungee/src/main/java/org/geysermc/floodgate/pluginmessage/BungeeSkinApplier.java +++ b/bungee/src/main/java/org/geysermc/floodgate/pluginmessage/BungeeSkinApplier.java @@ -92,8 +92,6 @@ public void applySkin(@NonNull FloodgatePlayer floodgatePlayer, @NonNull SkinDat SkinData currentSkin = currentSkin(properties); SkinApplyEvent event = new SkinApplyEventImpl(floodgatePlayer, currentSkin, skinData); - event.setCancelled(floodgatePlayer.isLinked()); - eventBus.fire(event); if (event.isCancelled()) { diff --git a/core/src/main/java/org/geysermc/floodgate/skin/SkinDataImpl.java b/core/src/main/java/org/geysermc/floodgate/skin/SkinDataImpl.java index 9f44af79..1e2247e2 100644 --- a/core/src/main/java/org/geysermc/floodgate/skin/SkinDataImpl.java +++ b/core/src/main/java/org/geysermc/floodgate/skin/SkinDataImpl.java @@ -29,8 +29,14 @@ import java.util.Objects; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.floodgate.api.event.skin.SkinApplyEvent.SkinData; +import org.geysermc.floodgate.util.Constants; public class SkinDataImpl implements SkinData { + public static final SkinData DEFAULT_SKIN = new SkinDataImpl( + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_TEXTURE, + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_SIGNATURE + ); + private final String value; private final String signature; diff --git a/core/src/main/java/org/geysermc/floodgate/util/MojangUtils.java b/core/src/main/java/org/geysermc/floodgate/util/MojangUtils.java new file mode 100644 index 00000000..423ff44b --- /dev/null +++ b/core/src/main/java/org/geysermc/floodgate/util/MojangUtils.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Floodgate + */ + +package org.geysermc.floodgate.util; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; +import lombok.NonNull; +import org.geysermc.floodgate.api.event.skin.SkinApplyEvent.SkinData; +import org.geysermc.floodgate.skin.SkinDataImpl; +import org.geysermc.floodgate.util.HttpClient.HttpResponse; + +@Singleton +public class MojangUtils { + private final Cache SKIN_CACHE = CacheBuilder.newBuilder() + .expireAfterWrite(5, TimeUnit.MINUTES) + .maximumSize(500) + .build(); + + @Inject private HttpClient httpClient; + @Inject + @Named("commonPool") + private ExecutorService commonPool; + + public CompletableFuture<@NonNull SkinData> skinFor(UUID playerId) { + return CompletableFuture.supplyAsync(() -> { + try { + return SKIN_CACHE.get(playerId, () -> fetchSkinFor(playerId)); + } catch (ExecutionException exception) { + throw new RuntimeException(exception.getCause()); + } + }, commonPool); + } + + private @NonNull SkinData fetchSkinFor(UUID playerId) { + HttpResponse httpResponse = httpClient.get( + String.format(Constants.PROFILE_WITH_PROPERTIES_URL, playerId.toString())); + + if (httpResponse.getHttpCode() != 200) { + return SkinDataImpl.DEFAULT_SKIN; + } + + JsonObject response = httpResponse.getResponse(); + + if (response == null) { + return SkinDataImpl.DEFAULT_SKIN; + } + + JsonArray properties = response.getAsJsonArray("properties"); + + if (properties.size() == 0) { + return SkinDataImpl.DEFAULT_SKIN; + } + + for (JsonElement property : properties) { + if (!property.isJsonObject()) { + continue; + } + + JsonObject propertyObject = property.getAsJsonObject(); + + if (!propertyObject.has("name") + || !propertyObject.has("value") + || !propertyObject.has("signature") + || !propertyObject.get("name").getAsString().equals("textures")) { + continue; + } + + return new SkinDataImpl( + propertyObject.get("value").getAsString(), + propertyObject.get("signature").getAsString() + ); + } + + return SkinDataImpl.DEFAULT_SKIN; + } +} diff --git a/core/src/main/templates/org/geysermc/floodgate/util/Constants.java b/core/src/main/templates/org/geysermc/floodgate/util/Constants.java index 62cec467..1eec715a 100644 --- a/core/src/main/templates/org/geysermc/floodgate/util/Constants.java +++ b/core/src/main/templates/org/geysermc/floodgate/util/Constants.java @@ -56,6 +56,9 @@ public final class Constants { public static final String LATEST_VERSION_URL = "https://download.geysermc.org/v2/projects/%s/versions/latest/builds/latest"; + public static final String PROFILE_WITH_PROPERTIES_URL = + "https://sessionserver.mojang.com/session/minecraft/profile/%s?unsigned=false"; + public static final String NTP_SERVER = "time.cloudflare.com"; public static final String INTERNAL_ERROR_MESSAGE = @@ -70,4 +73,7 @@ public final class Constants { public static final int HANDSHAKE_PACKET_ID = 0; public static final int LOGIN_SUCCESS_PACKET_ID = 2; public static final int SET_COMPRESSION_PACKET_ID = 3; + + public static final String DEFAULT_MINECRAFT_JAVA_SKIN_TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTcxNTcxNzM1NTI2MywKICAicHJvZmlsZUlkIiA6ICIyMWUzNjdkNzI1Y2Y0ZTNiYjI2OTJjNGEzMDBhNGRlYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJHZXlzZXJNQyIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zMWY0NzdlYjFhN2JlZWU2MzFjMmNhNjRkMDZmOGY2OGZhOTNhMzM4NmQwNDQ1MmFiMjdmNDNhY2RmMWI2MGNiIgogICAgfQogIH0KfQ"; + public static final String DEFAULT_MINECRAFT_JAVA_SKIN_SIGNATURE = "dFKIZ5d6vNqCSe1IFGiVLjt3cnW8qh4qNP2umg9zqkX9bvAQawuR1iuO1kCD/+ye8A6GQFv2wRCdxdrjp5+Vrr0SsWqMnsYDN8cEg6CD18mAnaKI1TYDuGbdJaqLyGqN5wqSMdHxchs9iovFkde5ir4aYdvHkA11vOTi11L4kUzETGzJ4iKVuZOv4dq+B7wFAWqp4n8QZfhixyvemFazQHlLmxnuhU+jhpZMvYY9MAaRAJonfy/wJe9LymbTe0EJ8N+NwZQDrEUzgfBFo4OIGDqRZwvydInCqkjhPMtHCSL25VOKwcFocYpRYbk4eIKM4CLjYlBiQGki+XKsPaljwjVhnT0jUupSf7yraGb3T0CsVBjhDbIIIp9nytlbO0GvxHu0TzYjkr4Iji0do5jlCKQ/OasXcL21wd6ozw0t1QZnnzxi9ewSuyYVY9ErmWdkww1OtCIgJilceEBwNAB8+mhJ062WFaYPgJQAmOREM8InW33dbbeENMFhQi4LIO5P7p9ye3B4Lrwm20xtd9wJk3lewzcs8ezh0LUF6jPSDQDivgSKU49mLCTmOi+WZh8zKjjxfVEtNZON2W+3nct0LiWBVsQ55HzlvF0FFxuRVm6pxi6MQK2ernv3DQl0hUqyQ1+RV9nfZXTQOAUzwLjKx3t2zKqyZIiNEKLE+iAXrsE="; } diff --git a/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java b/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java index 36f34e9d..383fa7e9 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java +++ b/spigot/src/main/java/org/geysermc/floodgate/addon/data/SpigotDataHandler.java @@ -29,6 +29,7 @@ import static org.geysermc.floodgate.util.ReflectionUtils.setValue; import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; import io.netty.channel.Channel; import io.netty.util.AttributeKey; import java.lang.reflect.InvocationTargetException; @@ -38,9 +39,16 @@ import org.geysermc.floodgate.player.FloodgateHandshakeHandler; import org.geysermc.floodgate.player.FloodgateHandshakeHandler.HandshakeResult; import org.geysermc.floodgate.util.ClassNames; +import org.geysermc.floodgate.util.Constants; import org.geysermc.floodgate.util.ProxyUtils; public final class SpigotDataHandler extends CommonDataHandler { + private static final Property DEFAULT_TEXTURE_PROPERTY = new Property( + "textures", + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_TEXTURE, + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_SIGNATURE + ); + private Object networkManager; private FloodgatePlayer player; private boolean proxyData; @@ -171,6 +179,13 @@ private boolean checkAndHandleLogin(Object packet) throws Exception { player.getCorrectUniqueId(), player.getCorrectUsername() ); + if (!player.isLinked()) { + // Otherwise game server will try to fetch the skin from Mojang. + // No need to worry that this overrides proxy data, because those won't reach this + // method / are already removed (in the case of username validation) + gameProfile.getProperties().put("textures", DEFAULT_TEXTURE_PROPERTY); + } + // we have to fake the offline player (login) cycle if (ClassNames.IS_PRE_1_20_2) { diff --git a/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java b/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java index 29ade2ec..836b9fb2 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java +++ b/spigot/src/main/java/org/geysermc/floodgate/listener/PaperProfileListener.java @@ -26,20 +26,24 @@ package org.geysermc.floodgate.listener; import com.destroystokyo.paper.event.profile.PreFillProfileEvent; -import com.destroystokyo.paper.profile.PlayerProfile; import com.destroystokyo.paper.profile.ProfileProperty; import com.google.inject.Inject; import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; import org.geysermc.floodgate.api.SimpleFloodgateApi; import org.geysermc.floodgate.api.player.FloodgatePlayer; +import org.geysermc.floodgate.util.Constants; public final class PaperProfileListener implements Listener { + private static final ProfileProperty DEFAULT_TEXTURE_PROPERTY = new ProfileProperty( + "textures", + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_TEXTURE, + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_SIGNATURE + ); + @Inject private SimpleFloodgateApi api; @EventHandler @@ -62,26 +66,8 @@ public void onFill(PreFillProfileEvent event) { } Set properties = new HashSet<>(event.getPlayerProfile().getProperties()); - properties.add(new ProfileProperty("textures", "", "")); - event.setProperties(properties); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - Player bukkitPlayer = event.getPlayer(); - FloodgatePlayer player = api.getPlayer(bukkitPlayer.getUniqueId()); - if (player == null || player.isLinked()) { - return; - } - - PlayerProfile profile = bukkitPlayer.getPlayerProfile(); - if (profile.getProperties().stream().noneMatch( - prop -> "textures".equals(prop.getName()) && prop.getValue().isEmpty() - && prop.getSignature() != null && prop.getSignature().isEmpty())) { - return; - } + properties.add(DEFAULT_TEXTURE_PROPERTY); - profile.removeProperty("textures"); - bukkitPlayer.setPlayerProfile(profile); + event.setProperties(properties); } } diff --git a/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java b/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java index 8000f520..82c7abcc 100644 --- a/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java +++ b/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java @@ -36,6 +36,7 @@ import com.google.common.cache.CacheBuilder; import com.google.inject.Inject; import com.google.inject.name.Named; +import com.velocitypowered.api.event.Continuation; import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.DisconnectEvent; @@ -48,7 +49,7 @@ import io.netty.channel.Channel; import io.netty.util.AttributeKey; import java.lang.reflect.Field; -import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; import net.kyori.adventure.text.Component; @@ -56,12 +57,16 @@ import org.geysermc.floodgate.api.logger.FloodgateLogger; import org.geysermc.floodgate.api.player.FloodgatePlayer; import org.geysermc.floodgate.config.ProxyFloodgateConfig; +import org.geysermc.floodgate.skin.SkinDataImpl; +import org.geysermc.floodgate.util.Constants; import org.geysermc.floodgate.util.LanguageManager; +import org.geysermc.floodgate.util.MojangUtils; public final class VelocityListener { private static final Field INITIAL_MINECRAFT_CONNECTION; private static final Field INITIAL_CONNECTION_DELEGATE; private static final Field CHANNEL; + private static final Property DEFAULT_TEXTURE_PROPERTY; static { Class initialConnection = getPrefixedClass("connection.client.InitialInboundConnection"); @@ -82,6 +87,12 @@ public final class VelocityListener { } CHANNEL = getFieldOfType(minecraftConnection, Channel.class); + + DEFAULT_TEXTURE_PROPERTY = new Property( + "textures", + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_TEXTURE, + Constants.DEFAULT_MINECRAFT_JAVA_SKIN_SIGNATURE + ); } private final Cache playerCache = @@ -103,6 +114,9 @@ public final class VelocityListener { @Named("kickMessageAttribute") private AttributeKey kickMessageAttribute; + @Inject + private MojangUtils mojangUtils; + @Subscribe(order = PostOrder.EARLY) public void onPreLogin(PreLoginEvent event) { FloodgatePlayer player = null; @@ -139,22 +153,38 @@ public void onPreLogin(PreLoginEvent event) { } @Subscribe(order = PostOrder.EARLY) - public void onGameProfileRequest(GameProfileRequestEvent event) { + public void onGameProfileRequest(GameProfileRequestEvent event, Continuation continuation) { FloodgatePlayer player = playerCache.getIfPresent(event.getConnection()); - if (player != null) { - playerCache.invalidate(event.getConnection()); + if (player == null) { + return; + } + playerCache.invalidate(event.getConnection()); - GameProfile profile = new GameProfile( + // Skin look up (on Spigot and friends) would result in it failing, so apply a default skin + if (!player.isLinked()) { + event.setGameProfile(new GameProfile( player.getCorrectUniqueId(), player.getCorrectUsername(), - Collections.emptyList() - ); - // The texture properties addition is to fix the February 2 2022 Mojang authentication changes - if (!config.isSendFloodgateData() && !player.isLinked()) { - profile = profile.addProperty(new Property("textures", "", "")); - } - event.setGameProfile(profile); + List.of(DEFAULT_TEXTURE_PROPERTY) + )); + return; } + + // Floodgate players are seen as offline mode players, meaning we have to look up + // the linked player's textures ourselves + + mojangUtils.skinFor(player.getJavaUniqueId()) + .exceptionally(exception -> { + logger.debug("Unexpected skin fetch error for " + player.getJavaUniqueId(), exception); + return SkinDataImpl.DEFAULT_SKIN; + }).thenAccept(skin -> { + event.setGameProfile(new GameProfile( + player.getCorrectUniqueId(), + player.getCorrectUsername(), + List.of(new Property("textures", skin.value(), skin.signature())) + )); + continuation.resume(); + }); } @Subscribe(order = PostOrder.LAST) From f1c52b48fc007a9aaeaa0a8d34da5f54ab1854f2 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Sat, 18 May 2024 17:43:33 +0200 Subject: [PATCH 5/9] Fixed recession in latest commit --- .../java/org/geysermc/floodgate/listener/VelocityListener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java b/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java index 82c7abcc..cd625957 100644 --- a/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java +++ b/velocity/src/main/java/org/geysermc/floodgate/listener/VelocityListener.java @@ -156,6 +156,7 @@ public void onPreLogin(PreLoginEvent event) { public void onGameProfileRequest(GameProfileRequestEvent event, Continuation continuation) { FloodgatePlayer player = playerCache.getIfPresent(event.getConnection()); if (player == null) { + continuation.resume(); return; } playerCache.invalidate(event.getConnection()); @@ -167,6 +168,7 @@ public void onGameProfileRequest(GameProfileRequestEvent event, Continuation con player.getCorrectUsername(), List.of(DEFAULT_TEXTURE_PROPERTY) )); + continuation.resume(); return; } From 792af7b0ddcd178fdaf9c5e5413920d491c88529 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Sun, 19 May 2024 00:10:17 +0200 Subject: [PATCH 6/9] Fixed bug in Bungee platform --- .../java/org/geysermc/floodgate/listener/BungeeListener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java b/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java index f7e4b6fd..fd1befb6 100644 --- a/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java +++ b/bungee/src/main/java/org/geysermc/floodgate/listener/BungeeListener.java @@ -131,6 +131,9 @@ public void onLogin(LoginEvent event) { @EventHandler(priority = EventPriority.LOWEST) public void onPostLogin(PostLoginEvent event) { FloodgatePlayer player = api.getPlayer(event.getPlayer().getUniqueId()); + if (player == null) { + return; + } // Skin look up (on Spigot and friends) would result in it failing, so apply a default skin if (!player.isLinked()) { From c4a44879b87c53818aba0a3e4327023d2be668de Mon Sep 17 00:00:00 2001 From: Kas-tle <26531652+Kas-tle@users.noreply.github.com> Date: Mon, 27 May 2024 11:15:11 -0700 Subject: [PATCH 7/9] Switch to centralized GitHub actions (#516) * Switch to centralized GitHub actions * Build number is in env for PR --- .github/workflows/build.yml | 103 +++++++++++++----------------- .github/workflows/pullrequest.yml | 22 ++++--- 2 files changed, 56 insertions(+), 69 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 66cb9840..c251f4a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,42 +5,44 @@ on: [push] jobs: build: runs-on: ubuntu-latest - env: - PROJECT: 'floodgate' steps: - - name: Set Build Number - env: - BUILD_JSON: ${{ vars.RELEASEACTION_PREVRELEASE }} - run: | - BUILD_NUMBER=$(echo $BUILD_JSON | jq --arg branch "${GITHUB_REF_NAME}" 'if .[$branch] == null then 1 else .[$branch] | .t | tonumber + 1 end // 1') - echo "BUILD_NUMBER=${BUILD_NUMBER:=$GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + - name: Get Release Info + id: release-info + uses: GeyserMC/actions/previous-release@master + with: + data: ${{ vars.RELEASEACTION_PREVRELEASE }} - name: Checkout repository and submodules # See https://github.com/actions/checkout/commits - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: submodules: recursive - name: Validate Gradle Wrapper # See https://github.com/gradle/wrapper-validation-action/commits - uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1 + uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 + - name: Setup Java # See https://github.com/actions/setup-java/commits - - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: java-version: 17 distribution: temurin - - name: Build + - name: Setup Gradle # See https://github.com/gradle/actions/commits uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 with: - arguments: build cache-read-only: ${{ github.ref_name != 'master' && github.ref_name != 'development' }} + + - name: Build Floodgate + run: ./gradlew build + env: + BUILD_NUMBER: ${{ steps.release-info.outputs.curentRelease }} - name: Archive artifacts (Floodgate Bungee) # See https://github.com/actions/upload-artifact/commits - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 if: success() with: name: Floodgate Bungee @@ -48,8 +50,7 @@ jobs: if-no-files-found: error - name: Archive artifacts (Floodgate Spigot) - # See https://github.com/actions/upload-artifact/commits - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 if: success() with: name: Floodgate Spigot @@ -57,8 +58,7 @@ jobs: if-no-files-found: error - name: Archive artifacts (Floodgate Velocity) - # See https://github.com/actions/upload-artifact/commits - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 if: success() with: name: Floodgate Velocity @@ -67,18 +67,23 @@ jobs: - name: Publish to Maven Repository if: ${{ github.repository == 'GeyserMC/Floodgate' }} - uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 + run: ./gradlew publish env: + BUILD_NUMBER: ${{ steps.release-info.outputs.curentRelease }} ORG_GRADLE_PROJECT_geysermcUsername: ${{ vars.DEPLOY_USER }} ORG_GRADLE_PROJECT_geysermcPassword: ${{ secrets.DEPLOY_PASS }} - with: - arguments: publish - cache-read-only: ${{ github.ref_name != 'master' && github.ref_name != 'development' }} + + - name: Get Version + if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }} + id: get-version + run: | + version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2) + echo "VERSION=${version}" >> $GITHUB_OUTPUT - name: Get Release Metadata if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }} - # See https://github.com/Kas-tle/base-release-action/releases/tag/main-11 - uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # main-11 + uses: GeyserMC/actions/release@master + id: metadata with: appID: ${{ secrets.RELEASE_APP_ID }} appPrivateKey: ${{ secrets.RELEASE_APP_PK }} @@ -88,45 +93,25 @@ jobs: velocity:velocity/build/libs/floodgate-velocity.jar releaseEnabled: false saveMetadata: true - - - name: Update Generated Metadata - if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }} - run: | - cat metadata.json - echo - mv metadata.json metadata.json.tmp - version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2) - jq --arg project "${PROJECT}" --arg version "${version}" ' - . - | .changes |= map({"commit", "summary", "message"}) - | .downloads |= map_values({"name", "sha256"}) - | {$project, "repo", $version, "number": .build, "changes", "downloads"} - ' metadata.json.tmp > metadata.json - cat metadata.json + releaseProject: 'floodgate' + releaseVersion: ${{ steps.get-version.outputs.VERSION }} - name: Publish to Downloads API if: ${{ success() && github.ref_name == 'master' && github.repository == 'GeyserMC/Floodgate' }} - shell: bash - env: - DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }} - DOWNLOADS_PRIVATE_KEY: ${{ secrets.DOWNLOADS_PRIVATE_KEY }} - DOWNLOADS_SERVER_IP: ${{ secrets.DOWNLOADS_SERVER_IP }} - run: | - # Save the private key to a file - echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa - chmod 600 id_ecdsa - # Create the build folder - ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/" - # Copy over artifacts - rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" bungee/build/libs/floodgate-bungee.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/ - rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" spigot/build/libs/floodgate-spigot.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/ - rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" velocity/build/libs/floodgate-velocity.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/ - # Run the build script - rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/ + uses: GeyserMC/actions/upload-release@master + with: + username: ${{ vars.DOWNLOADS_USERNAME }} + privateKey: ${{ secrets.DOWNLOADS_PRIVATE_KEY }} + host: ${{ secrets.DOWNLOADS_SERVER_IP }} + files: | + bungee/build/libs/floodgate-bungee.jar + spigot/build/libs/floodgate-spigot.jar + velocity/build/libs/floodgate-velocity.jar - name: Notify Discord if: ${{ (success() || failure()) && github.repository == 'GeyserMC/Floodgate' }} - # See https://github.com/Tim203/actions-git-discord-webhook/commits - uses: Tim203/actions-git-discord-webhook@70f38ded3aca51635ec978ab4e1a58cd4cd0c2ff + uses: GeyserMC/actions/notify-discord@master with: - webhook_url: ${{ secrets.DISCORD_WEBHOOK }} + discordWebhook: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ job.status }} + body: ${{ steps.metadata.outputs.body }} diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 1b64603f..8d59fecf 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -14,31 +14,33 @@ jobs: - name: Checkout repository and submodules # See https://github.com/actions/checkout/commits - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: submodules: recursive - name: Validate Gradle Wrapper # See https://github.com/gradle/wrapper-validation-action/commits - uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1 + uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 - - name: Set up JDK 17 + - name: Setup Java # See https://github.com/actions/setup-java/commits - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: java-version: 17 distribution: temurin - - name: Build Floodgate + - name: Setup Gradle # See https://github.com/gradle/actions/commits - uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 with: - arguments: build cache-read-only: true + - name: Build Floodgate + run: ./gradlew build + - name: Archive artifacts (Floodgate Bungee) # See https://github.com/actions/upload-artifact/commits - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 if: success() with: name: Floodgate Bungee @@ -46,7 +48,7 @@ jobs: if-no-files-found: error - name: Archive artifacts (Floodgate Spigot) - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 if: success() with: name: Floodgate Spigot @@ -54,7 +56,7 @@ jobs: if-no-files-found: error - name: Archive artifacts (Floodgate Velocity) - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 if: success() with: name: Floodgate Velocity From e1bae5765bc447e646bd21474216b4a53d73666e Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:01:39 -0400 Subject: [PATCH 8/9] Do not swallow errors on Spigot --- .../org/geysermc/floodgate/SpigotPlugin.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/spigot/src/main/java/org/geysermc/floodgate/SpigotPlugin.java b/spigot/src/main/java/org/geysermc/floodgate/SpigotPlugin.java index 2a5af4ee..a12c41a8 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/SpigotPlugin.java +++ b/spigot/src/main/java/org/geysermc/floodgate/SpigotPlugin.java @@ -67,17 +67,12 @@ public void onEnable() { boolean usePaperListener = ReflectionUtils.getClassSilently( "com.destroystokyo.paper.event.profile.PreFillProfileEvent") != null; - try { - platform.enable( - new SpigotCommandModule(this), - new SpigotAddonModule(), - new PluginMessageModule(), - (usePaperListener ? new PaperListenerModule() : new SpigotListenerModule()) - ); - } catch (Exception exception) { - Bukkit.getPluginManager().disablePlugin(this); - throw exception; - } + platform.enable( + new SpigotCommandModule(this), + new SpigotAddonModule(), + new PluginMessageModule(), + (usePaperListener ? new PaperListenerModule() : new SpigotListenerModule()) + ); injector.getInstance(HandshakeHandlers.class) .addHandshakeHandler(injector.getInstance(SpigotHandshakeHandler.class)); From 49bd56446fa10931b1c4abf6609055571a4ae105 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 14 Jun 2024 04:08:27 +0200 Subject: [PATCH 9/9] Preliminary 1.21 Spigot support (#521) --- build-logic/src/main/kotlin/Versions.kt | 3 +-- spigot/build.gradle.kts | 4 +++- .../org/geysermc/floodgate/module/SpigotCommandModule.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build-logic/src/main/kotlin/Versions.kt b/build-logic/src/main/kotlin/Versions.kt index d04e0f59..f22b3d80 100644 --- a/build-logic/src/main/kotlin/Versions.kt +++ b/build-logic/src/main/kotlin/Versions.kt @@ -33,8 +33,7 @@ object Versions { const val guiceVersion = "6.0.0" const val nettyVersion = "4.1.49.Final" const val snakeyamlVersion = "1.28" - // TODO move to cloud release once those have 1.20.5 support - const val cloudVersion = "2.0.0-beta.7" // for cloud-minecraft + const val cloudVersion = "2.0.0-SNAPSHOT" // for cloud-minecraft const val cloudCore = "2.0.0-rc.1" const val bstatsVersion = "3.0.2" diff --git a/spigot/build.gradle.kts b/spigot/build.gradle.kts index 6e95bae1..af449d2f 100644 --- a/spigot/build.gradle.kts +++ b/spigot/build.gradle.kts @@ -13,7 +13,9 @@ indra { dependencies { api(projects.core) - implementation("org.incendo", "cloud-paper", Versions.cloudVersion) + //implementation("org.incendo", "cloud-paper", Versions.cloudVersion) + // TODO change back after https://github.com/incendo/cloud-minecraft is merged + implementation("com.github.onebeastchris.cloud-minecraft", "cloud-paper", "jitpack-SNAPSHOT") // hack to make pre 1.12 work implementation("com.google.guava", "guava", guavaVersion) diff --git a/spigot/src/main/java/org/geysermc/floodgate/module/SpigotCommandModule.java b/spigot/src/main/java/org/geysermc/floodgate/module/SpigotCommandModule.java index 959c4ac0..d616181e 100644 --- a/spigot/src/main/java/org/geysermc/floodgate/module/SpigotCommandModule.java +++ b/spigot/src/main/java/org/geysermc/floodgate/module/SpigotCommandModule.java @@ -40,7 +40,7 @@ import org.geysermc.floodgate.player.audience.FloodgateSenderMapper; import org.incendo.cloud.CommandManager; import org.incendo.cloud.execution.ExecutionCoordinator; -import org.incendo.cloud.paper.PaperCommandManager; +import org.incendo.cloud.paper.LegacyPaperCommandManager; @RequiredArgsConstructor public final class SpigotCommandModule extends CommandModule { @@ -56,7 +56,7 @@ protected void configure() { @Singleton @SneakyThrows public CommandManager commandManager(CommandUtil commandUtil) { - CommandManager commandManager = new PaperCommandManager<>( + CommandManager commandManager = new LegacyPaperCommandManager<>( plugin, ExecutionCoordinator.simpleCoordinator(), new FloodgateSenderMapper<>(commandUtil)