Skip to content

Commit 032575c

Browse files
feat(i18n): migrate election GUIs, NPCs, and holograms to translation system
Add gui_election.properties for GUI strings and election NPC keys to npcs_hub. Migrate ElectionView, ElectionViewStatsView, MayorMenuView, MinisterMenuView, ElectionDisplay holograms, and all election NPCs to use I18n.string() with per-player locale.
1 parent 7de8cda commit 032575c

6 files changed

Lines changed: 226 additions & 94 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# =============================================================================
2+
# Election GUI Translations
3+
# =============================================================================
4+
5+
# --- ElectionView (Voting GUI) ---
6+
gui_election.view.title = Election
7+
gui_election.view.no_election = §cNo Active Election
8+
gui_election.view.no_election.lore = §7There is no active election\n§7at this time.
9+
gui_election.view.candidate.year = §8Year {year} Candidate
10+
gui_election.view.candidate.votes = §7Votes: {color}{votes} §7({color}{percentage}§7)
11+
gui_election.view.candidate.last_elected = §7Last elected: {color}{years}y ago
12+
gui_election.view.candidate.last_elected_never = §7Last elected: {color}Never
13+
gui_election.view.candidate.minister_note_1 = §6✯ {color}Minister Perks §7are also granted if
14+
gui_election.view.candidate.minister_note_2 = §7this mayor wins second place!
15+
gui_election.view.candidate.voted = §aYou voted for this candidate!
16+
gui_election.view.candidate.change_vote_1 = §8You may change your vote at any
17+
gui_election.view.candidate.change_vote_2 = §8time until the election ends!
18+
gui_election.view.candidate.click_vote = §eClick to vote for {name}!
19+
gui_election.view.vote_divider = §c-----------------------------------------------------
20+
gui_election.view.vote_cast = §eYou cast §c1 vote §efor {candidate} §ein the §bYear {year} Elections§e!
21+
gui_election.view.vote_fame = §bNew player §eFame Rank §a+1 vote
22+
gui_election.view.vote_result = {candidate} §enow has §c{percentage} §eof votes with §c{votes} votes§e!
23+
gui_election.view.already_voted = §aYou voted for this candidate.
24+
25+
# --- ElectionViewStatsView ---
26+
gui_election.stats.title = Election, Year {year}
27+
gui_election.stats.leader = {color}Leading in votes!
28+
29+
# --- MayorMenuView ---
30+
gui_election.mayor.title = Mayor {name}
31+
gui_election.mayor.title_fallback = Mayor
32+
gui_election.mayor.perks_label = §8Perks List
33+
gui_election.mayor.perks_footer_1 = §7The listed perks are available to
34+
gui_election.mayor.perks_footer_2 = §7all players until the closing of
35+
gui_election.mayor.perks_footer_3 = §7the next elections.
36+
gui_election.mayor.results_title = §bMayor Election Results
37+
gui_election.mayor.results_no_data_1 = §7No previous election data
38+
gui_election.mayor.results_no_data_2 = §7available.
39+
gui_election.mayor.results_year = §8Year {year}
40+
gui_election.mayor.results_footer_1 = §7These are the votes for the
41+
gui_election.mayor.results_footer_2 = §7last election in which {name}
42+
gui_election.mayor.results_footer_3 = §7was elected.
43+
44+
# --- MinisterMenuView ---
45+
gui_election.minister.title = Minister {name}
46+
gui_election.minister.title_fallback = Minister
47+
gui_election.minister.perk_label = §8Active Perk
48+
gui_election.minister.perk_footer_1 = §7The Minister is who came in 2nd Place
49+
gui_election.minister.perk_footer_2 = §7during the election. They have one
50+
gui_election.minister.perk_footer_3 = §7of their perks active.
51+
52+
# --- ElectionDisplay (Holograms) ---
53+
gui_election.display.title = §e§lMAYOR ELECTIONS
54+
gui_election.display.year = §bYear {year}
55+
gui_election.display.time_left = §eTime left: §a{time}
56+
gui_election.display.your_vote = §eYour vote: §f{candidate}
57+
gui_election.display.click_switch = §e§lCLICK TO SWITCH

configuration/i18n/en_US/npcs/npcs_hub.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ npcs_hub.elizabeth.dialogue.hello = <white>Hello! Welcome to <aqua>SkyBlock<whit
7878
# --- Clerk Seraphine ---
7979
npcs_hub.clerk_seraphine.dialogue.hello = Welcome to the <aqua>Community Center<white>!|Contribute to community projects, upgrade your account, and more by talking to <light_purple>Elizabeth<white>!|You can also vote in the <aqua>mayor elections <white>by heading through the warp behind me!
8080

81+
# --- Election NPCs ---
82+
npcs_hub.election.clerk_seraphine = Clerk Seraphine
83+
npcs_hub.election.candidate_label = Candidate
84+
npcs_hub.election.click = §e§lCLICK
85+
npcs_hub.election.running = Running for mayor!
86+
npcs_hub.election.mayor_unknown = Mayor ???
87+
npcs_hub.election.minister_unknown = Minister ????
88+
npcs_hub.election.hello = §cHello!!
89+
8190
# --- Gladiator ---
8291
npcs_hub.gladiator.dialogue.hello = Welcome to the <aqua>Colosseum<white>!|Oh...wait. Nevermind.|Here you can join me in drinking away your sorrows.
8392

type.skyblockgeneric/src/main/java/net/swofty/type/skyblockgeneric/gui/inventories/election/ElectionView.java

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@
1111
import net.swofty.type.generic.gui.v2.ViewConfiguration;
1212
import net.swofty.type.generic.gui.v2.ViewLayout;
1313
import net.swofty.type.generic.gui.v2.context.ViewContext;
14+
import net.swofty.type.generic.i18n.I18n;
1415
import net.swofty.type.skyblockgeneric.calendar.SkyBlockCalendar;
1516
import net.swofty.type.skyblockgeneric.elections.ElectionData;
1617
import net.swofty.type.skyblockgeneric.elections.ElectionManager;
1718
import net.swofty.type.skyblockgeneric.elections.SkyBlockMayor;
1819

1920
import java.util.ArrayList;
2021
import java.util.List;
22+
import java.util.Locale;
2123
import java.util.Map;
2224

2325
public class ElectionView extends StatelessView {
2426

2527
@Override
2628
public ViewConfiguration<DefaultState> configuration() {
27-
return new ViewConfiguration<>("Election", InventoryType.CHEST_3_ROW);
29+
return ViewConfiguration.translatable("gui_election.view.title", InventoryType.CHEST_3_ROW);
2830
}
2931

3032
@Override
@@ -35,13 +37,15 @@ public void layout(ViewLayout<DefaultState> layout, DefaultState state, ViewCont
3537
ElectionData data = ElectionManager.getElectionData();
3638

3739
if (!data.isElectionOpen() || data.getCandidates().isEmpty()) {
38-
layout.slot(13, (s, c) -> ItemStackCreator.getStack(
39-
"§cNo Active Election",
40-
Material.BARRIER,
41-
1,
42-
"§7There is no active election",
43-
"§7at this time."
44-
));
40+
layout.slot(13, (s, c) -> {
41+
Locale l = c.player().getLocale();
42+
return ItemStackCreator.getStack(
43+
I18n.string("gui_election.view.no_election", l),
44+
Material.BARRIER,
45+
1,
46+
I18n.lore("gui_election.view.no_election.lore", l)
47+
);
48+
});
4549
return;
4650
}
4751

@@ -66,11 +70,12 @@ public void layout(ViewLayout<DefaultState> layout, DefaultState state, ViewCont
6670
String candidateName = candidate.getMayorName();
6771

6872
layout.slot(slot, (s, c) -> {
73+
Locale l = c.player().getLocale();
6974
String playerVote = ElectionManager.getPlayerVote(c.player().getUuid());
7075
boolean isVotedFor = candidateName.equals(playerVote);
7176

7277
List<String> lore = buildCandidateLore(
73-
mayor, candidate, data.getElectionYear(),
78+
l, mayor, candidate, data.getElectionYear(),
7479
yearsSince, voteStr, pctStr, isVotedFor
7580
);
7681
return ItemStackCreator.getStackHead(
@@ -80,28 +85,37 @@ public void layout(ViewLayout<DefaultState> layout, DefaultState state, ViewCont
8085
lore
8186
);
8287
}, (_, c) -> {
88+
Locale l = c.player().getLocale();
8389
ElectionManager.castVote(c.player().getUuid(), candidateName);
84-
c.player().sendMessage("§c-----------------------------------------------------");
85-
c.player().sendMessage("§eYou cast §c1 vote §efor " + candidate.getColoredName() + " §ein the §bYear " + data.getElectionYear() + " Elections§e!");
86-
c.player().sendMessage(" §bNew player §eFame Rank §a+1 vote");
87-
c.player().sendMessage(candidate.getColoredName() + " §enow has §c" + pctStr + " §eof votes with §c" + voteStr + " votes§e!");
88-
c.player().sendMessage("§c-----------------------------------------------------");
90+
c.player().sendMessage(I18n.string("gui_election.view.vote_divider", l));
91+
c.player().sendMessage(I18n.string("gui_election.view.vote_cast", l, Map.of(
92+
"candidate", candidate.getColoredName(),
93+
"year", String.valueOf(data.getElectionYear()))));
94+
c.player().sendMessage(" " + I18n.string("gui_election.view.vote_fame", l));
95+
c.player().sendMessage(I18n.string("gui_election.view.vote_result", l, Map.of(
96+
"candidate", candidate.getColoredName(),
97+
"percentage", pctStr,
98+
"votes", voteStr)));
99+
c.player().sendMessage(I18n.string("gui_election.view.vote_divider", l));
89100
c.replace(new ElectionViewStatsView());
90101
});
91102
}
92103
}
93104

94-
private List<String> buildCandidateLore(SkyBlockMayor mayor, ElectionData.CandidateData candidate,
105+
private List<String> buildCandidateLore(Locale l, SkyBlockMayor mayor, ElectionData.CandidateData candidate,
95106
int electionYear, int yearsSince,
96107
String voteStr, String pctStr, boolean votedFor) {
108+
String color = candidate.getColor();
97109
List<String> lore = new ArrayList<>();
98-
lore.add("§8Year " + electionYear + " Candidate");
110+
lore.add(I18n.string("gui_election.view.candidate.year", l, Map.of("year", String.valueOf(electionYear))));
99111
lore.add("");
100-
lore.add("§7Votes: " + candidate.getColor() + voteStr + " §7(" + candidate.getColor() + pctStr + "§7)");
112+
lore.add(I18n.string("gui_election.view.candidate.votes", l, Map.of(
113+
"color", color, "votes", voteStr, "percentage", pctStr)));
101114
if (yearsSince >= 0) {
102-
lore.add("§7Last elected: " + candidate.getColor() + yearsSince + "y ago");
115+
lore.add(I18n.string("gui_election.view.candidate.last_elected", l, Map.of(
116+
"color", color, "years", String.valueOf(yearsSince))));
103117
} else {
104-
lore.add("§7Last elected: " + candidate.getColor() + "Never");
118+
lore.add(I18n.string("gui_election.view.candidate.last_elected_never", l, Map.of("color", color)));
105119
}
106120
lore.add("");
107121
lore.add("§8§m--------------------------");
@@ -110,10 +124,10 @@ private List<String> buildCandidateLore(SkyBlockMayor mayor, ElectionData.Candid
110124
for (int j = 0; j < activePerks.size(); j++) {
111125
SkyBlockMayor.Perk perk = activePerks.get(j);
112126
if (j == 0) {
113-
lore.add("§6✯ " + candidate.getColor() + perk.getDisplayName());
127+
lore.add("§6✯ " + color + perk.getDisplayName());
114128
} else {
115129
lore.addAll(StringUtility.splitByWordAndLengthKeepLegacyColor(
116-
candidate.getColor() + perk.getDisplayName(), 35));
130+
color + perk.getDisplayName(), 35));
117131
}
118132
lore.addAll(StringUtility.splitByWordAndLengthKeepLegacyColor(
119133
perk.getDescription(), 35));
@@ -124,18 +138,18 @@ private List<String> buildCandidateLore(SkyBlockMayor mayor, ElectionData.Candid
124138

125139
if (!mayor.isSpecial()) {
126140
lore.add("");
127-
lore.add("§6✯ " + candidate.getColor() + "Minister Perks §7are also granted if");
128-
lore.add("§7this mayor wins second place!");
141+
lore.add(I18n.string("gui_election.view.candidate.minister_note_1", l, Map.of("color", color)));
142+
lore.add(I18n.string("gui_election.view.candidate.minister_note_2", l));
129143
}
130144

131145
lore.add("");
132146
if (votedFor) {
133-
lore.add("§aYou voted for this candidate!");
147+
lore.add(I18n.string("gui_election.view.candidate.voted", l));
134148
} else {
135-
lore.add("§8You may change your vote at any");
136-
lore.add("§8time until the election ends!");
149+
lore.add(I18n.string("gui_election.view.candidate.change_vote_1", l));
150+
lore.add(I18n.string("gui_election.view.candidate.change_vote_2", l));
137151
lore.add("");
138-
lore.add("§eClick to vote for " + mayor.getDisplayName() + "!");
152+
lore.add(I18n.string("gui_election.view.candidate.click_vote", l, Map.of("name", mayor.getDisplayName())));
139153
}
140154

141155
return lore;

0 commit comments

Comments
 (0)