Makes GUI titles configurable in the locale files

Idea from Discord
This commit is contained in:
tastybento 2024-10-05 10:17:43 -07:00
parent 9f4c9315d6
commit 37e4c10964
3 changed files with 22 additions and 8 deletions

View File

@ -119,7 +119,8 @@ public class LimitTab implements Tab {
});
groupMap.forEach((v, limit) -> {
PanelItemBuilder pib = new PanelItemBuilder();
pib.name(v.getName());
pib.name(user.getTranslation("island.limits.panel.entity-group-name-syntax", TextVariables.NAME,
v.getName()));
String description = "";
description += "(" + prettyNames(v) + ")\n";
pib.icon(v.getIcon());
@ -145,7 +146,8 @@ public class LimitTab implements Tab {
map.forEach((k,v) -> {
PanelItemBuilder pib = new PanelItemBuilder();
pib.name(Util.prettifyText(k.toString()));
pib.name(user.getTranslation("island.limits.panel.entity-name-syntax", TextVariables.NAME,
Util.prettifyText(k.toString())));
Material m;
try {
if (E2M.containsKey(k)) {
@ -175,7 +177,8 @@ public class LimitTab implements Tab {
// Material limits
for (Entry<Material, Integer> en : matLimits.entrySet()) {
PanelItemBuilder pib = new PanelItemBuilder();
pib.name(Util.prettifyText(en.getKey().toString()));
pib.name(user.getTranslation("island.limits.panel.block-name-syntax", TextVariables.NAME,
Util.prettifyText(en.getKey().toString())));
// Adjust icon
pib.icon(B2M.getOrDefault(en.getKey(), en.getKey()));
@ -197,7 +200,9 @@ public class LimitTab implements Tab {
@Override
public String getName() {
return user.getTranslation(world, "limits.panel-title") + " " + sortBy.name();
String sort = user.getTranslation(world, "island.limits.panel." + sortBy);
return user.getTranslation(world, "island.limits.panel.title-syntax", "[title]",
user.getTranslation(world, "limits.panel-title"), "[sort]", sort);
}
@Override

View File

@ -51,7 +51,7 @@ public class PlayerCommand extends CompositeCommand {
// Report the limit for the island, which is governed by the owner of the island
Optional<Island> opIsland = getIslands().getIslandAt(user.getLocation());
if (opIsland.isEmpty()) {
user.sendMessage("general.errors.no-island");
user.sendMessage("island.limits.errors.not-on-island");
return false;
}
Island island = opIsland.get();
@ -60,7 +60,7 @@ public class PlayerCommand extends CompositeCommand {
return false;
}
if (island.getOwner() == null) {
user.sendMessage("general.errors.no-owner");
user.sendMessage("island.limits.errors.no-owner");
return false;
}
new LimitPanel(addon).showLimits((GameModeAddon) getAddon(), user, island.getOwner());

View File

@ -10,7 +10,6 @@ entity-limits:
limits:
panel-title: "Island limits"
admin:
limits:
main:
@ -53,6 +52,16 @@ island:
regular-color: "&a"
block-limit-syntax: "[number]/[limit]"
no-limits: "&c No limits set in this world"
panel:
title-syntax: '[title] [sort]'
entity-group-name-syntax: '[name]'
entity-name-syntax: '[name]'
block-name-syntax: '[name]'
A2Z: "a > z"
Z2A: "z > a"
errors:
no-owner: "&c That island has no owner"
not-on-island: "&c This location does not have limits set."
recount:
description: "recounts limits for your island"
now-recounting: "&b Now recounting. This could take a while, please wait..."