Skip to content

Commit 1a31cc5

Browse files
refactor(i18n): migrate 8 hub NPCs to use DialogueSet.ofTranslation()
Replace hardcoded dialogue strings with translation key references in NPCBaker, NPCBanker, NPCArthur, NPCBartender, NPCAlchemist, NPCAdventurer, NPCAuctionMaster, and NPCFarmerRigby.
1 parent 2dff66c commit 1a31cc5

8 files changed

Lines changed: 40 additions & 103 deletions

File tree

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCAdventurer.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.swofty.type.generic.entity.npc.HypixelNPC;
66
import net.swofty.type.generic.entity.npc.configuration.HumanConfiguration;
77
import net.swofty.type.generic.event.custom.NPCInteractEvent;
8+
import net.swofty.type.generic.i18n.I18n;
89
import net.swofty.type.generic.user.HypixelPlayer;
910
import net.swofty.type.hub.gui.GUIShopAdventurer;
1011

@@ -57,13 +58,7 @@ public void onClick(NPCInteractEvent e) {
5758
@Override
5859
public DialogueSet[] dialogues(HypixelPlayer player) {
5960
return new DialogueSet[] {
60-
DialogueSet.builder()
61-
.key("hello").lines(new String[]{
62-
"I've seen it all - every island from here to the edge of the world!",
63-
"Over the years I've acquired a variety of Talismans and Artifact.",
64-
"For a price, you can have it all!",
65-
"Click me again to open the Adventurer Shop!"
66-
}).build(),
61+
DialogueSet.ofTranslation("hello", "npcs_hub.adventurer.dialogue.hello")
6762
};
6863
}
6964
}

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCAlchemist.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import net.swofty.type.generic.entity.npc.HypixelNPC;
77
import net.swofty.type.generic.entity.npc.configuration.AnimalConfiguration;
88
import net.swofty.type.generic.event.custom.NPCInteractEvent;
9+
import net.swofty.type.generic.i18n.I18n;
910
import net.swofty.type.generic.user.HypixelPlayer;
1011
import net.swofty.type.hub.gui.GUIShopAlchemist;
1112
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
1213

14+
import java.util.Map;
15+
1316
public class NPCAlchemist extends HypixelNPC {
1417
public NPCAlchemist() {
1518
super(new AnimalConfiguration() {
@@ -60,12 +63,7 @@ public void onClick(NPCInteractEvent e) {
6063
@Override
6164
public DialogueSet[] dialogues(HypixelPlayer player) {
6265
return new DialogueSet[] {
63-
DialogueSet.builder()
64-
.key("hello").lines(new String[]{
65-
"There is a darkness in you, " + player.getUsername() + ".",
66-
"I've seen it in my flames, you are destined for great things.",
67-
"For now, you shouldn't let it get to your head."
68-
}).build(),
66+
DialogueSet.ofTranslation("hello", "npcs_hub.alchemist.dialogue.hello", Map.of("player", player.getUsername()))
6967
};
7068
}
7169
}

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCArthur.java

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.swofty.type.generic.entity.npc.HypixelNPC;
55
import net.swofty.type.generic.entity.npc.configuration.HumanConfiguration;
66
import net.swofty.type.generic.event.custom.NPCInteractEvent;
7+
import net.swofty.type.generic.i18n.I18n;
78
import net.swofty.type.generic.user.HypixelPlayer;
89

910
import java.util.stream.Stream;
@@ -48,38 +49,14 @@ public void onClick(NPCInteractEvent e) {
4849

4950
@Override
5051
public DialogueSet[] dialogues(HypixelPlayer player) {
51-
return Stream.of(
52-
DialogueSet.builder()
53-
.key("dialogue-1").lines(new String[]{
54-
"Fuel makes your Minion work harder for a limited time",
55-
"There are multiple types of Fuel, like Coal, Enchanted Bread and many more!"
56-
}).build(),
57-
DialogueSet.builder()
58-
.key("dialogue-2").lines(new String[]{
59-
"If you place your Minions poorly, they will complain!",
60-
"Open their Menu and look for their Perfect Layout!"
61-
}).build(),
62-
DialogueSet.builder()
63-
.key("dialogue-3").lines(new String[]{
64-
"Once you unlock a Minion, you also unlock all their Level up recipes!"
65-
}).build(),
66-
DialogueSet.builder()
67-
.key("dialogue-4").lines(new String[]{
68-
"Use a §aBudget Hopper§f to make your Minions automatically sell their work once full!"
69-
}).build(),
70-
DialogueSet.builder()
71-
.key("dialogue-5").lines(new String[]{
72-
"My favorite Minion Upgrade is the §aCompactor§f, sooooo useful!",
73-
"I have one in my Minion, look!"
74-
}).build(),
75-
DialogueSet.builder()
76-
.key("dialogue-6").lines(new String[]{
77-
"People always empty the storage of my Minion when I'm not looking!"
78-
}).build(),
79-
DialogueSet.builder()
80-
.key("dialogue-7").lines(new String[]{
81-
"Minions always have 4 Upgrade Slots where you can place Fuel or else"
82-
}).build()
83-
).toArray(DialogueSet[]::new);
52+
return new DialogueSet[] {
53+
DialogueSet.ofTranslation("dialogue-1", "npcs_hub.arthur.dialogue.dialogue_1"),
54+
DialogueSet.ofTranslation("dialogue-2", "npcs_hub.arthur.dialogue.dialogue_2"),
55+
DialogueSet.ofTranslation("dialogue-3", "npcs_hub.arthur.dialogue.dialogue_3"),
56+
DialogueSet.ofTranslation("dialogue-4", "npcs_hub.arthur.dialogue.dialogue_4"),
57+
DialogueSet.ofTranslation("dialogue-5", "npcs_hub.arthur.dialogue.dialogue_5"),
58+
DialogueSet.ofTranslation("dialogue-6", "npcs_hub.arthur.dialogue.dialogue_6"),
59+
DialogueSet.ofTranslation("dialogue-7", "npcs_hub.arthur.dialogue.dialogue_7")
60+
};
8461
}
8562
}

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCAuctionMaster.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.swofty.type.generic.entity.npc.HypixelNPC;
55
import net.swofty.type.generic.entity.npc.configuration.HumanConfiguration;
66
import net.swofty.type.generic.event.custom.NPCInteractEvent;
7+
import net.swofty.type.generic.i18n.I18n;
78
import net.swofty.type.generic.user.HypixelPlayer;
89
import net.swofty.type.skyblockgeneric.gui.inventories.auction.GUIAuctionHouse;
910
import net.swofty.type.skyblockgeneric.mission.MissionData;
@@ -44,15 +45,9 @@ public boolean looking(HypixelPlayer player) {
4445

4546
@Override
4647
public DialogueSet[] dialogues(HypixelPlayer player) {
47-
return Stream.of(
48-
DialogueSet.builder()
49-
.key("quest-hello").lines(new String[]{
50-
"Hey there, I'm the Auction Master.",
51-
"In the §6Auction House§f, you can put your valuable items up for auction!",
52-
"You may also want to check back here to see what items other players are selling to see if you can get a good deal.",
53-
"Talk to me or one of the §6Auction Agents §fif you would like to start your first auction or if you want to see the items currently being sold."
54-
}).build()
55-
).toArray(DialogueSet[]::new);
48+
return new DialogueSet[] {
49+
DialogueSet.ofTranslation("quest-hello", "npcs_hub.auction_master.dialogue.quest_hello")
50+
};
5651
}
5752

5853
@Override

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCBaker.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
1616
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
1717

18+
import net.swofty.type.generic.i18n.I18n;
19+
1820
import java.util.List;
1921
import java.util.stream.Stream;
2022

@@ -87,13 +89,8 @@ public void onClick(NPCInteractEvent event) {
8789

8890
@Override
8991
protected DialogueSet[] dialogues(HypixelPlayer player) {
90-
return Stream.of(
91-
DialogueSet.builder()
92-
.key("initial-hello").lines(new String[]{
93-
"At the end of each year I bake cakes for everyone in town to celebrate the year.",
94-
"I made one especially for you, here you go.",
95-
"I've recently added a §dNew Year Cake Bag §fto my inventory. Sadly, it's not free! Click me again to open my shop!",
96-
}).build()
97-
).toArray(DialogueSet[]::new);
92+
return new DialogueSet[] {
93+
DialogueSet.ofTranslation("initial-hello", "npcs_hub.baker.dialogue.initial_hello")
94+
};
9895
}
9996
}

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCBanker.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.swofty.type.generic.entity.npc.HypixelNPC;
55
import net.swofty.type.generic.entity.npc.configuration.HumanConfiguration;
66
import net.swofty.type.generic.event.custom.NPCInteractEvent;
7+
import net.swofty.type.generic.i18n.I18n;
78
import net.swofty.type.generic.user.HypixelPlayer;
89
import net.swofty.type.skyblockgeneric.gui.inventories.banker.GUIBanker;
910
import net.swofty.type.skyblockgeneric.mission.MissionData;
@@ -58,13 +59,8 @@ public void onClick(NPCInteractEvent e) {
5859

5960
@Override
6061
public DialogueSet[] dialogues(HypixelPlayer player) {
61-
return Stream.of(
62-
DialogueSet.builder()
63-
.key("quest-hello").lines(new String[]{
64-
"Hello there!",
65-
"You may want to store your §6Coins §fin a safe place while you are off adventuring.",
66-
"Storing them in your §6Bank §fkeeps them safe and allows you to earn interest at the start of every season!"
67-
}).build()
68-
).toArray(DialogueSet[]::new);
62+
return new DialogueSet[] {
63+
DialogueSet.ofTranslation("quest-hello", "npcs_hub.banker.dialogue.quest_hello")
64+
};
6965
}
7066
}

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCBartender.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.swofty.type.generic.entity.npc.HypixelNPC;
55
import net.swofty.type.generic.entity.npc.configuration.HumanConfiguration;
66
import net.swofty.type.generic.event.custom.NPCInteractEvent;
7+
import net.swofty.type.generic.i18n.I18n;
78
import net.swofty.type.generic.user.HypixelPlayer;
89
import net.swofty.type.hub.gui.GUIShopBartender;
910
import net.swofty.type.skyblockgeneric.mission.missions.MissionKillZombies;
@@ -68,24 +69,10 @@ public void onClick(NPCInteractEvent e) {
6869

6970
@Override
7071
public DialogueSet[] dialogues(HypixelPlayer player) {
71-
return Stream.of(
72-
DialogueSet.builder()
73-
.key("quest-hello").lines(new String[]{
74-
"Welcome to the Bar, friend!",
75-
"These are trying times, indeed. The §cGraveyard §fis overflowing with monsters! Anyone who comes in is spooked off by the grunts of zombies in the distance.",
76-
"Could you give me a hand? If you help clear out some of these monsters, I'll pay you for it."
77-
}).build(),
78-
DialogueSet.builder()
79-
.key("quest-talk").lines(new String[]{
80-
"Clear out some more of those Zombies and I'll pay you greatly for it!"
81-
}).build(),
82-
DialogueSet.builder()
83-
.key("quest-complete").lines(new String[]{
84-
"Words cannot describe how thankful I am!",
85-
"That whole area is very dangerous, but can be quite rewarding for a warrior such as yourself.",
86-
"If you're up for the challenge, both the §cGraveyard§f and the §cSpider's Den §fbeyond it are great training grounds for improving your §aCombat Skill§f.",
87-
"For now, here's a reward for helping me out!"
88-
}).build()
89-
).toArray(DialogueSet[]::new);
72+
return new DialogueSet[] {
73+
DialogueSet.ofTranslation("quest-hello", "npcs_hub.bartender.dialogue.quest_hello"),
74+
DialogueSet.ofTranslation("quest-talk", "npcs_hub.bartender.dialogue.quest_talk"),
75+
DialogueSet.ofTranslation("quest-complete", "npcs_hub.bartender.dialogue.quest_complete")
76+
};
9077
}
9178
}

type.hub/src/main/java/net/swofty/type/hub/npcs/NPCFarmerRigby.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.swofty.type.generic.entity.npc.HypixelNPC;
55
import net.swofty.type.generic.entity.npc.configuration.HumanConfiguration;
66
import net.swofty.type.generic.event.custom.NPCInteractEvent;
7+
import net.swofty.type.generic.i18n.I18n;
78
import net.swofty.type.generic.user.HypixelPlayer;
89
import net.swofty.type.skyblockgeneric.mission.MissionData;
910
import net.swofty.type.skyblockgeneric.mission.missions.farmer.MissionCollectWheat;
@@ -70,19 +71,10 @@ public void onClick(NPCInteractEvent e) {
7071

7172
@Override
7273
public DialogueSet[] dialogues(HypixelPlayer player) {
73-
return List.of(
74-
DialogueSet.builder()
75-
.key("initial-hello").lines(new String[]{
76-
"Howdy, friend!",
77-
"My cow is sick, she needs some food to replenish her strength.",
78-
"Could you gather some Wheat from my farm and bring it back to me so that I can feed her? Poor thing."
79-
}).build(),
80-
DialogueSet.builder()
81-
.key("spoke-again").lines(new String[]{
82-
"Thank you so much!",
83-
"My Farm is yours to harvest! Wheat is a valuable resource to collect, you can unlock many cool things by collecting it."
84-
}).build()
85-
).stream().toArray(DialogueSet[]::new);
74+
return new DialogueSet[] {
75+
DialogueSet.ofTranslation("initial-hello", "npcs_hub.farmer_rigby.dialogue.initial_hello"),
76+
DialogueSet.ofTranslation("spoke-again", "npcs_hub.farmer_rigby.dialogue.spoke_again")
77+
};
8678
}
8779

8880
}

0 commit comments

Comments
 (0)