Chat/Skin fixes (#480)

* Made MessageUtils mimic java chat behavior
Send ClientSettingsPacket when player joins a server

* Fix comments
Set use client locale instead of hard coding

* Moved chat reset to fix some broken formatting

* Revert MessageUtil as rtm516 has implemented a better fix
This commit is contained in:
James Harrison 2020-05-05 03:32:37 +01:00 committed by GitHub
parent b49004ddaf
commit 5b3e7c965f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

1
.gitignore vendored
View file

@ -222,6 +222,7 @@ nbdist/
# End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all # End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all
### Geyser ### ### Geyser ###
run/
config.yml config.yml
logs/ logs/
public-key.pem public-key.pem

View file

@ -25,6 +25,10 @@
package org.geysermc.connector.network.translators.java; package org.geysermc.connector.network.translators.java;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientSettingsPacket;
import org.geysermc.connector.entity.PlayerEntity; import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
@ -38,6 +42,9 @@ import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket; import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket; import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
import java.util.Arrays;
import java.util.List;
@Translator(packet = ServerJoinGamePacket.class) @Translator(packet = ServerJoinGamePacket.class)
public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacket> { public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacket> {
@ -67,6 +74,12 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
session.setRenderDistance(packet.getViewDistance()); session.setRenderDistance(packet.getViewDistance());
// We need to send our skin parts to the server otherwise java sees us with no hat, jacket etc
String locale = session.getClientData().getLanguageCode();
List<SkinPart> skinParts = Arrays.asList(SkinPart.values());
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, Hand.MAIN_HAND);
session.getDownstream().getSession().send(clientSettingsPacket);
if (DimensionUtils.javaToBedrock(packet.getDimension()) != entity.getDimension()) { if (DimensionUtils.javaToBedrock(packet.getDimension()) != entity.getDimension()) {
DimensionUtils.switchDimension(session, packet.getDimension()); DimensionUtils.switchDimension(session, packet.getDimension());
} }