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.setName(defaultName);
|
||||||
profile.setSkin(defaultName);
|
profile.setSkin(defaultName);
|
||||||
dataStore.getCache().cache(player.getUniqueId(), profile);
|
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) {
|
public ActionResult updatePlayer(boolean skinChange, boolean reset) {
|
||||||
|
|
|
@ -43,9 +43,9 @@ public class PlayerInformationItem extends AsyncItem {
|
||||||
final NickoProfile profile = optionalProfile.get();
|
final NickoProfile profile = optionalProfile.get();
|
||||||
final AbstractItemBuilder<?> headItem = i18n.translateItem(skull, I18NDict.GUI.Admin.CHECK,
|
final AbstractItemBuilder<?> headItem = i18n.translateItem(skull, I18NDict.GUI.Admin.CHECK,
|
||||||
target.getName(),
|
target.getName(),
|
||||||
(profile.hasData() ? "§a✔" : "§c❌"),
|
(profile.hasData() ? "<green>✔</green>" : "<red>❌</red>"),
|
||||||
(profile.getName() == null ? "§7N/A" : profile.getName()),
|
(profile.getName() == null ? "<grey>N/A<grey>" : profile.getName()),
|
||||||
(profile.getSkin() == null ? "§7N/A" : profile.getSkin()));
|
(profile.getSkin() == null ? "<grey>N/A</grey>" : profile.getSkin()));
|
||||||
|
|
||||||
if (!profile.hasData()) {
|
if (!profile.hasData()) {
|
||||||
// Remove the last 2 lines of the lore.
|
// Remove the last 2 lines of the lore.
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package xyz.ineanto.nicko.gui.items.common;
|
package xyz.ineanto.nicko.gui.items.common;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
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.Material;
|
||||||
import xyz.ineanto.nicko.i18n.I18N;
|
import xyz.ineanto.nicko.i18n.I18N;
|
||||||
import xyz.ineanto.nicko.i18n.I18NDict;
|
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 ItemBuilder builder = new ItemBuilder(Material.GREEN_STAINED_GLASS_PANE);
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_DOWN);
|
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_DOWN);
|
||||||
builder.setDisplayName(Component.text(translation.name()).content());
|
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;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package xyz.ineanto.nicko.gui.items.common;
|
package xyz.ineanto.nicko.gui.items.common;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
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.Material;
|
||||||
import xyz.ineanto.nicko.i18n.I18N;
|
import xyz.ineanto.nicko.i18n.I18N;
|
||||||
import xyz.ineanto.nicko.i18n.I18NDict;
|
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 ItemBuilder builder = new ItemBuilder(Material.RED_STAINED_GLASS_PANE);
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_UP);
|
final Translation translation = i18n.translate(I18NDict.GUI.SCROLL_UP);
|
||||||
builder.setDisplayName(Component.text(translation.name()).content());
|
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;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package xyz.ineanto.nicko.gui.items.settings;
|
package xyz.ineanto.nicko.gui.items.settings;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
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.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -68,6 +70,11 @@ public class LanguageCyclingItem {
|
||||||
builder.addLoreLines("§6§l> §f" + value.getName());
|
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);
|
cyclingChoicesTranslation.lore().forEach(builder::addLoreLines);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package xyz.ineanto.nicko.gui.items.settings;
|
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.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import xyz.ineanto.nicko.NickoBukkit;
|
import xyz.ineanto.nicko.NickoBukkit;
|
||||||
|
@ -61,6 +64,11 @@ public class RandomSkinCyclingItem {
|
||||||
|
|
||||||
builder.setDisplayName(randomSkinTranslation.name());
|
builder.setDisplayName(randomSkinTranslation.name());
|
||||||
toggleableTranslation.lore().forEach(builder::addLoreLines);
|
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);
|
cyclingChoicesTranslation.lore().forEach(builder::addLoreLines);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ gui:
|
||||||
settings: "Nicko > Paramètres"
|
settings: "Nicko > Paramètres"
|
||||||
admin: "Nicko > Administration"
|
admin: "Nicko > Administration"
|
||||||
check: "Nicko > Admin... > Vérification"
|
check: "Nicko > Admin... > Vérification"
|
||||||
confirm: "... > Confirmer l'action"
|
confirm: "... > Confirmer l''action"
|
||||||
cache: "Nicko > Admin... > Cache"
|
cache: "Nicko > Admin... > Cache"
|
||||||
invalidate_skin: "... > Cache > Invalider"
|
invalidate_skin: "... > Cache > Invalider"
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,9 @@ public class ItemTranslationTest {
|
||||||
final Translation translation = i18n.translate(I18NDict.GUI.Admin.Cache.STATISTICS, "1", "1");
|
final Translation translation = i18n.translate(I18NDict.GUI.Admin.Cache.STATISTICS, "1", "1");
|
||||||
translation.lore().forEach(System.out::println);
|
translation.lore().forEach(System.out::println);
|
||||||
assertFalse(translation.lore().isEmpty());
|
assertFalse(translation.lore().isEmpty());
|
||||||
assertEquals("§fNombre de requêtes: §b1", translation.lore().get(0));
|
assertEquals("Nombre de requêtes: <aqua>1</aqua>", translation.lore().get(0));
|
||||||
assertEquals("§fNb. de skin dans le cache: §b1", translation.lore().get(1));
|
assertEquals("Nb. de skin dans le cache: <aqua>1</aqua>", translation.lore().get(1));
|
||||||
assertEquals("§8§oLe cache est vidé toutes les 24 heures.", translation.lore().get(2));
|
assertEquals("<dark_gray><i>Le cache est vidé toutes les 24 heures.</i></dark_gray>", translation.lore().get(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
|
|
Loading…
Reference in a new issue