From 868f290018099e52c2c6905c9b4b4bf92c3fb02c Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:25:32 +0200 Subject: [PATCH] Add upkeep to town info item --- .../github/townyadvanced/townymenus/menu/TownMenu.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java b/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java index 89d2ffd..2c7911c 100644 --- a/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java +++ b/src/main/java/io/github/townyadvanced/townymenus/menu/TownMenu.java @@ -711,8 +711,14 @@ public static MenuItem.Builder formatTownInfo(Player player,Town town) { lore.add(of("town-menu-town-info-founded").append(Time.ago(town.getRegistered()).translate()).component(locale).color(GREEN)); lore.add(text(town.getNumResidents(), DARK_GREEN).append(of("town-menu-town-info-resident").append(town.getNumResidents() == 1 ? "" : "s").component(locale).color(GREEN))); - if (TownySettings.isEconomyAsync() && TownyEconomyHandler.isActive()) - lore.add(of("town-menu-town-info-balance").component(locale).append(text(TownyEconomyHandler.getFormattedBalance(town.getAccount().getCachedBalance()), GREEN))); + if (TownyEconomyHandler.isActive()) { + // Only add bank balance when it's safe to do so + if (TownySettings.isEconomyAsync()) + lore.add(of("town-menu-town-info-balance").component(locale).append(text(TownyEconomyHandler.getFormattedBalance(town.getAccount().getCachedBalance()), GREEN))); + + if (town.hasUpkeep()) + lore.add(of("status_bank_town2").component(locale).color(DARK_GREEN).appendSpace().append(text(TownyEconomyHandler.getFormattedBalance(TownySettings.getTownUpkeepCost(town)), GREEN))); + } if (town.getMayor() != null) lore.add(of("town-menu-town-info-owned-by").component(locale).append(text(town.getMayor().getName(), GREEN)));