Skip to content

Commit

Permalink
Merge pull request #24 from basaigh/feature/1.20.5
Browse files Browse the repository at this point in the history
Add support for Java 1.21
  • Loading branch information
Tim203 authored Jun 21, 2024
2 parents a3903ad + a77afd1 commit cf5e27b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 57 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ protocol = "3.0.0.Beta2-20240616.144648-10"
raknet = "1.0.0.CR3-20240416.144209-1"
netty = "4.1.110.Final"
fastutil = "8.5.2"
mcprotocollib = "1.20.4-1"
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"
Expand All @@ -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" }

Expand Down
3 changes: 0 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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();
Expand Down
74 changes: 38 additions & 36 deletions src/main/java/org/geysermc/globallinkserver/java/JavaServer.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,43 +24,44 @@
*/
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.key.Key;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3i;
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;
Expand Down Expand Up @@ -129,23 +130,24 @@ 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,
false,
false,
false,
new PlayerSpawnInfo(
"minecraft:the_end",
"minecraft:the_end",
2,
Key.key("minecraft:the_end"),
100,
GameMode.SPECTATOR,
GameMode.SPECTATOR,
false,
false,
null,
100)));
100),
true));

session.send(new ClientboundPlayerAbilitiesPacket(false, false, true, false, 0f, 0f));

Expand All @@ -157,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

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/geysermc/globallinkserver/java/PacketHandler.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -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<String, JavaPlayer> javaPlayers = new HashMap<>();
Expand Down

0 comments on commit cf5e27b

Please sign in to comment.