Skip to content

Commit

Permalink
Updated to 1.19 and fixed Team translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMDEV committed Jul 16, 2022
1 parent 378315a commit 6ac9a7d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions i18n-paper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
<version>5.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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]);
Expand All @@ -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<EnumWrappers.ItemSlot, ItemStack> slotPair : slotPairs) {
slotPair.setSecond(modifyItem(player, slotPair.getSecond()));
Expand All @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
}

0 comments on commit 6ac9a7d

Please sign in to comment.