-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(velocity): support new client information packet (#333)
- Loading branch information
1 parent
2d88e82
commit b1142a1
Showing
4 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...src/main/java/com/rexcantor64/triton/velocity/packetinterceptor/VelocityNettyDecoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.rexcantor64.triton.velocity.packetinterceptor; | ||
|
||
import com.rexcantor64.triton.velocity.player.VelocityLanguagePlayer; | ||
import com.velocitypowered.proxy.protocol.MinecraftPacket; | ||
import com.velocitypowered.proxy.protocol.packet.ClientSettings; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.MessageToMessageDecoder; | ||
import io.netty.util.ReferenceCounted; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
public class VelocityNettyDecoder extends MessageToMessageDecoder<MinecraftPacket> { | ||
|
||
private final VelocityLanguagePlayer player; | ||
|
||
@Override | ||
protected void decode(ChannelHandlerContext ctx, MinecraftPacket packet, List<Object> out) { | ||
if (packet instanceof ReferenceCounted) { | ||
// We need to retain the packet since we're just passing them through, otherwise Netty will throw an error | ||
((ReferenceCounted) packet).retain(); | ||
out.add(packet); | ||
return; | ||
} | ||
// PlayerSettingsChangedEvent is not working on 1.20.2, so we are using packets instead | ||
if (packet instanceof ClientSettings) { | ||
ClientSettings cs = (ClientSettings) packet; | ||
player.setClientLocale(cs.getLocale()); | ||
} | ||
out.add(packet); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters