Skip to content

Commit

Permalink
Velocity 218+ build support
Browse files Browse the repository at this point in the history
  • Loading branch information
hevav committed Jan 8, 2023
1 parent 331320b commit a9ac291
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ allprojects {
apply(plugin: "org.cadixdev.licenser")

setGroup("net.elytrium")
setVersion("1.0.8")
setVersion("1.0.9-SNAPSHOT")

compileJava {
getOptions().setEncoding("UTF-8")
Expand Down
4 changes: 3 additions & 1 deletion plugin/src/main/java/net/elytrium/limboapi/LimboAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.velocitypowered.natives.util.Natives;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.connection.client.InitialConnectSessionHandler;
import com.velocitypowered.proxy.event.VelocityEventManager;
import com.velocitypowered.proxy.network.Connections;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
Expand Down Expand Up @@ -159,8 +160,9 @@ public LimboAPI(Logger logger, ProxyServer server, Metrics.Factory metricsFactor
this.nextServer = new HashMap<>();
this.initialID = new HashMap<>();

boolean temp761VelocityUpdateFlag = InitialConnectSessionHandler.class.getDeclaredConstructors()[0].getParameterCount() != 2;
int maximumProtocolVersionNumber = ProtocolVersion.MAXIMUM_VERSION.getProtocol();
if (maximumProtocolVersionNumber < SUPPORTED_MAXIMUM_PROTOCOL_VERSION_NUMBER) {
if (temp761VelocityUpdateFlag || maximumProtocolVersionNumber < SUPPORTED_MAXIMUM_PROTOCOL_VERSION_NUMBER) {
LOGGER.error("Please update Velocity (https://papermc.io/downloads#Velocity). LimboAPI support: https://ely.su/discord");
this.server.shutdown();
} else if (maximumProtocolVersionNumber != SUPPORTED_MAXIMUM_PROTOCOL_VERSION_NUMBER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ private void initialize(MinecraftConnection connection) throws Throwable {
} else {
if (this.server.registerConnection(this.player)) {
try {
connection.setSessionHandler((InitialConnectSessionHandler) INITIAL_CONNECT_SESSION_HANDLER_CONSTRUCTOR.invokeExact(this.player));
connection.setSessionHandler(
(InitialConnectSessionHandler) INITIAL_CONNECT_SESSION_HANDLER_CONSTRUCTOR.invokeExact(this.player, this.server));
this.server.getEventManager().fire(new PostLoginEvent(this.player)).thenAccept(postLoginEvent -> {
try {
MC_CONNECTION_FIELD.set(this.handler, connection);
Expand Down Expand Up @@ -270,7 +271,7 @@ private void initialize(MinecraftConnection connection) throws Throwable {

INITIAL_CONNECT_SESSION_HANDLER_CONSTRUCTOR = MethodHandles
.privateLookupIn(InitialConnectSessionHandler.class, MethodHandles.lookup())
.findConstructor(InitialConnectSessionHandler.class, MethodType.methodType(void.class, ConnectedPlayer.class));
.findConstructor(InitialConnectSessionHandler.class, MethodType.methodType(void.class, ConnectedPlayer.class, VelocityServer.class));

CONNECT_TO_INITIAL_SERVER_METHOD = MethodHandles.privateLookupIn(AuthSessionHandler.class, MethodHandles.lookup())
.findVirtual(AuthSessionHandler.class, "connectToInitialServer", MethodType.methodType(CompletableFuture.class, ConnectedPlayer.class));
Expand Down

0 comments on commit a9ac291

Please sign in to comment.