Skip to content

Commit

Permalink
Merge branch 'master' into feature/viaproxy-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC authored Jan 19, 2024
2 parents 0040b6a + 509e00c commit 92b5051
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private ChannelInitializer<Channel> getChildHandler(GeyserBootstrap bootstrap, C
childHandler = (ChannelInitializer<Channel>) childHandlerField.get(handler);
// ViaVersion non-Paper-injector workaround so we aren't double-injecting
if (isViaVersion && childHandler instanceof BukkitChannelInitializer) {
childHandler = ((BukkitChannelInitializer) childHandler).getOriginal();
childHandler = ((BukkitChannelInitializer) childHandler).original();
}
break;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ public void onLoad() {
}
}

try {
Class.forName("io.netty.util.internal.ObjectPool$ObjectCreator");
} catch (ClassNotFoundException e) {
getLogger().severe("*********************************************");
getLogger().severe("");
getLogger().severe("This version of Spigot is using an outdated version of netty. Please use Paper instead!");
getLogger().severe("");
getLogger().severe("*********************************************");
return;
}

// This is manually done instead of using Bukkit methods to save the config because otherwise comments get removed
try {
if (!getDataFolder().exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ public GameMode getDefaultGameMode(GeyserSession session) {

@Override
public boolean hasPermission(GeyserSession session, String permission) {
return Objects.requireNonNull(Bukkit.getPlayer(session.getPlayerEntity().getUsername())).hasPermission(permission);
Player player = Bukkit.getPlayer(session.javaUuid());
if (player != null) {
return player.hasPermission(permission);
}
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ public class GeyserVelocityCompressionDisabler extends ChannelDuplexHandler {
Method setCompressionMethod = null;

try {
compressionPacketClass = Class.forName("com.velocitypowered.proxy.protocol.packet.SetCompression");
loginSuccessPacketClass = Class.forName("com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess");
try {
compressionPacketClass = Class.forName("com.velocitypowered.proxy.protocol.packet.SetCompressionPacket");
loginSuccessPacketClass = Class.forName("com.velocitypowered.proxy.protocol.packet.ServerLoginSuccessPacket");
} catch (Exception ignored) {
// Velocity renamed packet classes in https://github.com/PaperMC/Velocity/commit/2ac8751337befd04f4663575f5d752c748384110
compressionPacketClass = Class.forName("com.velocitypowered.proxy.protocol.packet.SetCompression");
loginSuccessPacketClass = Class.forName("com.velocitypowered.proxy.protocol.packet.ServerLoginSuccess");
}
compressionEnabledEvent = Class.forName("com.velocitypowered.proxy.protocol.VelocityConnectionEvent")
.getDeclaredField("COMPRESSION_ENABLED").get(null);
setCompressionMethod = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public final class BlockStateValues {
private static final Int2IntMap SKULL_WALL_DIRECTIONS = new Int2IntOpenHashMap();
private static final Int2ByteMap SHULKERBOX_DIRECTIONS = new FixedInt2ByteMap();
private static final Int2IntMap WATER_LEVEL = new Int2IntOpenHashMap();
private static final IntSet UPPER_DOORS = new IntOpenHashSet();

public static final int JAVA_AIR_ID = 0;

Expand Down Expand Up @@ -219,6 +220,10 @@ public static void storeBlockStateValues(String javaId, int javaBlockState, Json
if (javaId.contains("_cauldron") && !javaId.contains("water_")) {
NON_WATER_CAULDRONS.add(javaBlockState);
}

if (javaId.contains("_door[") && javaId.contains("half=upper")) {
UPPER_DOORS.add(javaBlockState);
}
}

/**
Expand Down Expand Up @@ -498,6 +503,16 @@ public static int getWaterLevel(int state) {
return WATER_LEVEL.getOrDefault(state, -1);
}

/**
* Check if a block is the upper half of a door.
*
* @param state BlockState of the block
* @return True if the block is the upper half of a door
*/
public static boolean isUpperDoor(int state) {
return UPPER_DOORS.contains(state);
}

/**
* Get the height of water from the block state
* This is used in FishingHookEntity to create splash sounds when the hook hits the water. In addition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import io.netty.buffer.Unpooled;
import org.cloudburstmc.protocol.bedrock.BedrockDisconnectReasons;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.cloudburstmc.protocol.bedrock.codec.compat.BedrockCompat;
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
import org.cloudburstmc.protocol.bedrock.data.ExperimentData;
import org.cloudburstmc.protocol.bedrock.data.PacketCompressionAlgorithm;
import org.cloudburstmc.protocol.bedrock.data.ResourcePackType;
Expand Down Expand Up @@ -108,6 +110,10 @@ private boolean setCorrectCodec(int protocolVersion) {
session.disconnect(disconnectMessage);
return false;
} else if (protocolVersion < GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
if (protocolVersion < Bedrock_v622.CODEC.getProtocolVersion()) {
// https://github.com/GeyserMC/Geyser/issues/4378
session.getUpstream().getSession().setCodec(BedrockCompat.CODEC_LEGACY);
}
session.disconnect(GeyserLocale.getLocaleStringLog("geyser.network.outdated.client", supportedVersions));
return false;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,15 @@ public void sendDownstreamLoginPacket(Packet packet) {
* @param intendedState the state the client should be in
*/
public void sendDownstreamPacket(Packet packet, ProtocolState intendedState) {
// protocol can be null when we're not yet logged in (online auth)
if (protocol == null) {
if (geyser.getConfig().isDebugMode()) {
geyser.getLogger().debug("Tried to send downstream packet with no downstream session!");
Thread.dumpStack();
}
return;
}

if (protocol.getState() != intendedState) {
geyser.getLogger().debug("Tried to send " + packet.getClass().getSimpleName() + " packet while not in " + intendedState.name() + " state");
return;
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/geysermc/geyser/util/ChunkUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ public static void updateBlockClientSide(GeyserSession session, int blockState,
break; //No block will be a part of two classes
}
}

if (BlockStateValues.isUpperDoor(blockState)) {
// Update the lower door block as Bedrock client doesn't like door to be closed from the top
// See https://github.com/GeyserMC/Geyser/issues/4358
Vector3i belowDoorPosition = position.sub(0, 1, 0);
int belowDoorBlockState = session.getGeyser().getWorldManager().getBlockAt(session, belowDoorPosition.getX(), belowDoorPosition.getY(), belowDoorPosition.getZ());
updateBlock(session, belowDoorBlockState, belowDoorPosition);
}
}

public static void sendEmptyChunk(GeyserSession session, int chunkX, int chunkZ, boolean forceUpdate) {
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ erosion = "1.0-20230406.174837-8"
events = "1.1-SNAPSHOT"
jackson = { strictly = "2.14.0" } # Don't let other dependencies override
fastutil = "8.5.2"
netty = "4.1.80.Final"
netty = "4.1.103.Final"
guava = "29.0-jre"
gson = "2.3.1" # Provided by Spigot 1.8.8
websocket = "1.5.1"
protocol = "3.0.0.Beta1-20231107.190703-113"
protocol-connection = "3.0.0.Beta1-20231107.190703-112"
raknet = "1.0.0.CR1-20230703.195238-9"
protocol = "3.0.0.Beta1-20231206.150507-114"
protocol-connection = "3.0.0.Beta1-20231206.150507-113"
raknet = "1.0.0.CR1-20231206.145325-12"
blockstateupdater="1.20.50-20231106.161340-1"
mcauthlib = "d9d773e"
mcprotocollib = "1.20.4-1-20231214.212857-1"
mcprotocollib = "1.20.4-2-20240116.220521-7"
adventure = "4.14.0"
adventure-platform = "4.3.0"
junit = "5.9.2"
Expand All @@ -23,7 +23,7 @@ log4j = "2.20.0"
jline = "3.21.0"
terminalconsoleappender = "1.2.0"
folia = "1.19.4-R0.1-SNAPSHOT"
viaversion = "4.0.0"
viaversion = "4.9.2"
adapters = "1.11-SNAPSHOT"
commodore = "2.2"
bungeecord = "a7c6ede"
Expand Down

0 comments on commit 92b5051

Please sign in to comment.