diff --git a/i18n-paper/pom.xml b/i18n-paper/pom.xml index 85566b3..0ea00fb 100644 --- a/i18n-paper/pom.xml +++ b/i18n-paper/pom.xml @@ -20,13 +20,13 @@ io.papermc.paper paper-api - 1.18.2-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT provided com.comphenix.protocol ProtocolLib - 4.8.0 + 5.0.0-SNAPSHOT provided diff --git a/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/ITranslationAdapter.java b/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/ITranslationAdapter.java index 7372067..e3c50dc 100644 --- a/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/ITranslationAdapter.java +++ b/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/ITranslationAdapter.java @@ -1,5 +1,6 @@ package de.helixdevs.i18n.paper.protocollib; +import com.comphenix.protocol.events.AbstractStructure; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.wrappers.EnumWrappers; import com.comphenix.protocol.wrappers.Pair; @@ -20,16 +21,16 @@ public interface ITranslationAdapter { static final GsonComponentSerializer gsonComponentSerializer = GsonComponentSerializer.gson(); - default void handleItem(Player player, PacketContainer packet, int index) { + default void handleItem(Player player, AbstractStructure packet, int index) { packet.getItemModifier().modify(index, item -> modifyItem(player, item)); } - default void handleItemList(Player player, PacketContainer packet, int index) { + default void handleItemList(Player player, AbstractStructure packet, int index) { packet.getItemListModifier().modify(index, itemList -> itemList.stream().map(itemStack -> modifyItem(player, itemStack)).collect(Collectors.toList())); } - default void handleItemArray(Player player, PacketContainer packet, int index) { + default void handleItemArray(Player player, AbstractStructure packet, int index) { packet.getItemArrayModifier().modify(index, itemArray -> { for (int i = 0; i < itemArray.length; i++) { itemArray[i] = modifyItem(player, itemArray[i]); @@ -38,7 +39,7 @@ default void handleItemArray(Player player, PacketContainer packet, int index) { }); } - default void handleSlotPair(Player player, PacketContainer packet, int index) { + default void handleSlotPair(Player player, AbstractStructure packet, int index) { packet.getSlotStackPairLists().modify(index, slotPairs -> { for (Pair slotPair : slotPairs) { slotPair.setSecond(modifyItem(player, slotPair.getSecond())); @@ -47,11 +48,11 @@ default void handleSlotPair(Player player, PacketContainer packet, int index) { }); } - default void handleChatComponent(Player player, PacketContainer packet, int index) { + default void handleChatComponent(Player player, AbstractStructure packet, int index) { packet.getChatComponents().modify(index, wrappedChatComponent -> translate(player, wrappedChatComponent)); } - default void handleChatComponentArray(Player player, PacketContainer packet, int index) { + default void handleChatComponentArray(Player player, AbstractStructure packet, int index) { packet.getChatComponentArrays().modify(index, wrappedChatComponents -> { for (int i = 0; i < wrappedChatComponents.length; i++) { wrappedChatComponents[i] = translate(player, wrappedChatComponents[i]); diff --git a/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/TeamAdapter.java b/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/TeamAdapter.java index 30c9b94..a403967 100644 --- a/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/TeamAdapter.java +++ b/i18n-paper/src/main/java/de/helixdevs/i18n/paper/protocollib/TeamAdapter.java @@ -12,7 +12,13 @@ public TeamAdapter(Plugin plugin) { @Override public void onPacketSending(PacketEvent event) { - handleChatComponent(event.getPlayer(), event.getPacket(), 0); - handleChatComponent(event.getPlayer(), event.getPacket(), 1); + event.getPacket().getOptionalStructures().modify(0, structureOptional -> { + structureOptional.ifPresent(internalStructure -> { + handleChatComponent(event.getPlayer(), internalStructure, 0); + handleChatComponent(event.getPlayer(), internalStructure, 1); + handleChatComponent(event.getPlayer(), internalStructure, 2); + }); + return structureOptional; + }); } }