From 4d941951460eb7c43784fa6509d49169421b602c Mon Sep 17 00:00:00 2001 From: Zrips Date: Sat, 28 Sep 2024 17:19:13 +0300 Subject: [PATCH] Returning back basic chat payment messages --- .../jobs/config/LanguageManager.java | 13 ++++-- .../jobs/economy/BufferedEconomy.java | 4 +- .../JobsPaymentVisualizationListener.java | 41 +++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 3016c1fe..e0559ff7 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -294,7 +294,7 @@ public class LanguageManager { c.get("command.recalculatepermissions.help.info", "Reset players permission cache"); c.get("command.recalculatepermissions.help.args", "(playername)"); - + c.get("command.stats.help.info", "Show the level you are in each job you are part of."); c.get("command.stats.help.args", "[playername]"); Jobs.getGCManager().getCommandArgs().put("stats", Arrays.asList("[playername]")); @@ -561,7 +561,7 @@ public class LanguageManager { c.get("command.area.output.removed", "&eRemoved the restricted area &6%name%"); c.get("command.area.output.lists", "&7%number%&f. &7%areaname% &f%worldname% &7(&a%x1%:%y1%:%z1%&7/&e%x2%:%y2%:%z2%&7) &2%money% &6%points% &e%exp%"); c.get("command.area.output.wgLists", "&7%number%&f. WorldGuard: &7%areaname% &2%money% &6%points% &e%exp%"); - c.get("command.area.output.noAreas", "&eThere are no saved restricted areas"); + c.get("command.area.output.noAreas", "&eThere are no saved restricted areas"); c.get("command.area.output.noAreasByLoc", "&eThere are no restricted areas in this location"); c.get("command.area.output.areaList", "&eRestricted areas by your location: &6%list%"); c.get("command.area.output.selected1", "&eSelected the first point: &6%x%:%y%:%z%"); @@ -648,11 +648,16 @@ public class LanguageManager { c.get("command.toggle.help.args", "actionbar/bossbar"); Jobs.getGCManager().getCommandArgs().put("toggle", Arrays.asList("actionbar%%bossbar")); c.get("command.toggle.output.turnedoff", "&4This feature is turned off!"); - + + c.get("command.toggle.output.paid.main", "&aYou got:"); + c.get("command.toggle.output.paid.money", "&e[amount] money"); + c.get("command.toggle.output.paid.exp", "&7[exp] exp"); + c.get("command.toggle.output.paid.points", "&6[points] points"); + c.get("command.toggle.output.paid.ACmoney", "&e+[amount]$ "); c.get("command.toggle.output.paid.ACexp", "&7+[exp]XP "); c.get("command.toggle.output.paid.ACpoints", "&6+[points]pts "); - + c.get("command.toggle.output.on", "&aToggled: &aON"); c.get("command.toggle.output.off", "&aToggled: &4OFF"); diff --git a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java index c376c163..bf152f74 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -37,6 +37,7 @@ import com.gamingmesh.jobs.stuff.ToggleBarHandling; import com.gamingmesh.jobs.tasks.BufferedPaymentTask; import net.Zrips.CMILib.ActionBar.CMIActionBar; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Schedulers.CMIScheduler; @@ -207,9 +208,6 @@ public class BufferedEconomy { if (jobsPaymentEvent.isCancelled()) continue; - // Do we need this? - payment.getPayment().putAll(jobsPaymentEvent.getPayment()); - if (Jobs.getGCManager().UseServerAccount && !hasMoney) { CMIActionBar.send(payment.getOfflinePlayer().getPlayer(), Jobs.getLanguage().getMessage("economy.error.nomoney")); continue; diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentVisualizationListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentVisualizationListener.java index bc508c66..9198661c 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentVisualizationListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentVisualizationListener.java @@ -31,10 +31,13 @@ import org.bukkit.event.player.PlayerQuitEvent; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.api.JobsInstancePaymentEvent; +import com.gamingmesh.jobs.api.JobsPaymentEvent; import com.gamingmesh.jobs.container.CurrencyType; +import com.gamingmesh.jobs.economy.BufferedPayment; import com.gamingmesh.jobs.stuff.ToggleBarHandling; import net.Zrips.CMILib.ActionBar.CMIActionBar; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Version.Version; public class JobsPaymentVisualizationListener implements Listener { @@ -90,6 +93,44 @@ public class JobsPaymentVisualizationListener implements Listener { paymentCaches.remove(event.getPlayer().getUniqueId()); } + @EventHandler(priority = EventPriority.MONITOR) + public void onJobsPaymentEvent(JobsPaymentEvent event) { + if (event.isCancelled()) + return; + showPayment(event); + } + + private static void showPayment(JobsPaymentEvent event) { + + if (event.getPlayer() == null || !event.getPlayer().isOnline() || event.getPayment().isEmpty()) + return; + + UUID playerUUID = event.getPlayer().getUniqueId(); + Player abp = Bukkit.getPlayer(playerUUID); + if (abp == null) + return; + + if (ToggleBarHandling.getActionBarToggle().getOrDefault(playerUUID, Jobs.getGCManager().ActionBarsMessageByDefault)) + return; + + String message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main"); + double money = event.getPayment().get(CurrencyType.MONEY); + if (money != 0D) + message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(), money)); + + double points = event.getPayment().get(CurrencyType.POINTS); + if (points != 0D) + message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points)); + + double exp = event.getPayment().get(CurrencyType.EXP); + if (exp != 0D) + message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(), exp)); + + if (!message.isEmpty()) + abp.sendMessage(message); + + } + @EventHandler(priority = EventPriority.MONITOR) public void onJobsInstancePaymentBossEvent(JobsInstancePaymentEvent event) {