From f7c4afc8dc2b028b7d75f2ddd77aca7a365260a3 Mon Sep 17 00:00:00 2001 From: Zrips Date: Sat, 10 Dec 2016 15:45:59 +0200 Subject: [PATCH] Wrong penalty amount --- com/gamingmesh/jobs/Jobs.java | 4 ++++ com/gamingmesh/jobs/container/Job.java | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index 3c9b308f..f97c582b 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -405,7 +405,11 @@ public class Jobs extends JavaPlugin { * Get the Data Access Object * @return the DAO */ + static int ii = 0; + public static JobsDAO getJobsDAO() { + ii++; + Debug.D("db access " + ii); return dao; } diff --git a/com/gamingmesh/jobs/container/Job.java b/com/gamingmesh/jobs/container/Job.java index 765dc5db..7b5951c2 100644 --- a/com/gamingmesh/jobs/container/Job.java +++ b/com/gamingmesh/jobs/container/Job.java @@ -29,6 +29,7 @@ import org.bukkit.inventory.ItemStack; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; public class Job { // job info @@ -69,7 +70,7 @@ public class Job { private ItemStack GUIitem; private int totalPlayers = -1; - private double bonus = 0.0; + private Double bonus = null; private BoostMultiplier boost = new BoostMultiplier(); @@ -117,15 +118,15 @@ public class Job { public void addBoost(BoostType type, double Point) { this.boost.add(type, Point - 1D); } - + public void setBoost(BoostMultiplier BM) { - this.boost = BM; - } - + this.boost = BM; + } + public BoostMultiplier getBoost() { return this.boost; } - + public boolean isSame(Job job) { return this.getName().equalsIgnoreCase(job.getName()); } @@ -147,22 +148,21 @@ public class Job { if (!Jobs.getGCManager().useDynamicPayment) return; Parser eq = Jobs.getGCManager().DynamicPaymentEquation; - eq.setVariable("totalworkers", this.totalPlayers); + eq.setVariable("totalworkers", Jobs.getJobsDAO().getTotalPlayers()); eq.setVariable("totaljobs", Jobs.getJobs().size()); eq.setVariable("jobstotalplayers", getTotalPlayers()); - double now = eq.getValue(); if (now > Jobs.getGCManager().DynamicPaymentMaxBonus) now = Jobs.getGCManager().DynamicPaymentMaxBonus; if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty * -1) now = Jobs.getGCManager().DynamicPaymentMaxPenalty * -1; - this.bonus = now; + this.bonus = (now / 100); } public double getBonus() { - if (this.bonus == 0.0) + if (this.bonus == null) updateBonus(); - return this.bonus; + return this.bonus == null ? 1D : this.bonus; } public List getCmdOnJoin() {