Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 06:50:09 +01:00
Merge branch 'feature/1.19.1'
Dieser Commit ist enthalten in:
Commit
8f8964761a
@ -6,9 +6,9 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ap</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</project>
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>api-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>api-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>base-api</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>api-parent</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-bungeecord</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Used for better working with internals without reflection -->
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
@ -34,7 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>ap</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-spigot</artifactId>
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-sponge</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-standalone</artifactId>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-velocity</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
|
10
core/pom.xml
10
core/pom.xml
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>core</artifactId>
|
||||
|
||||
@ -29,19 +29,19 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>ap</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-api</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Jackson JSON and YAML serialization -->
|
||||
@ -163,7 +163,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.GeyserMC</groupId>
|
||||
<artifactId>MCProtocolLib</artifactId>
|
||||
<version>ecc04fd</version>
|
||||
<version>9f78bd5</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -453,6 +453,8 @@ public final class EntityDefinitions {
|
||||
ALLAY = EntityDefinition.inherited(AllayEntity::new, mobEntityBase)
|
||||
.type(EntityType.ALLAY)
|
||||
.height(0.6f).width(0.35f)
|
||||
.addTranslator(MetadataType.BOOLEAN, AllayEntity::setDancing)
|
||||
.addTranslator(MetadataType.BOOLEAN, AllayEntity::setCanDuplicate)
|
||||
.build();
|
||||
BAT = EntityDefinition.inherited(BatEntity::new, mobEntityBase)
|
||||
.type(EntityType.BAT)
|
||||
|
@ -25,8 +25,10 @@
|
||||
|
||||
package org.geysermc.geyser.entity.type.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
import org.geysermc.geyser.inventory.GeyserItemStack;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
@ -37,14 +39,27 @@ import javax.annotation.Nonnull;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AllayEntity extends MobEntity {
|
||||
private boolean canDuplicate;
|
||||
|
||||
public AllayEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
|
||||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setDancing(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.DANCING, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setCanDuplicate(BooleanEntityMetadata entityMetadata) {
|
||||
this.canDuplicate = entityMetadata.getPrimitiveValue();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractiveTag testMobInteraction(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (!this.hand.isValid() && !itemInHand.isEmpty()) {
|
||||
if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) {
|
||||
// Maybe better as another tag?
|
||||
return InteractiveTag.GIVE_ITEM_TO_ALLAY;
|
||||
} else if (!this.hand.isValid() && !itemInHand.isEmpty()) {
|
||||
return InteractiveTag.GIVE_ITEM_TO_ALLAY;
|
||||
} else if (this.hand.isValid() && hand == Hand.MAIN_HAND && itemInHand.isEmpty()) {
|
||||
// Seems like there isn't a good tag for this yet
|
||||
@ -57,7 +72,10 @@ public class AllayEntity extends MobEntity {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected InteractionResult mobInteract(@Nonnull Hand hand, @Nonnull GeyserItemStack itemInHand) {
|
||||
if (!this.hand.isValid() && !itemInHand.isEmpty()) {
|
||||
if (this.canDuplicate && getFlag(EntityFlag.DANCING) && isDuplicationItem(itemInHand)) {
|
||||
//TOCHECK sound
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (!this.hand.isValid() && !itemInHand.isEmpty()) {
|
||||
//TODO play sound?
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (this.hand.isValid() && hand == Hand.MAIN_HAND && itemInHand.isEmpty()) {
|
||||
@ -67,4 +85,8 @@ public class AllayEntity extends MobEntity {
|
||||
return super.mobInteract(hand, itemInHand);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDuplicationItem(GeyserItemStack itemStack) {
|
||||
return itemStack.getJavaId() == session.getItemMappings().getStoredItems().amethystShard();
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import java.util.Map;
|
||||
@Getter
|
||||
@Accessors(fluent = true)
|
||||
public class StoredItemMappings {
|
||||
private final int amethystShard;
|
||||
private final ItemMapping bamboo;
|
||||
private final ItemMapping banner;
|
||||
private final ItemMapping barrier;
|
||||
@ -71,6 +72,7 @@ public class StoredItemMappings {
|
||||
private final ItemMapping writableBook;
|
||||
|
||||
public StoredItemMappings(Map<String, ItemMapping> itemMappings) {
|
||||
this.amethystShard = load(itemMappings, "amethyst_shard").getJavaId();
|
||||
this.bamboo = load(itemMappings, "bamboo");
|
||||
this.banner = load(itemMappings, "white_banner"); // As of 1.17.10, all banners have the same Bedrock ID
|
||||
this.barrier = load(itemMappings, "barrier");
|
||||
|
@ -123,9 +123,9 @@ import org.geysermc.geyser.session.auth.AuthType;
|
||||
import org.geysermc.geyser.session.auth.BedrockClientData;
|
||||
import org.geysermc.geyser.session.cache.*;
|
||||
import org.geysermc.geyser.skin.FloodgateSkinUploader;
|
||||
import org.geysermc.geyser.text.ChatTypeEntry;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.text.MinecraftLocale;
|
||||
import org.geysermc.geyser.text.TextDecoration;
|
||||
import org.geysermc.geyser.translator.inventory.InventoryTranslator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.geysermc.geyser.util.ChunkUtils;
|
||||
@ -341,7 +341,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||
*/
|
||||
private final Map<String, JavaDimension> dimensions = new Object2ObjectOpenHashMap<>(3);
|
||||
|
||||
private final Int2ObjectMap<ChatTypeEntry> chatTypes = new Int2ObjectOpenHashMap<>(8);
|
||||
private final Int2ObjectMap<TextDecoration> chatTypes = new Int2ObjectOpenHashMap<>(7);
|
||||
|
||||
@Setter
|
||||
private int breakingBlock;
|
||||
@ -564,8 +564,6 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||
this.playerEntity = new SessionPlayerEntity(this);
|
||||
collisionManager.updatePlayerBoundingBox(this.playerEntity.getPosition());
|
||||
|
||||
ChatTypeEntry.applyDefaults(chatTypes);
|
||||
|
||||
this.playerInventory = new PlayerInventory();
|
||||
this.openInventory = null;
|
||||
this.craftingRecipes = new Int2ObjectOpenHashMap<>();
|
||||
@ -1388,14 +1386,14 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||
* Sends a chat message to the Java server.
|
||||
*/
|
||||
public void sendChat(String message) {
|
||||
sendDownstreamPacket(new ServerboundChatPacket(message, Instant.now().toEpochMilli(), 0L, ByteArrays.EMPTY_ARRAY, false));
|
||||
sendDownstreamPacket(new ServerboundChatPacket(message, Instant.now().toEpochMilli(), 0L, ByteArrays.EMPTY_ARRAY, false, Collections.emptyList(), null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a command to the Java server.
|
||||
*/
|
||||
public void sendCommand(String command) {
|
||||
sendDownstreamPacket(new ServerboundChatCommandPacket(command, Instant.now().toEpochMilli(), 0L, Collections.emptyMap(), false));
|
||||
sendDownstreamPacket(new ServerboundChatCommandPacket(command, Instant.now().toEpochMilli(), 0L, Collections.emptyList(), false, Collections.emptyList(), null));
|
||||
}
|
||||
|
||||
public void setServerRenderDistance(int renderDistance) {
|
||||
|
@ -34,9 +34,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
public record ChatTypeEntry(@Nonnull TextPacket.Type bedrockChatType, @Nullable TextDecoration textDecoration) {
|
||||
private static final ChatTypeEntry CHAT = new ChatTypeEntry(TextPacket.Type.CHAT, null);
|
||||
private static final ChatTypeEntry SYSTEM = new ChatTypeEntry(TextPacket.Type.CHAT, null);
|
||||
private static final ChatTypeEntry TIP = new ChatTypeEntry(TextPacket.Type.CHAT, null);
|
||||
private static final ChatTypeEntry RAW = new ChatTypeEntry(TextPacket.Type.CHAT, null);
|
||||
private static final ChatTypeEntry RAW = new ChatTypeEntry(TextPacket.Type.RAW, null);
|
||||
|
||||
/**
|
||||
* Apply defaults to a map so it isn't empty in the event a chat message is sent before the login packet.
|
||||
@ -46,12 +44,11 @@ public record ChatTypeEntry(@Nonnull TextPacket.Type bedrockChatType, @Nullable
|
||||
// But, the only way this happens is if a chat message is sent to us before the login packet, which is rare.
|
||||
// So we'll just make sure chat ends up in the right place.
|
||||
chatTypes.put(BuiltinChatType.CHAT.ordinal(), CHAT);
|
||||
chatTypes.put(BuiltinChatType.SYSTEM.ordinal(), SYSTEM);
|
||||
chatTypes.put(BuiltinChatType.GAME_INFO.ordinal(), TIP);
|
||||
chatTypes.put(BuiltinChatType.SAY_COMMAND.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.MSG_COMMAND.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.TEAM_MSG_COMMAND.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.MSG_COMMAND_INCOMING.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.MSG_COMMAND_OUTGOING.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.TEAM_MSG_COMMAND_INCOMING.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.TEAM_MSG_COMMAND_OUTGOING.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.EMOTE_COMMAND.ordinal(), RAW);
|
||||
chatTypes.put(BuiltinChatType.TELLRAW_COMMAND.ordinal(), RAW);
|
||||
}
|
||||
}
|
||||
|
@ -46,14 +46,16 @@ public final class TextDecoration {
|
||||
|
||||
CompoundTag styleTag = tag.get("style");
|
||||
Style.Builder builder = Style.style();
|
||||
StringTag color = styleTag.get("color");
|
||||
if (color != null) {
|
||||
builder.color(NamedTextColor.NAMES.value(color.getValue()));
|
||||
}
|
||||
//TODO implement the rest
|
||||
Tag italic = styleTag.get("italic");
|
||||
if (italic != null && ((Number) italic.getValue()).byteValue() == (byte) 1) {
|
||||
builder.decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC);
|
||||
if (styleTag != null) {
|
||||
StringTag color = styleTag.get("color");
|
||||
if (color != null) {
|
||||
builder.color(NamedTextColor.NAMES.value(color.getValue()));
|
||||
}
|
||||
//TODO implement the rest
|
||||
Tag italic = styleTag.get("italic");
|
||||
if (italic != null && ((Number) italic.getValue()).byteValue() == (byte) 1) {
|
||||
builder.decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC);
|
||||
}
|
||||
}
|
||||
style = builder.build();
|
||||
|
||||
@ -88,6 +90,6 @@ public final class TextDecoration {
|
||||
public enum Parameter {
|
||||
CONTENT,
|
||||
SENDER,
|
||||
TEAM_NAME
|
||||
TARGET
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
|
||||
CommandNode node = nodes[nodeIndex];
|
||||
|
||||
// Make sure we don't have duplicated commands (happens if there is more than 1 root node)
|
||||
if (!commandNodes.add(nodeIndex) || !knownAliases.add(node.getName().toLowerCase())) continue;
|
||||
if (!commandNodes.add(nodeIndex) || !knownAliases.add(node.getName().toLowerCase(Locale.ROOT))) continue;
|
||||
|
||||
// Get and update the commandArgs list with the found arguments
|
||||
if (node.getChildIndices().length >= 1) {
|
||||
@ -319,7 +319,7 @@ public class JavaCommandsTranslator extends PacketTranslator<ClientboundCommands
|
||||
CommandParam type = null;
|
||||
boolean optional = this.paramNode.isExecutable();
|
||||
if (mappedType instanceof String[]) {
|
||||
enumData = new CommandEnumData(paramNode.getParser().name().toLowerCase(), (String[]) mappedType, false);
|
||||
enumData = new CommandEnumData(paramNode.getParser().name().toLowerCase(Locale.ROOT), (String[]) mappedType, false);
|
||||
} else {
|
||||
type = (CommandParam) mappedType;
|
||||
// Bedrock throws a fit if an optional message comes after a string or target
|
||||
|
@ -25,25 +25,21 @@
|
||||
|
||||
package org.geysermc.geyser.translator.protocol.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.BuiltinChatType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.nukkitx.protocol.bedrock.data.GameRuleData;
|
||||
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
|
||||
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.GameRulesChangedPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
|
||||
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
|
||||
import org.geysermc.geyser.level.JavaDimension;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.session.auth.AuthType;
|
||||
import org.geysermc.geyser.text.ChatTypeEntry;
|
||||
import org.geysermc.geyser.text.TextDecoration;
|
||||
import org.geysermc.geyser.translator.level.BiomeTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
@ -68,7 +64,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
|
||||
JavaDimension.load(packet.getRegistry(), dimensions);
|
||||
|
||||
Int2ObjectMap<ChatTypeEntry> chatTypes = session.getChatTypes();
|
||||
Int2ObjectMap<TextDecoration> chatTypes = session.getChatTypes();
|
||||
chatTypes.clear();
|
||||
for (CompoundTag tag : JavaCodecEntry.iterateAsTag(packet.getRegistry().get("minecraft:chat_type"))) {
|
||||
// The ID is NOT ALWAYS THE SAME! ViaVersion as of 1.19 adds two registry entries that do NOT match vanilla.
|
||||
@ -77,21 +73,9 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
CompoundTag chat = element.get("chat");
|
||||
TextDecoration textDecoration = null;
|
||||
if (chat != null) {
|
||||
CompoundTag decorationTag = chat.get("decoration");
|
||||
if (decorationTag != null) {
|
||||
textDecoration = new TextDecoration(decorationTag);
|
||||
}
|
||||
textDecoration = new TextDecoration(chat);
|
||||
}
|
||||
BuiltinChatType type = BuiltinChatType.from(((StringTag) tag.get("name")).getValue());
|
||||
// TODO new types?
|
||||
// The built-in type can be null if custom plugins/mods add in new types
|
||||
TextPacket.Type bedrockType = type != null ? switch (type) {
|
||||
case CHAT -> TextPacket.Type.CHAT;
|
||||
case SYSTEM -> TextPacket.Type.SYSTEM;
|
||||
case GAME_INFO -> TextPacket.Type.TIP;
|
||||
default -> TextPacket.Type.RAW;
|
||||
} : TextPacket.Type.RAW;
|
||||
chatTypes.put(id, new ChatTypeEntry(bedrockType, textDecoration));
|
||||
chatTypes.put(id, textDecoration);
|
||||
}
|
||||
|
||||
// If the player is already initialized and a join game packet is sent, they
|
||||
|
@ -30,7 +30,6 @@ import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.ChatTypeEntry;
|
||||
import org.geysermc.geyser.text.TextDecoration;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
@ -45,18 +44,16 @@ public class JavaPlayerChatTranslator extends PacketTranslator<ClientboundPlayer
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundPlayerChatPacket packet) {
|
||||
ChatTypeEntry entry = session.getChatTypes().get(packet.getTypeId());
|
||||
|
||||
TextPacket textPacket = new TextPacket();
|
||||
textPacket.setPlatformChatId("");
|
||||
textPacket.setSourceName("");
|
||||
textPacket.setXuid(session.getAuthData().xuid());
|
||||
textPacket.setType(entry.bedrockChatType());
|
||||
textPacket.setType(TextPacket.Type.CHAT);
|
||||
|
||||
textPacket.setNeedsTranslation(false);
|
||||
Component message = packet.getUnsignedContent() == null ? packet.getSignedContent() : packet.getUnsignedContent();
|
||||
Component message = packet.getUnsignedContent() == null ? packet.getMessageDecorated() : packet.getUnsignedContent();
|
||||
|
||||
TextDecoration decoration = entry.textDecoration();
|
||||
TextDecoration decoration = session.getChatTypes().get(packet.getChatType());
|
||||
if (decoration != null) {
|
||||
// As of 1.19 - do this to apply all the styling for signed messages
|
||||
// Though, Bedrock cannot care about the signed stuff.
|
||||
@ -65,11 +62,11 @@ public class JavaPlayerChatTranslator extends PacketTranslator<ClientboundPlayer
|
||||
.style(decoration.style());
|
||||
Set<TextDecoration.Parameter> parameters = decoration.parameters();
|
||||
List<Component> args = new ArrayList<>(3);
|
||||
if (parameters.contains(TextDecoration.Parameter.TEAM_NAME)) {
|
||||
args.add(packet.getSenderTeamName());
|
||||
if (parameters.contains(TextDecoration.Parameter.TARGET)) {
|
||||
args.add(packet.getTargetName());
|
||||
}
|
||||
if (parameters.contains(TextDecoration.Parameter.SENDER)) {
|
||||
args.add(packet.getSenderName());
|
||||
args.add(packet.getName());
|
||||
}
|
||||
if (parameters.contains(TextDecoration.Parameter.CONTENT)) {
|
||||
args.add(message);
|
||||
|
@ -28,7 +28,6 @@ package org.geysermc.geyser.translator.protocol.java;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.ChatTypeEntry;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
@ -38,15 +37,11 @@ public class JavaSystemChatTranslator extends PacketTranslator<ClientboundSystem
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundSystemChatPacket packet) {
|
||||
ChatTypeEntry chatTypeEntry = session.getChatTypes().get(packet.getTypeId());
|
||||
// This probably isn't proper but system chat won't care about the registry in 1.19.1 anyway
|
||||
TextPacket.Type chatType = chatTypeEntry == null ? TextPacket.Type.RAW : chatTypeEntry.bedrockChatType();
|
||||
|
||||
TextPacket textPacket = new TextPacket();
|
||||
textPacket.setPlatformChatId("");
|
||||
textPacket.setSourceName("");
|
||||
textPacket.setXuid(session.getAuthData().xuid());
|
||||
textPacket.setType(chatType);
|
||||
textPacket.setType(packet.isOverlay() ? TextPacket.Type.TIP : TextPacket.Type.SYSTEM);
|
||||
|
||||
textPacket.setNeedsTranslation(false);
|
||||
textPacket.setMessage(MessageTranslator.convertMessage(packet.getContent(), session.getLocale()));
|
||||
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.5-SNAPSHOT</version>
|
||||
<version>2.0.6-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Geyser</name>
|
||||
<description>Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers.</description>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren