Skip to content

Commit 8e604d2

Browse files
committed
Support up to Minecraft 1.20.6
1 parent 7d61f97 commit 8e604d2

File tree

11 files changed

+69
-247
lines changed

11 files changed

+69
-247
lines changed

api/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
dependencies {
24
api("com.google.code.gson", "gson", Versions.gsonVersion)
35

46
compileOnly("io.netty", "netty-transport", Versions.nettyVersion)
57
}
8+
9+
tasks {
10+
named<Jar>("jar") {
11+
archiveClassifier.set("")
12+
}
13+
named<ShadowJar>("shadowJar") {
14+
archiveClassifier.set("shaded")
15+
}
16+
}

build-logic/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "build-logic"

build-logic/src/main/kotlin/Versions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
object Versions {
2727
const val spigotVersion = "1.19.4-R0.1-SNAPSHOT"
2828
const val configUtilsVersion = "1.0-SNAPSHOT"
29-
const val guiceVersion = "5.0.1"
29+
const val guiceVersion = "6.0.0"
3030
const val nettyVersion = "4.1.49.Final"
3131
const val snakeyamlVersion = "1.28"
3232
const val cloudVersion = "1.5.0"
@@ -35,7 +35,7 @@ object Versions {
3535
const val viaVersionVersion = "4.0.0"
3636
const val gRPCVersion = "1.44.0"
3737
const val protocVersion = "3.19.4"
38-
const val bstatsVersion = "3.0.0"
38+
const val bstatsVersion = "3.0.2"
3939
const val gsonVersion = "2.8.6"
4040

4141
const val checkerQual = "3.19.0"

bungee/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var bungeeCommit = "master-SNAPSHOT"
1+
var bungeeVersion = "1.20-R0.3-SNAPSHOT"
22
var gsonVersion = "2.8.0"
33
var guavaVersion = "21.0"
44

@@ -17,6 +17,6 @@ relocate("io.leangen.geantyref")
1717
relocate("org.yaml")
1818

1919
// these dependencies are already present on the platform
20-
provided("com.github.SpigotMC.BungeeCord", "bungeecord-proxy", bungeeCommit)
20+
provided("net.md-5", "bungeecord-proxy", bungeeVersion)
2121
provided("com.google.code.gson", "gson", gsonVersion)
2222
provided("com.google.guava", "guava", guavaVersion)

core/src/main/java/com/minekube/connect/addon/DebugAddon.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
import com.google.inject.name.Named;
3030
import com.minekube.connect.addon.debug.ChannelInDebugHandler;
3131
import com.minekube.connect.addon.debug.ChannelOutDebugHandler;
32-
import com.minekube.connect.addon.debug.StateChangeDetector;
3332
import com.minekube.connect.api.inject.InjectorAddon;
3433
import com.minekube.connect.api.logger.ConnectLogger;
3534
import com.minekube.connect.config.ConnectConfig;
3635
import com.minekube.connect.util.Utils;
3736
import io.netty.channel.Channel;
3837
import io.netty.channel.ChannelPipeline;
38+
import java.util.concurrent.atomic.AtomicInteger;
3939

4040
public final class DebugAddon implements InjectorAddon {
4141
@Inject private ConnectConfig config;
@@ -57,16 +57,14 @@ public final class DebugAddon implements InjectorAddon {
5757
public void onInject(Channel channel, boolean toServer) {
5858
logger.info("Successfully called onInject. To server? " + toServer);
5959

60-
StateChangeDetector changeDetector = new StateChangeDetector(
61-
channel, packetEncoder, packetDecoder, logger
62-
);
60+
AtomicInteger packetCount = new AtomicInteger();
6361

6462
channel.pipeline().addBefore(
6563
packetEncoder, "connect_debug_out",
66-
new ChannelOutDebugHandler(platformName, toServer, changeDetector, logger)
64+
new ChannelOutDebugHandler(platformName, toServer, packetCount, logger)
6765
).addBefore(
6866
packetDecoder, "connect_debug_in",
69-
new ChannelInDebugHandler(platformName, toServer, changeDetector, logger)
67+
new ChannelInDebugHandler(platformName, toServer, packetCount, logger)
7068
);
7169
}
7270

core/src/main/java/com/minekube/connect/addon/debug/ChannelInDebugHandler.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,44 @@
2626
package com.minekube.connect.addon.debug;
2727

2828
import com.minekube.connect.api.logger.ConnectLogger;
29+
import com.minekube.connect.util.Utils;
2930
import io.netty.buffer.ByteBuf;
3031
import io.netty.buffer.ByteBufUtil;
3132
import io.netty.channel.ChannelHandler.Sharable;
3233
import io.netty.channel.ChannelHandlerContext;
3334
import io.netty.channel.SimpleChannelInboundHandler;
35+
import java.util.concurrent.atomic.AtomicInteger;
3436

3537
@Sharable
3638
public final class ChannelInDebugHandler extends SimpleChannelInboundHandler<ByteBuf> {
3739
private final String direction;
3840
private final ConnectLogger logger;
3941

4042
private final boolean toServer;
41-
private final StateChangeDetector changeDetector;
43+
private final AtomicInteger packetCount;
4244

4345
public ChannelInDebugHandler(
4446
String implementationType,
4547
boolean toServer,
46-
StateChangeDetector changeDetector,
48+
AtomicInteger changeDetector,
4749
ConnectLogger logger) {
4850
this.direction = (toServer ? "Server -> " : "Player -> ") + implementationType;
4951
this.logger = logger;
5052
this.toServer = toServer;
51-
this.changeDetector = changeDetector;
53+
this.packetCount = changeDetector;
5254
}
5355

5456
@Override
5557
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
5658
try {
5759
int index = msg.readerIndex();
5860

59-
if (changeDetector.shouldPrintPacket(msg, !toServer)) {
61+
if (packetCount.getAndIncrement() < Utils.MAX_DEBUG_PACKET_COUNT) {
6062
logger.info("{} {}:\n{}",
6163
direction,
62-
changeDetector.getCurrentState(),
64+
packetCount.get(),
6365
ByteBufUtil.prettyHexDump(msg)
6466
);
65-
66-
changeDetector.checkPacket(msg, !toServer);
6767
}
6868

6969
// reset index

core/src/main/java/com/minekube/connect/addon/debug/ChannelOutDebugHandler.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,45 @@
2626
package com.minekube.connect.addon.debug;
2727

2828
import com.minekube.connect.api.logger.ConnectLogger;
29+
import com.minekube.connect.util.Utils;
2930
import io.netty.buffer.ByteBuf;
3031
import io.netty.buffer.ByteBufUtil;
3132
import io.netty.channel.ChannelHandler.Sharable;
3233
import io.netty.channel.ChannelHandlerContext;
3334
import io.netty.handler.codec.MessageToByteEncoder;
35+
import java.util.concurrent.atomic.AtomicInteger;
3436

3537
@Sharable
3638
public final class ChannelOutDebugHandler extends MessageToByteEncoder<ByteBuf> {
3739
private final String direction;
3840
private final ConnectLogger logger;
3941

4042
private final boolean toServer;
41-
private final StateChangeDetector changeDetector;
43+
private final AtomicInteger packetCount;
4244

4345
public ChannelOutDebugHandler(
4446
String implementationType,
4547
boolean toServer,
46-
StateChangeDetector changeDetector,
48+
AtomicInteger changeDetector,
4749
ConnectLogger logger) {
4850
this.direction = implementationType + (toServer ? " -> Server" : " -> Player");
4951
this.logger = logger;
5052
this.toServer = toServer;
51-
this.changeDetector = changeDetector;
53+
this.packetCount = changeDetector;
5254
}
5355

5456
@Override
5557
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) {
5658
try {
5759
int index = msg.readerIndex();
5860

59-
if (changeDetector.shouldPrintPacket(msg, toServer)) {
61+
if (packetCount.getAndIncrement() < Utils.MAX_DEBUG_PACKET_COUNT) {
6062
logger.info(
6163
"{} {}:\n{}",
6264
direction,
63-
changeDetector.getCurrentState(),
65+
packetCount.get(),
6466
ByteBufUtil.prettyHexDump(msg)
6567
);
66-
67-
// proxy acts as a client when it connects to a server
68-
changeDetector.checkPacket(msg, toServer);
6968
}
7069

7170
// reset index

core/src/main/java/com/minekube/connect/addon/debug/StateChangeDetector.java

Lines changed: 0 additions & 193 deletions
This file was deleted.

0 commit comments

Comments
 (0)