1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

cleaner way to show incoming payments

This commit is contained in:
Zrips 2017-05-13 16:18:39 +03:00
parent a7aead4639
commit 278c001389
2 changed files with 21 additions and 5 deletions

View File

@ -121,9 +121,9 @@ public class GeneralConfigManager {
public int AutoJobJoinDelay;
public boolean AutoJobJoinUse;
public boolean AllowDelevel;
//BossBar
public boolean BossBarEnabled;
public boolean BossBarShowOnEachAction;

View File

@ -110,15 +110,31 @@ public class ActionBar {
if (abp != null && show) {
String Message = Jobs.getLanguage().getMessage("command.toggle.output.paid.main");
if (payment.getAmount() != 0D)
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", String.format("%.2f", payment.getAmount()));
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.money", "[amount]", convertAmount(payment.getAmount()));
if (payment.getPoints() != 0D)
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", String.format("%.2f", payment.getPoints()));
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.points", "[points]", convertAmount(payment.getPoints()));
if (payment.getExp() != 0D)
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", String.format("%.2f", payment.getExp()));
Message = Message + " " + Jobs.getLanguage().getMessage("command.toggle.output.paid.exp", "[exp]", convertAmount(payment.getExp()));
send(abp, ChatColor.GREEN + Message);
}
}
private String convertAmount(double amount) {
String format = "%.2f";
if (amount % 1 == 0 || amount > 100 || amount < -100) {
amount = (int) Math.round(amount);
format = "%.0f";
} else {
if ((amount * 10) % 1 == 0) {
format = "%.1f";
}
}
return String.format(format, amount);
}
public void send(CommandSender receivingPacket, String msg) {
try {
if (msg == null || nmsChatSerializer == null || msg.isEmpty())