Skip to content

Commit

Permalink
Create a default impl for I18nAdapter in paper
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Jul 2, 2024
1 parent 847736c commit 5027f38
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/nookure/core/inv/paper/DefaultPaperAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.nookure.core.inv.paper;

import com.nookure.core.inv.I18nAdapter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

public class DefaultPaperAdapter extends I18nAdapter<Player> {

@Override
public String translate(String key, boolean isKey, @Nullable Player player) {
return LegacyComponentSerializer.legacySection().serialize(translateComponent(key, isKey, player));
}

@Override
public Component translateComponent(String key, boolean isKey, @Nullable Player player) {
return MiniMessage.miniMessage().deserialize(key);
}
}

0 comments on commit 5027f38

Please sign in to comment.