feat(i18n): final touches from the move to adventure
This commit is contained in:
parent
84e792880f
commit
c78ba0c84a
8 changed files with 50 additions and 10 deletions
|
@ -40,7 +40,14 @@ public class AppearanceManager {
|
|||
profile.setName(defaultName);
|
||||
profile.setSkin(defaultName);
|
||||
dataStore.getCache().cache(player.getUniqueId(), profile);
|
||||
return updatePlayer(true, true);
|
||||
|
||||
final ActionResult result = updatePlayer(true, true);
|
||||
if (!result.isError()) {
|
||||
profile.setName(null);
|
||||
profile.setSkin(null);
|
||||
dataStore.getCache().cache(player.getUniqueId(), profile);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ActionResult updatePlayer(boolean skinChange, boolean reset) {
|
||||
|
|
|
@ -43,9 +43,9 @@ public class PlayerInformationItem extends AsyncItem {
|
|||
final NickoProfile profile = optionalProfile.get();
|
||||
final AbstractItemBuilder<?> headItem = i18n.translateItem(skull, I18NDict.GUI.Admin.CHECK,
|
||||
target.getName(),
|
||||
(profile.hasData() ? "§a✔" : "§c❌"),
|
||||
(profile.getName() == null ? "§7N/A" : profile.getName()),
|
||||
(profile.getSkin() == null ? "§7N/A" : profile.getSkin()));
|
||||
(profile.hasData() ? "<green>✔</green>" : "<red>❌</red>"),
|
||||
(profile.getName() == null ? "<grey>N/A<grey>" : profile.getName()),
|
||||
(profile.getSkin() == null ? "<grey>N/A</grey>" : profile.getSkin()));
|
||||
|
||||
if (!profile.hasData()) {
|
||||
// Remove the last 2 lines of the lore.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package xyz.ineanto.nicko.gui.items.common;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Material;
|
||||
import xyz.ineanto.nicko.i18n.I18N;
|
||||
import xyz.ineanto.nicko.i18n.I18NDict;
|
||||
|
@ -23,7 +25,14 @@ public class ScrollDownItem extends ScrollItem {
|
|||
final ItemBuilder builder = new ItemBuilder(Material.GREEN_STAINED_GLASS_PANE);
|
||||
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_DOWN);
|
||||
builder.setDisplayName(Component.text(translation.name()).content());
|
||||
if (!gui.canScroll(1)) translation.lore().forEach(builder::addLoreLines);
|
||||
if (!gui.canScroll(1)) {
|
||||
// Lore serialization
|
||||
translation.lore().replaceAll(s -> {
|
||||
final Component deserializedLoreLine = MiniMessage.miniMessage().deserialize(s);
|
||||
return LegacyComponentSerializer.legacySection().serialize(deserializedLoreLine);
|
||||
});
|
||||
translation.lore().forEach(builder::addLoreLines);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package xyz.ineanto.nicko.gui.items.common;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Material;
|
||||
import xyz.ineanto.nicko.i18n.I18N;
|
||||
import xyz.ineanto.nicko.i18n.I18NDict;
|
||||
|
@ -23,7 +25,14 @@ public class ScrollUpItem extends ScrollItem {
|
|||
final ItemBuilder builder = new ItemBuilder(Material.RED_STAINED_GLASS_PANE);
|
||||
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_UP);
|
||||
builder.setDisplayName(Component.text(translation.name()).content());
|
||||
if (!gui.canScroll(-1)) translation.lore().forEach(builder::addLoreLines);
|
||||
if (!gui.canScroll(-1)) {
|
||||
// Lore serialization
|
||||
translation.lore().replaceAll(s -> {
|
||||
final Component deserializedLoreLine = MiniMessage.miniMessage().deserialize(s);
|
||||
return LegacyComponentSerializer.legacySection().serialize(deserializedLoreLine);
|
||||
});
|
||||
translation.lore().forEach(builder::addLoreLines);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package xyz.ineanto.nicko.gui.items.settings;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -68,6 +70,11 @@ public class LanguageCyclingItem {
|
|||
builder.addLoreLines("§6§l> §f" + value.getName());
|
||||
}
|
||||
}
|
||||
|
||||
cyclingChoicesTranslation.lore().replaceAll(s -> {
|
||||
final Component deserializedLoreLine = MiniMessage.miniMessage().deserialize(s);
|
||||
return LegacyComponentSerializer.legacySection().serialize(deserializedLoreLine);
|
||||
});
|
||||
cyclingChoicesTranslation.lore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package xyz.ineanto.nicko.gui.items.settings;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.ineanto.nicko.NickoBukkit;
|
||||
|
@ -61,6 +64,11 @@ public class RandomSkinCyclingItem {
|
|||
|
||||
builder.setDisplayName(randomSkinTranslation.name());
|
||||
toggleableTranslation.lore().forEach(builder::addLoreLines);
|
||||
|
||||
cyclingChoicesTranslation.lore().replaceAll(s -> {
|
||||
final Component deserializedLoreLine = MiniMessage.miniMessage().deserialize(s);
|
||||
return LegacyComponentSerializer.legacySection().serialize(deserializedLoreLine);
|
||||
});
|
||||
cyclingChoicesTranslation.lore().forEach(builder::addLoreLines);
|
||||
return builder;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ gui:
|
|||
settings: "Nicko > Paramètres"
|
||||
admin: "Nicko > Administration"
|
||||
check: "Nicko > Admin... > Vérification"
|
||||
confirm: "... > Confirmer l'action"
|
||||
confirm: "... > Confirmer l''action"
|
||||
cache: "Nicko > Admin... > Cache"
|
||||
invalidate_skin: "... > Cache > Invalider"
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ public class ItemTranslationTest {
|
|||
final Translation translation = i18n.translate(I18NDict.GUI.Admin.Cache.STATISTICS, "1", "1");
|
||||
translation.lore().forEach(System.out::println);
|
||||
assertFalse(translation.lore().isEmpty());
|
||||
assertEquals("§fNombre de requêtes: §b1", translation.lore().get(0));
|
||||
assertEquals("§fNb. de skin dans le cache: §b1", translation.lore().get(1));
|
||||
assertEquals("§8§oLe cache est vidé toutes les 24 heures.", translation.lore().get(2));
|
||||
assertEquals("Nombre de requêtes: <aqua>1</aqua>", translation.lore().get(0));
|
||||
assertEquals("Nb. de skin dans le cache: <aqua>1</aqua>", translation.lore().get(1));
|
||||
assertEquals("<dark_gray><i>Le cache est vidé toutes les 24 heures.</i></dark_gray>", translation.lore().get(2));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
|
Loading…
Reference in a new issue