Skip to content

Commit 88c63d5

Browse files
refactor(i18n): migrate 92 GUI files to use I18n translation system
Replace all hardcoded UI strings across GUI Java files with I18n.string() and I18n.lore() calls referencing keys from the properties files. Covers banker, auction, bazaar, museum, rusty, builder, shop, stash, coop, abiphone, profile, enchantment, reforge, minion, anvil, SBMenu and all sub-GUIs (levels, bags, pets, skills, storage, recipes, profiles, quests).
1 parent d25f1dc commit 88c63d5

92 files changed

Lines changed: 1635 additions & 2093 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

type.generic/src/main/java/net/swofty/type/generic/i18n/I18n.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
66
import net.kyori.adventure.translation.GlobalTranslator;
77

8+
import java.util.List;
89
import java.util.Locale;
910
import java.util.Map;
1011

@@ -63,6 +64,14 @@ public static String string(String key, Locale locale, Map<String, String> place
6364
return result;
6465
}
6566

67+
public static List<String> lore(String key) {
68+
return List.of(string(key).split("\n"));
69+
}
70+
71+
public static List<String> lore(String key, Map<String, String> placeholders) {
72+
return List.of(string(key, placeholders).split("\n"));
73+
}
74+
6675
public static String[] dialogueLines(String key) {
6776
return dialogueLines(key, HypixelTranslator.defaultLocale);
6877
}

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/GUIAnvil.java

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.swofty.type.generic.gui.inventory.ItemStackCreator;
1212
import net.swofty.type.generic.gui.inventory.item.GUIClickableItem;
1313
import net.swofty.type.generic.gui.inventory.item.GUIItem;
14+
import net.swofty.type.generic.i18n.I18n;
1415
import net.swofty.type.generic.user.HypixelPlayer;
1516
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
1617
import net.swofty.type.skyblockgeneric.item.components.AnvilCombinableComponent;
@@ -19,6 +20,7 @@
1920

2021
import java.util.ArrayList;
2122
import java.util.List;
23+
import java.util.Map;
2224

2325
public class GUIAnvil extends HypixelInventoryGUI {
2426

@@ -35,7 +37,7 @@ public class GUIAnvil extends HypixelInventoryGUI {
3537
private SkyBlockItem sacrificeItem = null;
3638

3739
public GUIAnvil() {
38-
super("Anvil", InventoryType.CHEST_6_ROW);
40+
super(I18n.string("gui_anvil.title"), InventoryType.CHEST_6_ROW);
3941
}
4042

4143
@Override
@@ -58,9 +60,8 @@ private void setupCombineButton() {
5860
set(new GUIItem(COMBINE_BUTTON_SLOT) {
5961
@Override
6062
public ItemStack.Builder getItem(HypixelPlayer p) {
61-
return ItemStackCreator.getStack("§aCombine Items", Material.ANVIL, 1,
62-
"§7Combine the items in the slots to the",
63-
"§7left and right below.");
63+
return ItemStackCreator.getStack(I18n.string("gui_anvil.combine_items"), Material.ANVIL, 1,
64+
I18n.lore("gui_anvil.combine_items.lore"));
6465
}
6566
});
6667
}
@@ -69,10 +70,8 @@ private void setupResultSlot() {
6970
set(new GUIItem(RESULT_SLOT) {
7071
@Override
7172
public ItemStack.Builder getItem(HypixelPlayer p) {
72-
return ItemStackCreator.getStack("§cAnvil", Material.BARRIER, 1,
73-
"§7Place a target item in the left slot",
74-
"§7and a sacrifice item in the right slot",
75-
"§7to combine them!");
73+
return ItemStackCreator.getStack(I18n.string("gui_anvil.result_empty"), Material.BARRIER, 1,
74+
I18n.lore("gui_anvil.result_empty.lore"));
7675
}
7776
});
7877
}
@@ -274,15 +273,11 @@ private void updateIndicators(boolean isUpgradeValid, boolean isSacrificeValid,
274273
? Material.LIME_STAINED_GLASS_PANE
275274
: Material.RED_STAINED_GLASS_PANE;
276275

277-
ItemStack.Builder upgradeIndicator = ItemStackCreator.getStack("§6Item to Upgrade", upgradeMaterial, 1,
278-
"§7The item you want to upgrade should",
279-
"§7be placed in the slot on this side.");
276+
ItemStack.Builder upgradeIndicator = ItemStackCreator.getStack(I18n.string("gui_anvil.item_to_upgrade"), upgradeMaterial, 1,
277+
I18n.lore("gui_anvil.item_to_upgrade.lore"));
280278

281-
ItemStack.Builder sacrificeIndicator = ItemStackCreator.getStack("§6Item to Sacrifice", sacrificeMaterial, 1,
282-
"§7The item you are sacrificing in order",
283-
"§7to upgrade the item on the left",
284-
"§7should be placed in the slot on this",
285-
"§7side.");
279+
ItemStack.Builder sacrificeIndicator = ItemStackCreator.getStack(I18n.string("gui_anvil.item_to_sacrifice"), sacrificeMaterial, 1,
280+
I18n.lore("gui_anvil.item_to_sacrifice.lore"));
286281

287282
for (int slot : UPGRADE_INDICATOR_SLOTS) {
288283
set(slot, upgradeIndicator);
@@ -307,18 +302,16 @@ private void updateResultPreview(boolean isUpgradeValid, boolean isSacrificeVali
307302
set(new GUIItem(RESULT_SLOT) {
308303
@Override
309304
public ItemStack.Builder getItem(HypixelPlayer p) {
310-
return ItemStackCreator.getStack("§cError!", Material.BARRIER, 1,
311-
"§7You can not combine those Items");
305+
return ItemStackCreator.getStack(I18n.string("gui_anvil.result_error"), Material.BARRIER, 1,
306+
I18n.lore("gui_anvil.result_error.lore"));
312307
}
313308
});
314309
} else {
315310
set(new GUIItem(RESULT_SLOT) {
316311
@Override
317312
public ItemStack.Builder getItem(HypixelPlayer p) {
318-
return ItemStackCreator.getStack("§cAnvil", Material.BARRIER, 1,
319-
"§7Place a target item in the left slot",
320-
"§7and a sacrifice item in the right slot",
321-
"§7to combine them!");
313+
return ItemStackCreator.getStack(I18n.string("gui_anvil.result_empty"), Material.BARRIER, 1,
314+
I18n.lore("gui_anvil.result_empty.lore"));
322315
}
323316
});
324317
}
@@ -342,9 +335,8 @@ private void updateCombineButton(boolean canCraft) {
342335
set(new GUIItem(COMBINE_BUTTON_SLOT) {
343336
@Override
344337
public ItemStack.Builder getItem(HypixelPlayer p) {
345-
return ItemStackCreator.getStack("§aCombine Items", Material.ANVIL, 1,
346-
"§7Combine the items in the slots to the",
347-
"§7left and right below.");
338+
return ItemStackCreator.getStack(I18n.string("gui_anvil.combine_items"), Material.ANVIL, 1,
339+
I18n.lore("gui_anvil.combine_items.lore"));
348340
}
349341
});
350342
return;
@@ -353,18 +345,16 @@ public ItemStack.Builder getItem(HypixelPlayer p) {
353345
int levelCost = sacrificeItem.getComponent(AnvilCombinableComponent.class)
354346
.applyCostLevels(upgradeItem, sacrificeItem, (SkyBlockPlayer) getPlayer());
355347

356-
List<String> lore = new ArrayList<>();
357-
lore.add("§7Combine the items in the slots to the");
358-
lore.add("§7left and right below.");
348+
List<String> lore = new ArrayList<>(I18n.lore("gui_anvil.combine_items.lore"));
359349

360350
if (levelCost > 0) {
361351
lore.add("");
362-
lore.add("§7Cost");
363-
lore.add("§9" + levelCost + " Exp Levels");
352+
lore.add(I18n.string("gui_anvil.cost_label"));
353+
lore.add(I18n.string("gui_anvil.cost_exp_levels", Map.of("cost", String.valueOf(levelCost))));
364354
}
365355

366356
lore.add("");
367-
lore.add("§eClick to combine!");
357+
lore.add(I18n.string("gui_anvil.click_to_combine"));
368358

369359
set(new GUIClickableItem(COMBINE_BUTTON_SLOT) {
370360
@Override
@@ -375,7 +365,7 @@ public void run(InventoryPreClickEvent e, HypixelPlayer p) {
375365

376366
@Override
377367
public ItemStack.Builder getItem(HypixelPlayer p) {
378-
return ItemStackCreator.getStack("§aCombine Items", Material.ANVIL, 1, lore);
368+
return ItemStackCreator.getStack(I18n.string("gui_anvil.combine_items"), Material.ANVIL, 1, lore);
379369
}
380370
});
381371
}
@@ -391,7 +381,7 @@ private void performCraft(SkyBlockPlayer player) {
391381
int requiredLevels = component.applyCostLevels(upgradeItem, sacrificeItem, player);
392382

393383
if (player.getLevel() < requiredLevels) {
394-
player.sendMessage("§cYou don't have enough Experience Levels!");
384+
player.sendMessage(I18n.string("gui_anvil.not_enough_levels"));
395385
return;
396386
}
397387

@@ -418,8 +408,8 @@ private void performCraft(SkyBlockPlayer player) {
418408
set(new GUIItem(COMBINE_BUTTON_SLOT) {
419409
@Override
420410
public ItemStack.Builder getItem(HypixelPlayer p) {
421-
return ItemStackCreator.getStack("§aAnvil", Material.OAK_SIGN, 1,
422-
"§7Claim the result item above!");
411+
return ItemStackCreator.getStack(I18n.string("gui_anvil.claim_result"), Material.OAK_SIGN, 1,
412+
I18n.lore("gui_anvil.claim_result.lore"));
423413
}
424414
});
425415

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/GUIBoosterCookie.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
import net.swofty.type.generic.gui.inventory.HypixelInventoryGUI;
1010
import net.swofty.type.generic.gui.inventory.ItemStackCreator;
1111
import net.swofty.type.generic.gui.inventory.item.GUIClickableItem;
12+
import net.swofty.type.generic.i18n.I18n;
1213
import net.swofty.type.generic.user.HypixelPlayer;
1314
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
1415

1516
public class GUIBoosterCookie extends HypixelInventoryGUI {
1617
public GUIBoosterCookie() {
17-
super("Consume Booster Cookie?", InventoryType.CHEST_3_ROW);
18+
super(I18n.string("gui_misc.booster_cookie.title"), InventoryType.CHEST_3_ROW);
1819
}
1920

2021
@Override
@@ -24,8 +25,8 @@ public void onOpen(InventoryGUIOpenEvent e) {
2425
@Override
2526
public ItemStack.Builder getItem(HypixelPlayer p) {
2627
SkyBlockPlayer player = (SkyBlockPlayer) p;
27-
return ItemStackCreator.getStack("§cCancel", Material.RED_CONCRETE, 1,
28-
"§7I'm not hungry...");
28+
return ItemStackCreator.getStack(I18n.string("gui_misc.booster_cookie.cancel_button"), Material.RED_CONCRETE, 1,
29+
I18n.lore("gui_misc.booster_cookie.cancel_button.lore"));
2930
}
3031

3132
@Override
@@ -55,15 +56,8 @@ public void run(InventoryPreClickEvent e, HypixelPlayer p) {
5556
@Override
5657
public ItemStack.Builder getItem(HypixelPlayer p) {
5758
SkyBlockPlayer player = (SkyBlockPlayer) p;
58-
return ItemStackCreator.getStack("§eConsume Cookie", Material.COOKIE, 1,
59-
"§7Gain the §dCookie Buff§!",
60-
" ",
61-
"§7Duration: §b4 days§!",
62-
" ",
63-
"§7You will be able to gain",
64-
"§b4,000 Bits §7from this",
65-
"§7cookie."
66-
);
59+
return ItemStackCreator.getStack(I18n.string("gui_misc.booster_cookie.consume_button"), Material.COOKIE, 1,
60+
I18n.lore("gui_misc.booster_cookie.consume_button.lore"));
6761
}
6862
});
6963
updateItemStacks(getInventory(), getPlayer());

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/GUIBrewingStand.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import net.swofty.type.generic.gui.inventory.ItemStackCreator;
1414
import net.swofty.type.generic.gui.inventory.RefreshingGUI;
1515
import net.swofty.type.generic.gui.inventory.item.GUIClickableItem;
16+
import net.swofty.type.generic.i18n.I18n;
1617
import net.swofty.type.generic.user.HypixelPlayer;
1718
import net.swofty.type.skyblockgeneric.block.SkyBlockBlock;
1819
import net.swofty.type.skyblockgeneric.block.attribute.attributes.BlockAttributeBrewingData;
@@ -28,6 +29,8 @@
2829
import net.swofty.commons.skyblock.item.Rarity;
2930
import net.swofty.commons.skyblock.item.attribute.attributes.ItemAttributePotionData;
3031

32+
import java.util.Map;
33+
3134
public class GUIBrewingStand extends HypixelInventoryGUI implements RefreshingGUI {
3235

3336
private static final int INGREDIENT_SLOT = 13;
@@ -45,7 +48,7 @@ public class GUIBrewingStand extends HypixelInventoryGUI implements RefreshingGU
4548
private SkyBlockItem[] potionItems = new SkyBlockItem[3];
4649

4750
public GUIBrewingStand(Instance instance, Point position, SkyBlockBlock block) {
48-
super("Brewing Stand", InventoryType.CHEST_6_ROW);
51+
super(I18n.string("gui_misc.brewing_stand.title"), InventoryType.CHEST_6_ROW);
4952
this.instance = instance;
5053
this.blockPosition = position;
5154
this.block = block;
@@ -199,12 +202,12 @@ private void updateAnimationPanes(BlockAttributeBrewingData.BrewingData brewingD
199202
if (brewingData.isBrewing()) {
200203
paneMaterial = animationToggle ? Material.RED_STAINED_GLASS_PANE : Material.ORANGE_STAINED_GLASS_PANE;
201204
long remainingSeconds = brewingData.getRemainingTimeMs() / 1000;
202-
paneName = "§e" + remainingSeconds + "s remaining";
205+
paneName = I18n.string("gui_misc.brewing_stand.remaining_time", Map.of("seconds", String.valueOf(remainingSeconds)));
203206
paneLore = new String[0];
204207
} else {
205208
paneMaterial = Material.LIGHT_BLUE_STAINED_GLASS_PANE;
206-
paneName = "§bPlace Water Bottles or Potions";
207-
paneLore = new String[]{"§bbelow to brew."};
209+
paneName = I18n.string("gui_misc.brewing_stand.place_bottles");
210+
paneLore = new String[]{I18n.string("gui_misc.brewing_stand.place_bottles_below")};
208211
}
209212

210213
for (int slot : ANIMATION_SLOTS) {

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/GUIConsumeSoulflow.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package net.swofty.type.skyblockgeneric.gui.inventories;
22

3-
import net.kyori.adventure.text.Component;
43
import net.minestom.server.inventory.InventoryType;
54
import net.minestom.server.item.ItemStack;
65
import net.swofty.type.generic.data.datapoints.DatapointInteger;
76
import net.swofty.type.generic.gui.inventory.ItemStackCreator;
87
import net.swofty.type.generic.gui.v2.*;
98
import net.swofty.type.generic.gui.v2.context.ViewContext;
9+
import net.swofty.type.generic.i18n.I18n;
1010
import net.swofty.type.skyblockgeneric.data.SkyBlockDataHandler;
1111
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
1212
import net.swofty.type.skyblockgeneric.item.components.SoulflowComponent;
1313
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
1414

15+
import java.util.Map;
16+
1517
public class GUIConsumeSoulflow implements View<GUIConsumeSoulflow.State> {
1618

1719
public record State(SkyBlockItem item) {
@@ -24,7 +26,7 @@ public record State(SkyBlockItem item) {
2426

2527
@Override
2628
public ViewConfiguration<State> configuration() {
27-
return new ViewConfiguration<>("Consume Soulflow", InventoryType.CHEST_4_ROW);
29+
return new ViewConfiguration<>(I18n.string("gui_misc.consume_soulflow.title"), InventoryType.CHEST_4_ROW);
2830
}
2931

3032
@Override
@@ -39,19 +41,13 @@ public void layout(ViewLayout<State> layout, State state, ViewContext ctx) {
3941
int addition = s.item().getAmount() * itemSoulflow;
4042

4143
return ItemStackCreator.getStackHead(
42-
"§aConsume Soulflow?",
44+
I18n.string("gui_misc.consume_soulflow.confirm_button"),
4345
"94f0c693b85658b0bae792c9f9b717eb024ab8c4b349455648ea08358b50ddc4",
4446
1,
45-
"§7Takes all the §3⸎ Soulflow §7items in",
46-
"§7your inventory and internalizes them",
47-
"§7to be ready for use.",
48-
"",
49-
"§7Internalized: §3" + soulflow + "⸎",
50-
"",
51-
"§7Adding from inventory: §3+" + addition + "⸎ Soulflow",
52-
"",
53-
"§eClick to consume!"
54-
);
47+
I18n.lore("gui_misc.consume_soulflow.confirm_button.lore", Map.of(
48+
"soulflow", String.valueOf(soulflow),
49+
"addition", String.valueOf(addition)
50+
)));
5551
},
5652
(click, viewCtx) -> {
5753
SkyBlockPlayer player = (SkyBlockPlayer) viewCtx.player();
@@ -62,7 +58,10 @@ public void layout(ViewLayout<State> layout, State state, ViewContext ctx) {
6258
int addition = click.state().item().getAmount() * itemSoulflow;
6359

6460
data.get(SkyBlockDataHandler.Data.SOULFLOW, DatapointInteger.class).setValue(soulflow + addition);
65-
player.sendMessage("§bYou internalized §3+" + addition + "⸎ Soulflow §band have a total of §3" + (soulflow + addition) + "⸎§b!");
61+
player.sendMessage(I18n.string("gui_misc.consume_soulflow.consumed_message", Map.of(
62+
"addition", String.valueOf(addition),
63+
"total", String.valueOf(soulflow + addition)
64+
)));
6665

6766
player.getInventory().setItemStack(player.getHeldSlot(), ItemStack.AIR);
6867
player.closeInventory();

0 commit comments

Comments
 (0)