From 3d23745b89df1f3f21aed4ff42889425a7c551a0 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Mon, 24 Jun 2024 21:26:11 +0200 Subject: [PATCH] Rename ComponentRewriter->TextRewriter Now that item components with 1.20.5+ are a thing the name component rewriter became even more unclear than before, TextRewriter better reflections what the rewriter actually does. --- .../viaversion/api/protocol/Protocol.java | 4 +-- ...mponentRewriter.java => TextRewriter.java} | 2 +- .../v1_11_1to1_12/data/TranslateRewriter.java | 4 +-- .../v1_12_2to1_13/Protocol1_12_2To1_13.java | 31 +++++++++--------- .../blockentities/CommandBlockHandler.java | 2 +- ...ewriter1_13.java => TextRewriter1_13.java} | 6 ++-- .../v1_13_2to1_14/Protocol1_13_2To1_14.java | 8 ++--- .../rewriter/ItemPacketRewriter1_14.java | 6 ++-- ...ewriter1_14.java => TextRewriter1_14.java} | 6 ++-- .../v1_15_2to1_16/Protocol1_15_2To1_16.java | 17 +++++----- .../rewriter/ItemPacketRewriter1_16.java | 2 +- ...ewriter1_16.java => TextRewriter1_16.java} | 6 ++-- .../rewriter/WorldPacketRewriter1_16.java | 2 +- .../Protocol1_20_3To1_20_5.java | 17 +++++----- .../BlockItemPacketRewriter1_20_5.java | 2 +- ...ter1_20_5.java => TextRewriter1_20_5.java} | 6 ++-- .../v1_20_5to1_21/Protocol1_20_5To1_21.java | 32 +++++++++---------- ...ewriter1_21.java => TextRewriter1_21.java} | 6 ++-- .../viaversion/rewriter/EntityRewriter.java | 2 +- .../viaversion/rewriter/ItemRewriter.java | 10 +++--- .../rewriter/StructuredItemRewriter.java | 10 +++--- ...mponentRewriter.java => TextRewriter.java} | 14 ++++---- 22 files changed, 99 insertions(+), 96 deletions(-) rename api/src/main/java/com/viaversion/viaversion/api/rewriter/{ComponentRewriter.java => TextRewriter.java} (97%) rename common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/{ComponentRewriter1_13.java => TextRewriter1_13.java} (94%) rename common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/{ComponentRewriter1_14.java => TextRewriter1_14.java} (86%) rename common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/{ComponentRewriter1_16.java => TextRewriter1_16.java} (96%) rename common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/{ComponentRewriter1_20_5.java => TextRewriter1_20_5.java} (99%) rename common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/{ComponentRewriter1_21.java => TextRewriter1_21.java} (91%) rename common/src/main/java/com/viaversion/viaversion/rewriter/{ComponentRewriter.java => TextRewriter.java} (96%) diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java index da6cbc09f..62e2f2130 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java @@ -33,7 +33,7 @@ import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; -import com.viaversion.viaversion.api.rewriter.ComponentRewriter; +import com.viaversion.viaversion.api.rewriter.TextRewriter; import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.rewriter.TagRewriter; @@ -383,7 +383,7 @@ public interface Protocol ACHIEVEMENT_TEXT_REWRITER = new ComponentRewriter<>(null, ComponentRewriter.ReadType.JSON) { + private static final TextRewriter ACHIEVEMENT_TEXT_REWRITER = new TextRewriter<>(null, TextRewriter.ReadType.JSON) { @Override protected void handleTranslate(JsonObject object, String translate) { String text = AchievementTranslations1_12.get(translate); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java index 75fd57acc..70aa2de65 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java @@ -54,7 +54,7 @@ import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPacke import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.PaintingProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.PlayerLookTargetProvider; -import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.ComponentRewriter1_13; +import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.TextRewriter1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.EntityPacketRewriter1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.ItemPacketRewriter1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.WorldPacketRewriter1_13; @@ -85,7 +85,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol FORMATTING_CODES = Sets.newHashSet('k', 'l', 'm', 'n', 'o', 'r'); private final EntityPacketRewriter1_13 entityRewriter = new EntityPacketRewriter1_13(this); private final ItemPacketRewriter1_13 itemRewriter = new ItemPacketRewriter1_13(this); - private final ComponentRewriter1_13 componentRewriter = new ComponentRewriter1_13<>(this); + private final TextRewriter1_13 textRewriter = new TextRewriter1_13<>(this); static { SCOREBOARD_TEAM_NAME_REWRITE.put('0', 'g'); @@ -174,7 +174,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); + textRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); }); registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), new PacketHandlers() { @@ -245,8 +245,8 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol { wrapper.write(Types.VAR_INT, wrapper.user().get(TabCompleteTracker.class).getTransactionId()); @@ -286,7 +286,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT))); // Title + handler(wrapper -> textRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT))); // Title } }); @@ -321,7 +321,7 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol(this).registerSound(ClientboundPackets1_12_1.SOUND); registerClientbound(ClientboundPackets1_12_1.TAB_LIST, wrapper -> { - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); - componentRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); + textRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); + textRewriter.processText(wrapper.user(), wrapper.passthrough(Types.COMPONENT)); }); registerClientbound(ClientboundPackets1_12_1.UPDATE_ADVANCEMENTS, wrapper -> { @@ -515,8 +515,8 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol extends ComponentRewriter { +public class TextRewriter1_13 extends TextRewriter { - public ComponentRewriter1_13(Protocol protocol) { + public TextRewriter1_13(Protocol protocol) { super(protocol, ReadType.JSON); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java index 7efa794bd..5ab7da7b1 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; -import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.ComponentRewriter1_14; +import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.TextRewriter1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.data.MappingData1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; @@ -38,7 +38,7 @@ import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.PlayerPacketRe import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.WorldPacketRewriter1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.storage.EntityTracker1_14; import com.viaversion.viaversion.rewriter.CommandRewriter; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.TextRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -65,8 +65,8 @@ public class Protocol1_13_2To1_14 extends AbstractProtocol(this).registerSound(ClientboundPackets1_13.SOUND); new StatisticsRewriter<>(this).register(ClientboundPackets1_13.AWARD_STATS); - ComponentRewriter componentRewriter = new ComponentRewriter1_14<>(this); - componentRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT); + TextRewriter textRewriter = new TextRewriter1_14<>(this); + textRewriter.registerTextPacket(ClientboundPackets1_13.CHAT); CommandRewriter commandRewriter = new CommandRewriter<>(this) { @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java index 3d25e4922..ed5861093 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java @@ -37,7 +37,7 @@ import com.viaversion.viaversion.protocols.v1_13_2to1_14.Protocol1_13_2To1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.storage.EntityTracker1_14; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.TextRewriter; import com.viaversion.viaversion.rewriter.ItemRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; import com.viaversion.viaversion.util.ComponentUtil; @@ -47,7 +47,7 @@ import java.util.concurrent.ThreadLocalRandom; public class ItemPacketRewriter1_14 extends ItemRewriter { private static final Set REMOVED_RECIPE_TYPES = Sets.newHashSet("crafting_special_banneraddpattern", "crafting_special_repairitem"); - private static final ComponentRewriter COMPONENT_REWRITER = new ComponentRewriter<>(null, ComponentRewriter.ReadType.JSON) { + private static final TextRewriter TEXT_REWRITER = new TextRewriter<>(null, TextRewriter.ReadType.JSON) { @Override protected void handleTranslate(JsonObject object, String translate) { super.handleTranslate(object, translate); @@ -71,7 +71,7 @@ public class ItemPacketRewriter1_14 extends ItemRewriter extends ComponentRewriter1_13 { +public class TextRewriter1_14 extends TextRewriter1_13 { - public ComponentRewriter1_14(Protocol protocol) { + public TextRewriter1_14(Protocol protocol) { super(protocol); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java index da21e8b76..bae7f5807 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java @@ -42,7 +42,7 @@ import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPacke import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ServerboundPackets1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.provider.PlayerAbilitiesProvider; -import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.ComponentRewriter1_16; +import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.TextRewriter1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.EntityPacketRewriter1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.ItemPacketRewriter1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.WorldPacketRewriter1_16; @@ -63,7 +63,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); public Protocol1_15_2To1_16() { @@ -129,14 +129,14 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol { - componentRewriter.processText(wrapper.user(), wrapper.get(Types.COMPONENT, 0)); + textRewriter.processText(wrapper.user(), wrapper.get(Types.COMPONENT, 0)); wrapper.write(Types.UUID, ZERO_UUID); // Sender uuid - always send as 'system' }); } }); - componentRewriter.registerBossEvent(ClientboundPackets1_15.BOSS_EVENT); - componentRewriter.registerTitle(ClientboundPackets1_15.SET_TITLES); - componentRewriter.registerPlayerCombat(ClientboundPackets1_15.PLAYER_COMBAT); + textRewriter.registerBossEvent(ClientboundPackets1_15.BOSS_EVENT); + textRewriter.registerTitle(ClientboundPackets1_15.SET_TITLES); + textRewriter.registerPlayerCombat(ClientboundPackets1_15.PLAYER_COMBAT); SoundRewriter soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_15.SOUND); @@ -255,8 +255,9 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol pages = tag.getListTag("pages", StringTag.class); if (pages != null) { for (StringTag pageTag : pages) { - pageTag.setValue(protocol.getComponentRewriter().processText(connection, pageTag.getValue()).toString()); + pageTag.setValue(protocol.getTextRewriter().processText(connection, pageTag.getValue()).toString()); } } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ComponentRewriter1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/TextRewriter1_16.java similarity index 96% rename from common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ComponentRewriter1_16.java rename to common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/TextRewriter1_16.java index cb4162690..a6486e380 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ComponentRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/TextRewriter1_16.java @@ -23,14 +23,14 @@ import com.google.gson.JsonPrimitive; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.v1_15_2to1_16.Protocol1_15_2To1_16; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.TextRewriter; import java.util.HashMap; import java.util.Map; -public class ComponentRewriter1_16 extends ComponentRewriter { +public class TextRewriter1_16 extends TextRewriter { private final Map mappings = new HashMap<>(); - public ComponentRewriter1_16(Protocol1_15_2To1_16 protocol) { + public TextRewriter1_16(Protocol1_15_2To1_16 protocol) { super(protocol, ReadType.JSON); mappings.put("attribute.name.generic.armorToughness", "attribute.name.generic.armor_toughness"); mappings.put("attribute.name.generic.attackDamage", "attribute.name.generic.attack_damage"); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java index 9acfb6d12..2df681012 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/WorldPacketRewriter1_16.java @@ -112,7 +112,7 @@ public class WorldPacketRewriter1_16 { for (int i = 1; i <= 4; i++) { StringTag line = compoundTag.getStringTag("Text" + i); if (line != null) { - JsonElement text = protocol.getComponentRewriter().processText(connection, line.getValue()); + JsonElement text = protocol.getTextRewriter().processText(connection, line.getValue()); compoundTag.putString("Text" + i, text.toString()); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java index 8a7c3a56d..1c8d3cbda 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/Protocol1_20_3To1_20_5.java @@ -47,11 +47,11 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundCon import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.BlockItemPacketRewriter1_20_5; -import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.ComponentRewriter1_20_5; +import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.TextRewriter1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.EntityPacketRewriter1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.storage.AcknowledgedMessagesStorage; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.TextRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -70,7 +70,7 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); - private final ComponentRewriter1_20_5 componentRewriter = new ComponentRewriter1_20_5<>(this, Types1_20_5.STRUCTURED_DATA); + private final TextRewriter1_20_5 textRewriter = new TextRewriter1_20_5<>(this, Types1_20_5.STRUCTURED_DATA); public Protocol1_20_3To1_20_5() { super(ClientboundPacket1_20_3.class, ClientboundPacket1_20_5.class, ServerboundPacket1_20_3.class, ServerboundPacket1_20_5.class); @@ -89,9 +89,9 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol(this).register(ClientboundPackets1_20_3.AWARD_STATS); - componentRewriter.registerComponentPacket(ClientboundPackets1_20_3.SYSTEM_CHAT); - componentRewriter.registerComponentPacket(ClientboundPackets1_20_3.DISGUISED_CHAT); - componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_20_3.PLAYER_COMBAT_KILL); + textRewriter.registerTextPacket(ClientboundPackets1_20_3.SYSTEM_CHAT); + textRewriter.registerTextPacket(ClientboundPackets1_20_3.DISGUISED_CHAT); + textRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_20_3.PLAYER_COMBAT_KILL); registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, wrapper -> { wrapper.passthrough(Types.STRING); // Server ID @@ -317,8 +317,9 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol getComponentRewriter() { - return componentRewriter; + @Override + public TextRewriter getTextRewriter() { + return textRewriter; } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java index ec4f8410a..aecbd1190 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java @@ -1194,7 +1194,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter extends ComponentRewriter { +public class TextRewriter1_20_5 extends TextRewriter { private final Map, ConverterPair> converters = new Reference2ObjectOpenHashMap<>(); private final StructuredDataType structuredDataType; @@ -110,7 +110,7 @@ public class ComponentRewriter1_20_5 extends Co * @param protocol protocol * @param structuredDataType unmapped structured data type */ - public ComponentRewriter1_20_5(final Protocol protocol, final StructuredDataType structuredDataType) { + public TextRewriter1_20_5(final Protocol protocol, final StructuredDataType structuredDataType) { super(protocol, ReadType.NBT); this.structuredDataType = structuredDataType; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java index 683131b42..5335cbc7d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java @@ -42,10 +42,10 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfi import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21; import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21; import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21; -import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.ComponentRewriter1_21; +import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.TextRewriter1_21; import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.EntityPacketRewriter1_21; import com.viaversion.viaversion.protocols.v1_20_5to1_21.storage.EfficiencyAttributeStorage; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.TextRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -62,7 +62,7 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); - private final ComponentRewriter componentRewriter = new ComponentRewriter1_21(this); + private final TextRewriter textRewriter = new TextRewriter1_21(this); public Protocol1_20_5To1_21() { super(ClientboundPacket1_20_5.class, ClientboundPacket1_21.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class); @@ -81,18 +81,18 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol(this).register(ClientboundPackets1_20_5.AWARD_STATS); - componentRewriter.registerOpenScreen(ClientboundPackets1_20_5.OPEN_SCREEN); - componentRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_ACTION_BAR_TEXT); - componentRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_TITLE_TEXT); - componentRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_SUBTITLE_TEXT); - componentRewriter.registerBossEvent(ClientboundPackets1_20_5.BOSS_EVENT); - componentRewriter.registerComponentPacket(ClientboundPackets1_20_5.DISCONNECT); - componentRewriter.registerTabList(ClientboundPackets1_20_5.TAB_LIST); - componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_20_5.PLAYER_COMBAT_KILL); - componentRewriter.registerComponentPacket(ClientboundPackets1_20_5.SYSTEM_CHAT); + textRewriter.registerOpenScreen(ClientboundPackets1_20_5.OPEN_SCREEN); + textRewriter.registerTextPacket(ClientboundPackets1_20_5.SET_ACTION_BAR_TEXT); + textRewriter.registerTextPacket(ClientboundPackets1_20_5.SET_TITLE_TEXT); + textRewriter.registerTextPacket(ClientboundPackets1_20_5.SET_SUBTITLE_TEXT); + textRewriter.registerBossEvent(ClientboundPackets1_20_5.BOSS_EVENT); + textRewriter.registerTextPacket(ClientboundPackets1_20_5.DISCONNECT); + textRewriter.registerTabList(ClientboundPackets1_20_5.TAB_LIST); + textRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_20_5.PLAYER_COMBAT_KILL); + textRewriter.registerTextPacket(ClientboundPackets1_20_5.SYSTEM_CHAT); registerClientbound(ClientboundPackets1_20_5.DISGUISED_CHAT, wrapper -> { - componentRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.TAG)); // Message + textRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.TAG)); // Message // Holder time final int chatType = wrapper.read(Types.VAR_INT); @@ -114,7 +114,7 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol getComponentRewriter() { - return componentRewriter; + public TextRewriter getTextRewriter() { + return textRewriter; } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/ComponentRewriter1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/TextRewriter1_21.java similarity index 91% rename from common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/ComponentRewriter1_21.java rename to common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/TextRewriter1_21.java index 0c3128037..d44c81b04 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/ComponentRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/TextRewriter1_21.java @@ -22,15 +22,15 @@ import com.viaversion.nbt.tag.ListTag; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5; import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21; -import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.TextRewriter; import com.viaversion.viaversion.util.SerializerVersion; import com.viaversion.viaversion.util.TagUtil; import com.viaversion.viaversion.util.UUIDUtil; import java.util.UUID; -public final class ComponentRewriter1_21 extends ComponentRewriter { +public final class TextRewriter1_21 extends TextRewriter { - public ComponentRewriter1_21(final Protocol1_20_5To1_21 protocol) { + public TextRewriter1_21(final Protocol1_20_5To1_21 protocol) { super(protocol, ReadType.NBT); } diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java index c970dc321..80f4ca79c 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -231,7 +231,7 @@ public abstract class EntityRewriter loreData = dataContainer.getNonEmpty(StructuredDataKey.LORE); if (loreData != null) { for (final Tag tag : loreData.value()) { - componentRewriter.processTag(connection, tag); + textRewriter.processTag(connection, tag); } } } @@ -165,7 +165,7 @@ public class StructuredItemRewriter implements com.viaversion.viaversion.api.rewriter.ComponentRewriter { +public class TextRewriter implements com.viaversion.viaversion.api.rewriter.TextRewriter { protected final Protocol protocol; protected final ReadType type; - public ComponentRewriter(final Protocol protocol, final ReadType type) { + public TextRewriter(final Protocol protocol, final ReadType type) { this.protocol = protocol; this.type = type; } /** - * Processes components at the beginning of the packet. + * Processes text components at the beginning of the packet. * Used for packets that have components as their very first value, so no special pre-reading is necessary. * * @param packetType clientbound packet type */ - public void registerComponentPacket(final C packetType) { + public void registerTextPacket(final C packetType) { protocol.registerClientbound(packetType, this::passthroughAndProcess); } @@ -80,7 +80,7 @@ public class ComponentRewriter implements com.v } /** - * Handles sub 1.17 combat event components. + * Handles sub 1.17 combat event text components. */ public void registerPlayerCombat(final C packetType) { protocol.registerClientbound(packetType, wrapper -> {