Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 08:30:12 +01:00
Translate specific messages (#1161)
Dieser Commit ist enthalten in:
Ursprung
78e8792a2d
Commit
b07433698a
@ -32,8 +32,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||||
import com.github.steveice10.mc.protocol.data.message.TextMessage;
|
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||||
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
@ -318,13 +317,10 @@ public class Entity {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: // custom name
|
case 2: // custom name
|
||||||
if (entityMetadata.getValue() instanceof TextMessage) {
|
if (entityMetadata.getValue() instanceof Message) {
|
||||||
TextMessage name = (TextMessage) entityMetadata.getValue();
|
Message message = (Message) entityMetadata.getValue();
|
||||||
if (name != null)
|
|
||||||
metadata.put(EntityData.NAMETAG, MessageUtils.getBedrockMessage(name));
|
|
||||||
} else if (entityMetadata.getValue() instanceof TranslationMessage) {
|
|
||||||
TranslationMessage message = (TranslationMessage) entityMetadata.getValue();
|
|
||||||
if (message != null)
|
if (message != null)
|
||||||
|
// Always translate even if it's a TextMessage since there could be translatable parameters
|
||||||
metadata.put(EntityData.NAMETAG, MessageUtils.getTranslatedBedrockMessage(message, session.getClientData().getLanguageCode(), true));
|
metadata.put(EntityData.NAMETAG, MessageUtils.getTranslatedBedrockMessage(message, session.getClientData().getLanguageCode(), true));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -39,15 +39,16 @@ public class JavaTitleTranslator extends PacketTranslator<ServerTitlePacket> {
|
|||||||
@Override
|
@Override
|
||||||
public void translate(ServerTitlePacket packet, GeyserSession session) {
|
public void translate(ServerTitlePacket packet, GeyserSession session) {
|
||||||
SetTitlePacket titlePacket = new SetTitlePacket();
|
SetTitlePacket titlePacket = new SetTitlePacket();
|
||||||
|
String locale = session.getClientData().getLanguageCode();
|
||||||
|
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
case TITLE:
|
case TITLE:
|
||||||
titlePacket.setType(SetTitlePacket.Type.TITLE);
|
titlePacket.setType(SetTitlePacket.Type.TITLE);
|
||||||
titlePacket.setText(MessageUtils.getBedrockMessage(packet.getTitle()));
|
titlePacket.setText(MessageUtils.getTranslatedBedrockMessage(packet.getTitle(), locale));
|
||||||
break;
|
break;
|
||||||
case SUBTITLE:
|
case SUBTITLE:
|
||||||
titlePacket.setType(SetTitlePacket.Type.SUBTITLE);
|
titlePacket.setType(SetTitlePacket.Type.SUBTITLE);
|
||||||
titlePacket.setText(MessageUtils.getBedrockMessage(packet.getTitle()));
|
titlePacket.setText(MessageUtils.getTranslatedBedrockMessage(packet.getTitle(), locale));
|
||||||
break;
|
break;
|
||||||
case CLEAR:
|
case CLEAR:
|
||||||
case RESET:
|
case RESET:
|
||||||
@ -56,7 +57,7 @@ public class JavaTitleTranslator extends PacketTranslator<ServerTitlePacket> {
|
|||||||
break;
|
break;
|
||||||
case ACTION_BAR:
|
case ACTION_BAR:
|
||||||
titlePacket.setType(SetTitlePacket.Type.ACTIONBAR);
|
titlePacket.setType(SetTitlePacket.Type.ACTIONBAR);
|
||||||
titlePacket.setText(MessageUtils.getBedrockMessage(packet.getTitle()));
|
titlePacket.setText(MessageUtils.getTranslatedBedrockMessage(packet.getTitle(), locale));
|
||||||
break;
|
break;
|
||||||
case TIMES:
|
case TIMES:
|
||||||
titlePacket.setFadeInTime(packet.getFadeIn());
|
titlePacket.setFadeInTime(packet.getFadeIn());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren