From 416a6f8ce3ce9565a7ff89382a9f233f15437a92 Mon Sep 17 00:00:00 2001 From: basaigh <53559772+basaigh@users.noreply.github.com> Date: Fri, 3 May 2024 11:17:45 +0100 Subject: [PATCH 1/3] Add support for 1.20.5/6 --- gradle/libs.versions.toml | 4 +- .../globallinkserver/java/JavaPlayer.java | 8 +-- .../globallinkserver/java/JavaServer.java | 63 ++++++++++--------- .../globallinkserver/java/PacketHandler.java | 20 +++--- .../player/PlayerManager.java | 4 +- 5 files changed, 50 insertions(+), 49 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 066bea3..41495c5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ protocol = "3.0.0.Beta2-20240423.201358-2" raknet = "1.0.0.CR1-20240330.103819-16" netty = "4.1.80.Final" fastutil = "8.5.2" -mcprotocollib = "1.20.4-1" +mcprotocollib = "12b94d74" # Revert from jitpack after release adventure-text = "4.15.0-20231207.074016-23" # Match version to MCPL mariadb-client = "2.7.3" checker-qual = "3.21.1" @@ -20,7 +20,7 @@ raknet = { group = "org.cloudburstmc.netty", name = "netty-transport-raknet", ve netty-handler = { group = "io.netty", name = "netty-handler", version.ref = "netty" } fastutil-common = { module = "com.nukkitx.fastutil:fastutil-common", version.ref = "fastutil" } -mcprotocollib = { module = "com.github.steveice10:mcprotocollib", version.ref = "mcprotocollib" } +mcprotocollib = { module = "com.github.GeyserMC:mcprotocollib", version.ref = "mcprotocollib" } adventure-text-legacy = { module = "net.kyori:adventure-text-serializer-legacy", version.ref = "adventure-text" } mariadb-client = { module = "org.mariadb.jdbc:mariadb-java-client", version.ref = "mariadb-client" } diff --git a/src/main/java/org/geysermc/globallinkserver/java/JavaPlayer.java b/src/main/java/org/geysermc/globallinkserver/java/JavaPlayer.java index 2de33cc..1c8015f 100644 --- a/src/main/java/org/geysermc/globallinkserver/java/JavaPlayer.java +++ b/src/main/java/org/geysermc/globallinkserver/java/JavaPlayer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 GeyserMC + * Copyright (c) 2021-2024 GeyserMC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,12 +25,12 @@ package org.geysermc.globallinkserver.java; import com.github.steveice10.mc.auth.data.GameProfile; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket; -import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginDisconnectPacket; -import com.github.steveice10.packetlib.Session; import java.util.UUID; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.geysermc.globallinkserver.player.Player; +import org.geysermc.mcprotocollib.network.Session; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket; +import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundLoginDisconnectPacket; public class JavaPlayer implements Player { private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.legacyAmpersand(); diff --git a/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java b/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java index 9e1d063..2932ec4 100644 --- a/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java +++ b/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 GeyserMC + * Copyright (c) 2021-2024 GeyserMC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,36 +24,9 @@ */ package org.geysermc.globallinkserver.java; -import static com.github.steveice10.mc.protocol.codec.MinecraftCodec.CODEC; +import static org.geysermc.mcprotocollib.protocol.codec.MinecraftCodec.CODEC; import com.github.steveice10.mc.auth.service.SessionService; -import com.github.steveice10.mc.protocol.MinecraftConstants; -import com.github.steveice10.mc.protocol.MinecraftProtocol; -import com.github.steveice10.mc.protocol.ServerLoginHandler; -import com.github.steveice10.mc.protocol.data.game.command.CommandNode; -import com.github.steveice10.mc.protocol.data.game.command.CommandParser; -import com.github.steveice10.mc.protocol.data.game.command.CommandType; -import com.github.steveice10.mc.protocol.data.game.command.properties.IntegerProperties; -import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; -import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerSpawnInfo; -import com.github.steveice10.mc.protocol.data.game.level.notify.GameEvent; -import com.github.steveice10.mc.protocol.data.status.PlayerInfo; -import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo; -import com.github.steveice10.mc.protocol.data.status.VersionInfo; -import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandsPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerAbilitiesPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundSetDefaultSpawnPositionPacket; -import com.github.steveice10.packetlib.Server; -import com.github.steveice10.packetlib.event.server.ServerAdapter; -import com.github.steveice10.packetlib.event.server.ServerClosedEvent; -import com.github.steveice10.packetlib.event.server.SessionAddedEvent; -import com.github.steveice10.packetlib.event.session.ConnectedEvent; -import com.github.steveice10.packetlib.tcp.TcpServer; import java.util.Collections; import java.util.OptionalInt; import net.kyori.adventure.text.Component; @@ -61,6 +34,33 @@ import org.geysermc.globallinkserver.config.Config; import org.geysermc.globallinkserver.link.LinkManager; import org.geysermc.globallinkserver.player.PlayerManager; +import org.geysermc.mcprotocollib.network.Server; +import org.geysermc.mcprotocollib.network.event.server.ServerAdapter; +import org.geysermc.mcprotocollib.network.event.server.ServerClosedEvent; +import org.geysermc.mcprotocollib.network.event.server.SessionAddedEvent; +import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent; +import org.geysermc.mcprotocollib.network.tcp.TcpServer; +import org.geysermc.mcprotocollib.protocol.MinecraftConstants; +import org.geysermc.mcprotocollib.protocol.MinecraftProtocol; +import org.geysermc.mcprotocollib.protocol.ServerLoginHandler; +import org.geysermc.mcprotocollib.protocol.data.game.command.CommandNode; +import org.geysermc.mcprotocollib.protocol.data.game.command.CommandParser; +import org.geysermc.mcprotocollib.protocol.data.game.command.CommandType; +import org.geysermc.mcprotocollib.protocol.data.game.command.properties.IntegerProperties; +import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode; +import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerSpawnInfo; +import org.geysermc.mcprotocollib.protocol.data.game.level.notify.GameEvent; +import org.geysermc.mcprotocollib.protocol.data.status.PlayerInfo; +import org.geysermc.mcprotocollib.protocol.data.status.ServerStatusInfo; +import org.geysermc.mcprotocollib.protocol.data.status.VersionInfo; +import org.geysermc.mcprotocollib.protocol.data.status.handler.ServerInfoBuilder; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundCommandsPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerAbilitiesPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundSetDefaultSpawnPositionPacket; public class JavaServer implements org.geysermc.globallinkserver.Server { private final PlayerManager playerManager; @@ -137,7 +137,7 @@ public boolean startServer(Config config) { false, false, new PlayerSpawnInfo( - "minecraft:the_end", + 2, "minecraft:the_end", 100, GameMode.SPECTATOR, @@ -145,7 +145,8 @@ public boolean startServer(Config config) { false, false, null, - 100))); + 100), + true)); session.send(new ClientboundPlayerAbilitiesPacket(false, false, true, false, 0f, 0f)); diff --git a/src/main/java/org/geysermc/globallinkserver/java/PacketHandler.java b/src/main/java/org/geysermc/globallinkserver/java/PacketHandler.java index 86b6caa..bc773ed 100644 --- a/src/main/java/org/geysermc/globallinkserver/java/PacketHandler.java +++ b/src/main/java/org/geysermc/globallinkserver/java/PacketHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 GeyserMC + * Copyright (c) 2021-2024 GeyserMC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,18 +25,18 @@ package org.geysermc.globallinkserver.java; import com.github.steveice10.mc.auth.data.GameProfile; -import com.github.steveice10.mc.protocol.MinecraftConstants; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket; -import com.github.steveice10.packetlib.Session; -import com.github.steveice10.packetlib.event.session.ConnectedEvent; -import com.github.steveice10.packetlib.event.session.DisconnectedEvent; -import com.github.steveice10.packetlib.event.session.SessionAdapter; -import com.github.steveice10.packetlib.packet.Packet; import org.geysermc.globallinkserver.link.LinkManager; import org.geysermc.globallinkserver.player.PlayerManager; import org.geysermc.globallinkserver.util.CommandUtils; +import org.geysermc.mcprotocollib.network.Session; +import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent; +import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent; +import org.geysermc.mcprotocollib.network.event.session.SessionAdapter; +import org.geysermc.mcprotocollib.network.packet.Packet; +import org.geysermc.mcprotocollib.protocol.MinecraftConstants; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket; public class PacketHandler extends SessionAdapter { private final Session session; diff --git a/src/main/java/org/geysermc/globallinkserver/player/PlayerManager.java b/src/main/java/org/geysermc/globallinkserver/player/PlayerManager.java index ff6fcf7..1051162 100644 --- a/src/main/java/org/geysermc/globallinkserver/player/PlayerManager.java +++ b/src/main/java/org/geysermc/globallinkserver/player/PlayerManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 GeyserMC + * Copyright (c) 2021-2024 GeyserMC * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,6 @@ package org.geysermc.globallinkserver.player; import com.github.steveice10.mc.auth.data.GameProfile; -import com.github.steveice10.packetlib.Session; import it.unimi.dsi.fastutil.ints.IntSet; import java.util.ArrayList; import java.util.HashMap; @@ -36,6 +35,7 @@ import org.cloudburstmc.protocol.bedrock.util.ChainValidationResult; import org.geysermc.globallinkserver.bedrock.BedrockPlayer; import org.geysermc.globallinkserver.java.JavaPlayer; +import org.geysermc.mcprotocollib.network.Session; public class PlayerManager { private final Map javaPlayers = new HashMap<>(); From b147e24e43be1542d4cee45d2a1a8611fa62157a Mon Sep 17 00:00:00 2001 From: basaigh <53559772+basaigh@users.noreply.github.com> Date: Fri, 3 May 2024 11:27:33 +0100 Subject: [PATCH 2/3] Remove redundant repository --- settings.gradle.kts | 3 --- 1 file changed, 3 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index d54e6ba..3747c5f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,9 +12,6 @@ dependencyResolutionManagement { maven("https://jitpack.io") { content { includeGroupByRegex("com\\.github\\..*") } } - - // Remove when adventure snapshot is no longer used - maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") } } From a77afd195ca7fd58c37d557663148683e41e1dba Mon Sep 17 00:00:00 2001 From: Tim203 Date: Fri, 21 Jun 2024 19:27:42 +0200 Subject: [PATCH 3/3] Added support for 1.21 and fixed loading terrain --- gradle/libs.versions.toml | 2 +- .../geysermc/globallinkserver/java/JavaServer.java | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 41495c5..057d8d1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ protocol = "3.0.0.Beta2-20240423.201358-2" raknet = "1.0.0.CR1-20240330.103819-16" netty = "4.1.80.Final" fastutil = "8.5.2" -mcprotocollib = "12b94d74" # Revert from jitpack after release +mcprotocollib = "4f5f650" # Revert from jitpack after release adventure-text = "4.15.0-20231207.074016-23" # Match version to MCPL mariadb-client = "2.7.3" checker-qual = "3.21.1" diff --git a/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java b/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java index 2932ec4..8c1efdb 100644 --- a/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java +++ b/src/main/java/org/geysermc/globallinkserver/java/JavaServer.java @@ -29,6 +29,7 @@ import com.github.steveice10.mc.auth.service.SessionService; import java.util.Collections; import java.util.OptionalInt; +import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import org.cloudburstmc.math.vector.Vector3i; import org.geysermc.globallinkserver.config.Config; @@ -129,7 +130,7 @@ public boolean startServer(Config config) { session.send(new ClientboundLoginPacket( 0, false, - new String[] {"minecraft:the_end"}, + new Key[] {Key.key("minecraft:the_end")}, 1, 0, 0, @@ -138,7 +139,7 @@ public boolean startServer(Config config) { false, new PlayerSpawnInfo( 2, - "minecraft:the_end", + Key.key("minecraft:the_end"), 100, GameMode.SPECTATOR, GameMode.SPECTATOR, @@ -158,15 +159,15 @@ public boolean startServer(Config config) { // this packet is also required to let our player spawn, but the location itself doesn't matter session.send(new ClientboundSetDefaultSpawnPositionPacket(Vector3i.ZERO, 0)); - // Manually call the connect event - session.callEvent(new ConnectedEvent(session)); - // we have to listen to the teleport confirm on the PacketHandler to prevent respawn request packet spam, // so send it after calling ConnectedEvent which adds the PacketHandler as listener session.send(new ClientboundPlayerPositionPacket(0, 0, 0, 0, 0, 0)); // this packet is required since 1.20.3 session.send(new ClientboundGameEventPacket(GameEvent.LEVEL_CHUNKS_LOAD_START, null)); + + // Manually call the connect event + session.callEvent(new ConnectedEvent(session)); }); server.setGlobalFlag(MinecraftConstants.SERVER_COMPRESSION_THRESHOLD, 256); // default