Skip to content

Commit dfdb8cb

Browse files
feat(i18n): convert SkyblockItem lore strings to translation system
Replace hardcoded strings in ItemLore.java with I18n.string() calls and add items.lore.* entries to items.properties for item display names and lore labels.
1 parent 6c43dfe commit dfdb8cb

2 files changed

Lines changed: 34 additions & 18 deletions

File tree

configuration/i18n/en_US/items.properties

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,3 +1712,19 @@ items.ENCHANTED_MANGROVE_LOG = Enchanted Mangrove Log
17121712
items.ENCHANTED_SEA_LUMIES = Enchanted Sea Lumies
17131713
items.ENCHANTED_TENDER_WOOD = Enchanted Tender Wood
17141714
items.ENCHANTED_VINESAP = Enchanted Vinesap
1715+
1716+
# Item Lore Strings
1717+
items.lore.collection_item = <dark_gray>Collection Item
1718+
items.lore.breaking_power = <dark_gray>Breaking Power {value}
1719+
items.lore.shot_cooldown = <gray>Shot Cooldown: <green>{cooldown}s
1720+
items.lore.ability_label = <gold>Ability: {name} <yellow><bold>{activation}
1721+
items.lore.ability_cooldown = <dark_gray>Cooldown: <green>{cooldown}s
1722+
items.lore.full_set_bonus = <gold>Full Set Bonus: {name} ({wearing}/{total})
1723+
items.lore.right_click_recipes = <yellow>Right-click to view recipes!
1724+
items.lore.reforgeable = <dark_gray>This item can be reforged!
1725+
items.lore.soulbound = <dark_gray>* {prefix}Soulbound *
1726+
items.lore.soulbound_coop_prefix = Co-op
1727+
items.lore.stats_when_shot = <dark_gray>Stats added when shot!
1728+
items.lore.not_finished = <red><bold>ITEM IS NOT FINISHED!
1729+
items.lore.splash_potion_suffix = Splash Potion
1730+
items.lore.potion_suffix = Potion

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/item/ItemLore.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import net.swofty.commons.skyblock.statistics.ItemStatistic;
2020
import net.swofty.commons.skyblock.statistics.ItemStatistics;
2121
import net.swofty.commons.skyblock.item.attribute.attributes.ItemAttributePotionData;
22+
import net.swofty.type.generic.i18n.I18n;
2223
import net.swofty.type.skyblockgeneric.collection.CollectionCategories;
2324
import net.swofty.type.skyblockgeneric.gems.GemRarity;
2425
import net.swofty.type.skyblockgeneric.gems.Gemstone;
@@ -73,18 +74,18 @@ public void updateLore(@Nullable SkyBlockPlayer player) {
7374
if (effectForName != null) {
7475
String effectDisplay = effectForName.getLevelDisplay(potionDataForName.getLevel());
7576
if (potionDataForName.isSplash()) {
76-
displayName = effectDisplay + " Splash Potion";
77+
displayName = effectDisplay + " " + I18n.string("items.lore.splash_potion_suffix");
7778
} else {
78-
displayName = effectDisplay + " Potion";
79+
displayName = effectDisplay + " " + I18n.string("items.lore.potion_suffix");
7980
}
8081
} else if (handler.getPotentialType() != null) {
81-
displayName = handler.getPotentialType().getDisplayName();
82+
displayName = I18n.string("items." + handler.getPotentialType().name());
8283
} else {
8384
Material material = stack.material();
8485
displayName = StringUtility.toNormalCase(material.key().value());
8586
}
8687
} else if (handler.getPotentialType() != null) {
87-
displayName = handler.getPotentialType().getDisplayName();
88+
displayName = I18n.string("items." + handler.getPotentialType().name());
8889
} else {
8990
Material material = stack.material();
9091
displayName = StringUtility.toNormalCase(material.key().value());
@@ -123,20 +124,20 @@ public void updateLore(@Nullable SkyBlockPlayer player) {
123124
underNameDisplay.getDisplays().forEach(line -> addLoreLine("§8" + line));
124125

125126
if (type != null && CollectionCategories.getCategory(type) != null) {
126-
addLoreLine("§8Collection Item");
127+
addLoreLine(I18n.string("items.lore.collection_item"));
127128
}
128129

129130
addLoreLine(null);
130131
} else {
131132
if (type != null && CollectionCategories.getCategory(type) != null) {
132-
addLoreLine("§8Collection Item");
133+
addLoreLine(I18n.string("items.lore.collection_item"));
133134
addLoreLine(null);
134135
}
135136
}
136137

137138
// Handle Item Statistics
138139
if (handler.isMiningTool()) {
139-
addLoreLine("§8Breaking Power " + handler.getBreakingPower());
140+
addLoreLine(I18n.string("items.lore.breaking_power", Map.of("value", String.valueOf(handler.getBreakingPower()))));
140141
addLoreLine(null);
141142
}
142143

@@ -157,7 +158,7 @@ public void updateLore(@Nullable SkyBlockPlayer player) {
157158

158159
if (item.hasComponent(ShortBowComponent.class)) {
159160
ShortBowComponent shortBowComponent = item.getComponent(ShortBowComponent.class);
160-
addLoreLine("§7Shot Cooldown: §a" + shortBowComponent.getCooldown() + "s");
161+
addLoreLine(I18n.string("items.lore.shot_cooldown", Map.of("cooldown", String.valueOf(shortBowComponent.getCooldown()))));
161162
addNextLine = true;
162163
}
163164

@@ -291,16 +292,15 @@ public void updateLore(@Nullable SkyBlockPlayer player) {
291292
AbilityComponent abilityComponent = item.getComponent(AbilityComponent.class);
292293

293294
abilityComponent.getAbilities().forEach(ability -> {
294-
addLoreLine("§6Ability: " + ability.getName() + " §e§l" +
295-
ability.getActivation().getDisplay());
295+
addLoreLine(I18n.string("items.lore.ability_label", Map.of("name", ability.getName(), "activation", ability.getActivation().getDisplay())));
296296
for (String line : StringUtility.splitByWordAndLength(ability.getDescription().apply(player, item), 40))
297297
addLoreLine("§7" + line);
298298

299299
String costDisplay = ability.getCost().getLoreDisplay();
300300
if (costDisplay != null) addLoreLine(costDisplay);
301301

302302
if (ability.getCooldownTicks() > 20) {
303-
addLoreLine("§8Cooldown: §a" + StringUtility.decimalify((double) ability.getCooldownTicks() / 20, 1) + "s");
303+
addLoreLine(I18n.string("items.lore.ability_cooldown", Map.of("cooldown", StringUtility.decimalify((double) ability.getCooldownTicks() / 20, 1))));
304304
}
305305

306306
addLoreLine(null);
@@ -333,13 +333,13 @@ public void updateLore(@Nullable SkyBlockPlayer player) {
333333
}
334334
}
335335
int totalPieces = ArmorSetRegistry.getPieceCount(ArmorSetRegistry.getArmorSet(armorSet.getClass()));
336-
addLoreLine("§6Full Set Bonus: " + armorSet.getName() + " (" + wearingAmount + "/" + totalPieces + ")");
336+
addLoreLine(I18n.string("items.lore.full_set_bonus", Map.of("name", armorSet.getName(), "wearing", String.valueOf(wearingAmount), "total", String.valueOf(totalPieces))));
337337
armorSet.getDescription().forEach(line -> addLoreLine("§7" + line));
338338
addLoreLine(null);
339339
}
340340

341341
if (item.hasComponent(RightClickRecipeComponent.class)) {
342-
addLoreLine("§eRight-click to view recipes!");
342+
addLoreLine(I18n.string("items.lore.right_click_recipes"));
343343
addLoreLine(null);
344344
}
345345

@@ -349,19 +349,20 @@ public void updateLore(@Nullable SkyBlockPlayer player) {
349349
}
350350

351351
if (item.hasComponent(ReforgableComponent.class)) {
352-
addLoreLine("§8This item can be reforged!");
352+
addLoreLine(I18n.string("items.lore.reforgeable"));
353353
if (handler.getReforge() != null) displayName = handler.getReforge().getPrefix() + " " + displayName;
354354
}
355355

356356
ItemAttributeSoulbound.SoulBoundData bound = handler.getSoulBoundData();
357-
if (bound != null) addLoreLine("§8* " + (bound.isCoopAllowed() ? "Co-op " : "") + "Soulbound *");
357+
if (bound != null)
358+
addLoreLine(I18n.string("items.lore.soulbound", Map.of("prefix", bound.isCoopAllowed() ? I18n.string("items.lore.soulbound_coop_prefix") : "")));
358359

359360
if (item.hasComponent(ArrowComponent.class)) {
360-
addLoreLine("§8Stats added when shot!");
361+
addLoreLine(I18n.string("items.lore.stats_when_shot"));
361362
}
362363

363364
if (item.hasComponent(NotFinishedYetComponent.class)) {
364-
addLoreLine("§c§lITEM IS NOT FINISHED!");
365+
addLoreLine(I18n.string("items.lore.not_finished"));
365366
addLoreLine(null);
366367
}
367368

@@ -425,4 +426,3 @@ private void addLoreLine(String line) {
425426
.decorations(Collections.singleton(TextDecoration.ITALIC), false));
426427
}
427428
}
428-

0 commit comments

Comments
 (0)