mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 12:35:28 +01:00
Make payment messages display in chat if setting is disabled per config
Closes #1031 Closes #1023
This commit is contained in:
parent
89649acb9e
commit
a8dd65cb4b
@ -21,11 +21,6 @@ public class VersionChecker {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Version getVersion() {
|
||||
return Version.getCurrent();
|
||||
}
|
||||
|
||||
public Integer convertVersion(String v) {
|
||||
v = v.replaceAll("[^\\d.]", "");
|
||||
Integer version = 0;
|
||||
|
@ -829,7 +829,8 @@ public class GeneralConfigManager {
|
||||
"Only works when fix-at-max-level is set to false");
|
||||
levelLossPercentageFromMax = c.get("old-job.level-loss-from-max-level", levelLossPercentage);
|
||||
|
||||
c.addComment("ActionBars.Messages.EnabledByDefault", "When this set to true player will see action bar messages by default");
|
||||
c.addComment("ActionBars.Messages.EnabledByDefault", "When this set to true player will see action bar messages by default",
|
||||
"When false, players will see chat messages instead.");
|
||||
ActionBarsMessageByDefault = c.get("ActionBars.Messages.EnabledByDefault", true);
|
||||
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) {
|
||||
|
@ -220,8 +220,8 @@ public class BufferedEconomy {
|
||||
else
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i);
|
||||
|
||||
// Action bar stuff
|
||||
showActionBar(payment);
|
||||
// Show players payment stuff
|
||||
showPayment(payment);
|
||||
|
||||
if (payment.getOfflinePlayer().isOnline() && Version.getCurrent().isHigher(Version.v1_8_R3)) {
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(payment.getOfflinePlayer().getUniqueId());
|
||||
@ -234,29 +234,53 @@ public class BufferedEconomy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #showPayment(BufferedPayment payment)}
|
||||
* @param payment
|
||||
*/
|
||||
@Deprecated
|
||||
public void showActionBar(BufferedPayment payment) {
|
||||
if (payment.getOfflinePlayer() == null || !payment.getOfflinePlayer().isOnline()
|
||||
|| !Jobs.getGCManager().ActionBarsMessageByDefault || !payment.containsPayment())
|
||||
showPayment(payment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the payment in actionbar or chat for the given player if online.
|
||||
*
|
||||
* @param payment {@link BufferedPayment}
|
||||
*/
|
||||
public void showPayment(BufferedPayment payment) {
|
||||
if (payment.getOfflinePlayer() == null || !payment.getOfflinePlayer().isOnline() || !payment.containsPayment())
|
||||
return;
|
||||
|
||||
UUID playerUUID = payment.getOfflinePlayer().getUniqueId();
|
||||
Boolean show = ToggleBarHandling.getActionBarToggle().getOrDefault(playerUUID.toString(), true);
|
||||
Player abp = Bukkit.getPlayer(playerUUID);
|
||||
if (abp != null && show.booleanValue()) {
|
||||
String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main");
|
||||
if (abp == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main");
|
||||
if (payment.get(CurrencyType.MONEY) != 0D) {
|
||||
Message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(),
|
||||
message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format(Jobs.getGCManager().getDecimalPlacesMoney(),
|
||||
payment.get(CurrencyType.MONEY)));
|
||||
}
|
||||
|
||||
if (payment.get(CurrencyType.POINTS) != 0D) {
|
||||
Message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(),
|
||||
message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format(Jobs.getGCManager().getDecimalPlacesPoints(),
|
||||
payment.get(CurrencyType.POINTS)));
|
||||
}
|
||||
|
||||
if (payment.get(CurrencyType.EXP) != 0D) {
|
||||
Message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(),
|
||||
message += " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format(Jobs.getGCManager().getDecimalPlacesExp(),
|
||||
payment.get(CurrencyType.EXP)));
|
||||
}
|
||||
ActionBarManager.send(abp, Message);
|
||||
|
||||
// Whether or not to show this on player actionbar or on chat
|
||||
boolean showInActionbar = ToggleBarHandling.getActionBarToggle().getOrDefault(playerUUID.toString(),
|
||||
Jobs.getGCManager().ActionBarsMessageByDefault);
|
||||
if (showInActionbar) {
|
||||
ActionBarManager.send(abp, message);
|
||||
} else {
|
||||
abp.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user