diff --git a/src/main/java/com/gamingmesh/jobs/api/JobsPaymentEvent.java b/src/main/java/com/gamingmesh/jobs/api/JobsPaymentEvent.java index b9afe163..a8628af5 100644 --- a/src/main/java/com/gamingmesh/jobs/api/JobsPaymentEvent.java +++ b/src/main/java/com/gamingmesh/jobs/api/JobsPaymentEvent.java @@ -1,38 +1,72 @@ package com.gamingmesh.jobs.api; +import java.util.HashMap; + import org.bukkit.OfflinePlayer; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import com.gamingmesh.jobs.container.CurrencyType; + public final class JobsPaymentEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private OfflinePlayer offlinePlayer; - private double money; - private double points; private boolean cancelled = false; + private HashMap payments = new HashMap(); + + @Deprecated public JobsPaymentEvent(OfflinePlayer offlinePlayer, double money, double points) { super(true); this.offlinePlayer = offlinePlayer; - this.money = money; - this.points = points; + payments.put(CurrencyType.MONEY, money); + payments.put(CurrencyType.POINTS, points); + } + + public JobsPaymentEvent(OfflinePlayer offlinePlayer, HashMap payments) { + super(true); + this.offlinePlayer = offlinePlayer; + this.payments = payments; } public OfflinePlayer getPlayer() { return offlinePlayer; } - public double getAmount() { - return money; + @Deprecated + public Double getAmount() { + Double amount = this.payments.get(CurrencyType.MONEY); + return amount == null ? 0 : amount; } + @Deprecated public double getPoints() { - return points; + Double amount = this.payments.get(CurrencyType.POINTS); + return amount == null ? 0 : amount; } + @Deprecated + public void setAmount(double amount) { + this.payments.put(CurrencyType.MONEY, amount); + } + + @Deprecated public void setPoints(double points) { - this.points = points; + this.payments.put(CurrencyType.POINTS, points); + } + + public Double get(CurrencyType type) { + Double amount = this.payments.get(type); + return amount == null ? 0 : amount; + } + + public Double set(CurrencyType type, double amount) { + return this.payments.put(type, amount); + } + + public HashMap getPayment() { + return payments; } @Override @@ -45,10 +79,6 @@ public final class JobsPaymentEvent extends Event implements Cancellable { this.cancelled = cancelled; } - public void setAmount(double money) { - this.money = money; - } - @Override public HandlerList getHandlers() { return handlers; diff --git a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java index 69544eb6..86268e7d 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -179,14 +179,14 @@ public class BufferedEconomy { continue; // JobsPayment event - JobsPaymentEvent JobsPaymentEvent = new JobsPaymentEvent(payment.getOfflinePlayer(), payment.get(CurrencyType.MONEY), payment.get(CurrencyType.POINTS)); + JobsPaymentEvent JobsPaymentEvent = new JobsPaymentEvent(payment.getOfflinePlayer(), payment.getPayment()); Bukkit.getServer().getPluginManager().callEvent(JobsPaymentEvent); // If event is canceled, dont do anything if (JobsPaymentEvent.isCancelled()) continue; - payment.set(CurrencyType.MONEY, JobsPaymentEvent.getAmount()); - payment.set(CurrencyType.POINTS, JobsPaymentEvent.getPoints()); + // Do we need this? + payment.getPayment().putAll(JobsPaymentEvent.getPayment()); if (Jobs.getGCManager().UseServerAccount) { if (!hasMoney) { diff --git a/src/main/java/com/gamingmesh/jobs/economy/BufferedPayment.java b/src/main/java/com/gamingmesh/jobs/economy/BufferedPayment.java index bdcf9034..78608bba 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/BufferedPayment.java +++ b/src/main/java/com/gamingmesh/jobs/economy/BufferedPayment.java @@ -48,18 +48,21 @@ public class BufferedPayment { } @Deprecated - public Double getAmount() { - return this.payments.get(CurrencyType.MONEY); + public Double getAmount() { + Double amount = this.payments.get(CurrencyType.MONEY); + return amount == null ? 0 : amount; } @Deprecated public double getPoints() { - return this.payments.get(CurrencyType.POINTS); + Double amount = this.payments.get(CurrencyType.POINTS); + return amount == null ? 0 : amount; } @Deprecated public double getExp() { - return this.payments.get(CurrencyType.EXP); + Double amount = this.payments.get(CurrencyType.EXP); + return amount == null ? 0 : amount; } @Deprecated