From d844216e8033e9ddfc472845fdb3fbabb8b3c0e4 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Sun, 11 Apr 2021 19:43:41 +0200 Subject: [PATCH] Limit Bungee injection tries. Explicitly define cumulus in the api pom --- api/pom.xml | 5 +++++ .../floodgate/inject/bungee/BungeeInjector.java | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/api/pom.xml b/api/pom.xml index bf0f83e2..983ef45e 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -24,6 +24,11 @@ common ${geyser.version} + + org.geysermc.cumulus + cumulus + ${cumulus.version} + diff --git a/bungee/src/main/java/org/geysermc/floodgate/inject/bungee/BungeeInjector.java b/bungee/src/main/java/org/geysermc/floodgate/inject/bungee/BungeeInjector.java index f95b6992..aede3b84 100644 --- a/bungee/src/main/java/org/geysermc/floodgate/inject/bungee/BungeeInjector.java +++ b/bungee/src/main/java/org/geysermc/floodgate/inject/bungee/BungeeInjector.java @@ -95,12 +95,24 @@ public final class BungeeInjector extends CommonPlatformInjector { // we're getting called before the decoder and encoder are added. // we'll have to wait a while :( ctx.executor().execute(() -> { + int tries = 0; while (ctx.channel().isOpen()) { if (ctx.channel().pipeline().get(MinecraftEncoder.class) != null) { logger.debug("found packet encoder :)"); ctx.channel().pipeline().addFirst(new BungeeInjectorInitializer()); return; } + + // half a second should be more than enough + if (++tries > 25) { + logger.debug("Failed to inject " + ctx.channel().pipeline()); + return; + } + + try { + Thread.sleep(20); + } catch (InterruptedException ignored) { + } } }); }