Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ jobs:
with:
submodules: recursive

- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '8'
java-version: '17'
cache: 'gradle'

- name: Build with Maven
run: ./gradlew build

- name: Archive artifacts (Floodgate Bungee)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: success()
with:
name: Floodgate Bungee
path: bungee/build/libs/connect-bungee.jar

- name: Archive artifacts (Floodgate Spigot)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: success()
with:
name: Floodgate Spigot
path: spigot/build/libs/connect-spigot.jar

- name: Archive artifacts (Floodgate Velocity)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: success()
with:
name: Floodgate Velocity
path: velocity/build/libs/connect-velocity.jar
path: velocity/build/libs/connect-velocity.jar
2 changes: 1 addition & 1 deletion bungee/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var bungeeVersion = "1.20-R0.3-SNAPSHOT"
var bungeeVersion = "1.21-R0.1-SNAPSHOT"
var gsonVersion = "2.8.0"
var guavaVersion = "21.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.local.LocalAddress;
import io.netty.util.AttributeKey;
Expand All @@ -46,18 +42,17 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.ProxyServer.Unsafe;
import net.md_5.bungee.api.config.ListenerInfo;
import net.md_5.bungee.api.event.ProxyReloadEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.MinecraftEncoder;
import net.md_5.bungee.protocol.Varint21LengthFieldPrepender;
import net.md_5.bungee.protocol.channel.BungeeChannelInitializer;

@RequiredArgsConstructor
public final class BungeeInjector extends CommonPlatformInjector implements Listener {
private static final String BUNGEE_INIT = "connect-bungee-init";

private final ConnectLogger logger;
private final ProxyServer proxy;
Expand All @@ -69,17 +64,27 @@ public final class BungeeInjector extends CommonPlatformInjector implements List
public boolean inject() {
try {
// Can everyone just switch to Velocity please :)
// :( ~BungeeCord Collaborator

Unsafe unsafe = ProxyServer.getInstance().unsafe();
BungeeChannelInitializer frontend = unsafe.getFrontendChannelInitializer();
unsafe.setFrontendChannelInitializer(BungeeChannelInitializer.create(channel -> {
if (!frontend.getChannelAcceptor().accept(channel)) {
return false;
}
injectClient(channel, true);
return true;
}));

BungeeChannelInitializer backend = unsafe.getBackendChannelInitializer();
unsafe.setBackendChannelInitializer(BungeeChannelInitializer.create(channel -> {
if (!backend.getChannelAcceptor().accept(channel)) {
return false;
}
injectClient(channel, false);
return true;
}));

// Field framePrepender = ReflectionUtils.getField(PipelineUtils.class, "framePrepender");
//
// // Required in order to inject into both Geyser <-> proxy AND proxy <-> server
// // (Instead of just replacing the ChannelInitializer which is only called for
// // player <-> proxy)
// BungeeCustomPrepender customPrepender = new BungeeCustomPrepender(
// this, ReflectionUtils.castedStaticValue(framePrepender)
// );
//
// BungeeReflectionUtils.setFieldValue(null, framePrepender, customPrepender);
initializeLocalChannel0();
injected = true;
return true;
Expand Down Expand Up @@ -129,6 +134,13 @@ private void initializeLocalChannel0() throws Exception {
"Connect does not currently support multiple listeners with injection! " +
"Please reach out to us on our Discord at https://minekube.com/discord so we can hear feedback on your setup.");
}

try {
ProxyServer.class.getMethod("unsafe");
} catch (NoSuchMethodException e) {
throw new UnsupportedOperationException("You're using an outdated version of BungeeCord - please update. Thank you!");
}

ListenerInfo listenerInfo = proxy.getConfig().getListeners().stream().findFirst().orElseThrow(
IllegalStateException::new);

Expand Down Expand Up @@ -202,7 +214,7 @@ protected void initChannel(Channel ch) throws Exception {
if (channelInitializer == null) {
// Proxy has finished initializing; we can safely grab this variable without fear of plugins modifying it
// (Older versions of ViaVersion replace this to inject)
channelInitializer = PipelineUtils.SERVER_CHILD;
channelInitializer = proxy.unsafe().getFrontendChannelInitializer().getChannelInitializer();
}
initChannel.invoke(channelInitializer, ch);
}
Expand Down Expand Up @@ -258,75 +270,7 @@ public void onProxyReload(ProxyReloadEvent event) {
// End of logic from GeyserMC

void injectClient(Channel channel, boolean clientToProxy) {
if (!channel.isOpen()) {
return;
}

if (channel.pipeline().get(MinecraftEncoder.class) == null) {
logger.debug(
"Minecraft encoder not found while injecting! {}",
String.join(", ", channel.pipeline().names())
);
return;
}

injectAddonsCall(channel, !clientToProxy);
addInjectedClient(channel);
}

@RequiredArgsConstructor
private static final class BungeeCustomPrepender extends Varint21LengthFieldPrepender {
private final BungeeInjector injector;
private final Varint21LengthFieldPrepender original;

@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
original.handlerAdded(ctx);
// The Minecraft encoder being in the pipeline isn't present until later

if (ctx.channel().parent() != null) {
// Client <-> Proxy
ctx.pipeline().addBefore(
PipelineUtils.FRAME_DECODER, BUNGEE_INIT,
new BungeeClientToProxyInjectInitializer(injector)
);
} else {
// Proxy <-> Server
ctx.pipeline().addLast(
BUNGEE_INIT, new BungeeProxyToServerInjectInitializer(injector)
);
}
}
}

@RequiredArgsConstructor
private static final class BungeeClientToProxyInjectInitializer
extends ChannelInboundHandlerAdapter {

private final BungeeInjector injector;

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
injector.injectClient(ctx.channel(), true);

ctx.pipeline().remove(this);
super.channelRead(ctx, msg);
}
}

@RequiredArgsConstructor
private static final class BungeeProxyToServerInjectInitializer
extends ChannelOutboundHandlerAdapter {

private final BungeeInjector injector;

@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
throws Exception {
injector.injectClient(ctx.channel(), false);

ctx.pipeline().remove(this);
super.write(ctx, msg, promise);
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import com.minekube.connect.platform.command.CommandUtil;
import com.minekube.connect.platform.listener.ListenerRegistration;
import com.minekube.connect.platform.util.PlatformUtils;
import com.minekube.connect.pluginmessage.SpigotSkinApplier;
import com.minekube.connect.skin.SkinApplier;
import com.minekube.connect.util.LanguageManager;
import com.minekube.connect.util.SpigotCommandUtil;
import com.minekube.connect.util.SpigotPlatformUtils;
Expand Down Expand Up @@ -159,12 +157,6 @@ public String platformName() {
// return new SpigotPluginMessageRegistration(plugin);
// }

@Provides
@Singleton
public SkinApplier skinApplier(SpigotVersionSpecificMethods versionSpecificMethods) {
return new SpigotSkinApplier(versionSpecificMethods, plugin);
}

@Provides
@Singleton
public SpigotVersionSpecificMethods versionSpecificMethods() {
Expand Down
Loading