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

Correct way to calculate finall income when it negative

This commit is contained in:
Zrips 2017-02-15 11:18:04 +02:00
parent 31ce825224
commit b98c0b87d6
7 changed files with 16 additions and 13 deletions

View File

@ -26,7 +26,7 @@ import org.bukkit.plugin.RegisteredServiceProvider;
import com.gamingmesh.jobs.economy.BlackholeEconomy;
import com.gamingmesh.jobs.economy.VaultEconomy;
import com.gamingmesh.jobs.economy.IConomyAdapter;
import com.gamingmesh.jobs.economy.IConomy6Adapter;
public class HookEconomyTask implements Runnable {
private Jobs plugin;
@ -79,7 +79,7 @@ public class HookEconomyTask implements Runnable {
return false;
try {
Jobs.setEconomy(this.plugin, new IConomyAdapter((com.iCo6.iConomy) p));
Jobs.setEconomy(this.plugin, new IConomy6Adapter((com.iCo6.iConomy) p));
} catch (Exception e) {
Jobs.consoleMsg("&e[" + this.plugin.getDescription().getName() + "] UNKNOWN iConomy version.");
return false;

View File

@ -924,7 +924,7 @@ public class Jobs extends JavaPlugin {
// Calculate income
if (income != 0D) {
income = income + ((income > 0D ? income : -income) * boost.getFinal(CurrencyType.MONEY));
income = boost.getFinalAmount(CurrencyType.MONEY, income);
if (GconfigManager.useMinimumOveralPayment && income > 0) {
double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit;
if (income < maxLimit) {
@ -935,7 +935,7 @@ public class Jobs extends JavaPlugin {
// Calculate points
if (pointAmount != 0D) {
pointAmount = pointAmount + ((pointAmount > 0D ? pointAmount : -pointAmount) * boost.getFinal(CurrencyType.POINTS));
pointAmount = boost.getFinalAmount(CurrencyType.POINTS, pointAmount);
if (GconfigManager.useMinimumOveralPoints && pointAmount > 0) {
double maxLimit = pointAmount * GconfigManager.MinimumOveralPaymentLimit;
if (pointAmount < maxLimit) {
@ -945,7 +945,7 @@ public class Jobs extends JavaPlugin {
}
// Calculate exp
expAmount = expAmount + ((expAmount > 0D ? expAmount : -expAmount) * boost.getFinal(CurrencyType.EXP));
expAmount = boost.getFinalAmount(CurrencyType.EXP, expAmount);
if (GconfigManager.useMinimumOveralPayment && expAmount > 0) {
double maxLimit = expAmount * GconfigManager.MinimumOveralPaymentLimit;

View File

@ -510,17 +510,15 @@ public class JobsCommands implements CommandExecutor {
double income = info.getIncome(level, numjobs);
// Jobs.getPlayerManager().getFinalBonus(player, prog)
income = income + (income * boost.getFinal(CurrencyType.MONEY));
income = boost.getFinalAmount(CurrencyType.MONEY, income);
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
double xp = info.getExperience(level, numjobs);
xp = xp + (xp * boost.getFinal(CurrencyType.EXP));
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
double points = info.getPoints(level, numjobs);
points = points + (points * boost.getFinal(CurrencyType.POINTS));
points = boost.getFinalAmount(CurrencyType.POINTS, points);
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
if (income == 0D && points == 0D && xp == 0D)

View File

@ -43,6 +43,10 @@ public class Boost {
return getFinal(BT, false, false);
}
public double getFinalAmount(CurrencyType BT, double income) {
return income + ((income > 0D ? income : -income) * getFinal(BT, false, false));
}
public double getFinal(CurrencyType BT, boolean percent, boolean excludeExtra) {
double r = 0D;
for (BoostOf one : BoostOf.values()) {

View File

@ -9,3 +9,4 @@
/IConomy7Adapter.class
/IConomyAdapter.class
/CraftConomy3Adapter.class
/SaneEconomyAdapter.class

View File

@ -5,11 +5,11 @@ import org.bukkit.OfflinePlayer;
import com.iCo6.iConomy;
import com.iCo6.system.Accounts;
public class IConomyAdapter implements Economy {
public class IConomy6Adapter implements Economy {
iConomy icon;
public IConomyAdapter(iConomy iconomy) {
public IConomy6Adapter(iConomy iconomy) {
icon = iconomy;
}

View File

@ -1,7 +1,7 @@
name: Jobs
description: Jobs Plugin for the BukkitAPI
main: com.gamingmesh.jobs.Jobs
version: 3.8.0
version: 3.8.1
author: phrstbrn
softdepend: [Vault, iConomy, MythicMobs, McMMO]
commands: