Skip to content

Commit 6e5a985

Browse files
authored
Merge pull request #25 from ApliNi/01
Use client's translated name and Allow custom PLAYER_REPUTATION as bar or number
2 parents 80945a9 + e9a363e commit 6e5a985

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/main/java/adhdmc/villagerinfo/Config/VIMessage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ public enum VIMessage {
1919
PURPUR_LOBOTOMIZED("<#05bff7><hover:show_text:'<aqua>Lobotomized: <grey><state>'>[<#c4fff7>Lobotomized</#c4fff7>]"),
2020
ZOMBIE_VILLAGER_CONVERSION_TIME("<#05bff7><hover:show_text:'<aqua>Conversion Time: <grey><time>'>[<#c4fff7>Time Until Converted</#c4fff7>]</hover>"),
2121
VILLAGER_AGE("<#05bff7><hover:show_text:'<aqua>Childhood Left: <grey><age>'>[<#c4fff7>Time Until Adult</#c4fff7>]"),
22-
VILLAGER_PROFESSION("<#05bff7><hover:show_text:'<aqua>Profession: <grey><profession>'>[<#c4fff7>Profession</#c4fff7>]"),
22+
VILLAGER_PROFESSION("<#05bff7><hover:show_text:'<aqua>Profession: <grey><lang:entity.minecraft.villager.<profession>>'>[<#c4fff7>Profession</#c4fff7>]"),
23+
VILLAGER_PROFESSION_NONE("<#05bff7><hover:show_text:'<aqua>Profession: <grey>None'>[<#c4fff7>Profession</#c4fff7>]"),
2324
VILLAGER_HEALTH("<#05bff7><hover:show_text:'<aqua>Health: <grey><current><aqua>/</aqua><total>'>[<#c4fff7>Health</#c4fff7>]"),
2425
VILLAGER_JOBSITE("<#05bff7><hover:show_text:'<aqua>POI: <grey><jobsitelocation>'>[<#c4fff7>Job Site</#c4fff7>]"),
2526
VILLAGER_LAST_WORKED("<#05bff7><hover:show_text:'<aqua>Last Worked: <grey><worktime>'>[<#c4fff7>Last Worked At Workstation</#c4fff7>]"),
2627
VILLAGER_RESTOCKS("<#05bff7><hover:show_text:'<aqua>Restocks: <grey><restockcount>'>[<#c4fff7>Restocks Today</#c4fff7>]"),
2728
VILLAGER_HOME("<#05bff7><hover:show_text:'<aqua>Bed: <grey><homelocation>'>[<#c4fff7>Home</#c4fff7>]"),
2829
VILLAGER_SLEPT("<#05bff7><hover:show_text:'<aqua>Last Slept: <grey><sleeptime>'>[<#c4fff7>Last Slept</#c4fff7>]"),
2930
VILLAGER_INVENTORY("<#05bff7><hover:show_text:'<aqua>Inventory: <grey><contents>'>[<#c4fff7>Villager Inventory</#c4fff7>]"),
30-
INVENTORY_CONTENTS("\n • <item> (<amount>)"),
31+
INVENTORY_CONTENTS("\n • <lang:item.minecraft.<item>> (<amount>)"),
3132
PLAYER_REPUTATION("<#05bff7><hover:show_text:'<#05bff7>[<#c4fff7>Player Reputation</#c4fff7>]'><reputation>"),
3233

3334
// Fillers

src/main/java/adhdmc/villagerinfo/VillagerHandling/ComponentHandler.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public static Component villagerLobotomized(Villager villager) {
7676
public static Component villagerProfession(Villager.Profession profession) {
7777
Component professionFinal;
7878
if (profession == Villager.Profession.NONE) {
79-
professionFinal = miniMessage.deserialize(VIMessage.VILLAGER_PROFESSION.getMessage(), Placeholder.parsed("profession", VIMessage.NONE.getMessage()));
79+
professionFinal = miniMessage.deserialize(VIMessage.VILLAGER_PROFESSION_NONE.getMessage());
8080
} else {
81-
professionFinal = miniMessage.deserialize(VIMessage.VILLAGER_PROFESSION.getMessage(), Placeholder.parsed("profession", profession.toString()));
81+
professionFinal = miniMessage.deserialize(VIMessage.VILLAGER_PROFESSION.getMessage(), Placeholder.parsed("profession", profession.toString().toLowerCase()));
8282
}
8383
return professionFinal;
8484
}
@@ -186,7 +186,7 @@ public static Component villagerInventory(Villager villager) {
186186
ItemStack[] inventoryItems = villager.getInventory().getContents();
187187
for (ItemStack items : inventoryItems) {
188188
if (items == null) continue;
189-
villagerInventory = villagerInventory.append(miniMessage.deserialize(inventoryOutput, Placeholder.parsed("item", items.getType().toString()), Placeholder.parsed("amount", String.valueOf(items.getAmount()))));
189+
villagerInventory = villagerInventory.append(miniMessage.deserialize(inventoryOutput, Placeholder.parsed("item", items.getType().toString().toLowerCase()), Placeholder.parsed("amount", String.valueOf(items.getAmount()))));
190190
}
191191
villagerInventoryFinal = miniMessage.deserialize(VIMessage.VILLAGER_INVENTORY.getMessage(), Placeholder.component("contents", villagerInventory));
192192
}
@@ -214,8 +214,10 @@ public static Component villagerRestocks(Villager villager) {
214214
public static Component villagerPlayerReputation(Reputation reputation) {
215215
Component villagerReputationFinal;
216216
int reputationRawTotal = reputationTotal(reputation);
217-
String playerReputation = ReputationHandler.villagerReputation(reputationRawTotal);
218-
villagerReputationFinal = miniMessage.deserialize(VIMessage.PLAYER_REPUTATION.getMessage(), Placeholder.unparsed("reputation", playerReputation));
217+
villagerReputationFinal = miniMessage.deserialize(
218+
VIMessage.PLAYER_REPUTATION.getMessage(),
219+
Placeholder.unparsed("reputation", ReputationHandler.villagerReputation(reputationRawTotal)),
220+
Placeholder.unparsed("reputation_number", String.valueOf(reputationRawTotal)));
219221
return villagerReputationFinal;
220222

221223
}

src/main/resources/locale.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
"PURPUR_LOBOTOMIZED": "<#05bff7><hover:show_text:'<aqua>Lobotomized: <grey><state>'>[<#c4fff7>Lobotomized</#c4fff7>]"
1212
"ZOMBIE_VILLAGER_CONVERSION_TIME": "<#05bff7><hover:show_text:'<aqua>Conversion Time: <grey><time>'>[<#c4fff7>Time Until Converted</#c4fff7>]</hover>"
1313
"VILLAGER_AGE": "<#05bff7><hover:show_text:'<aqua>Childhood Left: <grey><age>'>[<#c4fff7>Time Until Adult</#c4fff7>]"
14-
"VILLAGER_PROFESSION": "<#05bff7><hover:show_text:'<aqua>Profession: <grey><profession>'>[<#c4fff7>Profession</#c4fff7>]"
14+
"VILLAGER_PROFESSION": "<#05bff7><hover:show_text:'<aqua>Profession: <grey><lang:entity.minecraft.villager.<profession>>'>[<#c4fff7>Profession</#c4fff7>]"
15+
"VILLAGER_PROFESSION_NONE": "<#05bff7><hover:show_text:'<aqua>Profession: <grey>None'>[<#c4fff7>Profession</#c4fff7>]"
1516
"VILLAGER_HEALTH": "<#05bff7><hover:show_text:'<aqua>Health: <grey><current><aqua>/</aqua><total>'>[<#c4fff7>Health</#c4fff7>]"
1617
"VILLAGER_JOBSITE": "<#05bff7><hover:show_text:'<aqua>POI: <grey><jobsitelocation>'>[<#c4fff7>Job Site</#c4fff7>]"
1718
"VILLAGER_LAST_WORKED": "<#05bff7><hover:show_text:'<aqua>Last Worked: <grey><worktime>'>[<#c4fff7>Last Worked At Workstation</#c4fff7>]"
1819
"VILLAGER_RESTOCKS": "<#05bff7><hover:show_text:'<aqua>Restocks: <grey><restockcount>'>[<#c4fff7>Restocks Today</#c4fff7>]"
1920
"VILLAGER_HOME": "<#05bff7><hover:show_text:'<aqua>Bed: <grey><homelocation>'>[<#c4fff7>Home</#c4fff7>]"
2021
"VILLAGER_SLEPT": "<#05bff7><hover:show_text:'<aqua>Last Slept: <grey><sleeptime>'>[<#c4fff7>Last Slept</#c4fff7>]"
2122
"VILLAGER_INVENTORY": "<#05bff7><hover:show_text:'<aqua>Inventory: <grey><contents>'>[<#c4fff7>Villager Inventory</#c4fff7>]"
22-
"INVENTORY_CONTENTS": "\n • <item> (<amount>)"
23-
"PLAYER_REPUTATION": "<#05bff7><hover:show_text:'<#05bff7>[<#c4fff7>Player Reputation</#c4fff7>]'><reputation>"
23+
"INVENTORY_CONTENTS": "\n • <lang:item.minecraft.<item>> (<amount>)"
24+
"PLAYER_REPUTATION": "<#05bff7><hover:show_text:'<#05bff7>[<#c4fff7>Player Reputation</#c4fff7>]'><reputation>" # <reputation> or <reputation_number>
2425
"TRUE": "<grey>True"
2526
"FALSE": "<grey>False"
2627
"NONE": "<grey>None"

0 commit comments

Comments
 (0)