diff --git a/com/gamingmesh/jobs/Gui/GuiManager.java b/com/gamingmesh/jobs/Gui/GuiManager.java index e733de0f..771dbda9 100644 --- a/com/gamingmesh/jobs/Gui/GuiManager.java +++ b/com/gamingmesh/jobs/Gui/GuiManager.java @@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.ActionType; +import com.gamingmesh.jobs.container.BoostType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobInfo; import com.gamingmesh.jobs.container.JobProgression; @@ -149,9 +150,8 @@ public class GuiManager { JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player); // money exp boost - Player dude = Bukkit.getServer().getPlayer(player.getUniqueId()); - Double MoneyBoost = Jobs.getPlayerManager().GetMoneyBoost(dude, job); - Double ExpBoost = Jobs.getPlayerManager().GetExpBoost(dude, job); + Double MoneyBoost = JPlayer.getBoost(job.getName(), BoostType.MONEY); + Double ExpBoost = JPlayer.getBoost(job.getName(), BoostType.EXP); int level = 1; JobProgression prog = JPlayer.getJobProgression(job); diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index 28dde847..b360f6ef 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -735,7 +735,9 @@ public class Jobs { if (income != 0D || points != 0D) { - BoostMultiplier FinalBoost = Jobs.getPlayerManager().getFinalBonus(Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()), Jobs.getNoneJob()); +// jPlayer + + BoostMultiplier FinalBoost = Jobs.getPlayerManager().getFinalBonus(jPlayer, Jobs.getNoneJob()); // Calculate income @@ -825,7 +827,7 @@ public class Jobs { } } - BoostMultiplier FinalBoost = Jobs.getPlayerManager().getFinalBonus(Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()), prog.getJob()); + BoostMultiplier FinalBoost = Jobs.getPlayerManager().getFinalBonus(jPlayer, prog.getJob()); if (multiplier != 0.0) FinalBoost = new BoostMultiplier(FinalBoost.getMoneyBoost() + multiplier, @@ -903,19 +905,22 @@ public class Jobs { } else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction) jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); + // JobsPayment event + JobsExpGainEvent JobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount); + Bukkit.getServer().getPluginManager().callEvent(JobsExpGainEvent); + // If event is canceled, don't do anything + if (JobsExpGainEvent.isCancelled()) + expAmount = 0D; + else + expAmount = JobsExpGainEvent.getExp(); + Jobs.getEconomy().pay(jPlayer, amount, pointAmount, expAmount); int oldLevel = prog.getLevel(); if (Jobs.getGCManager().LoggingUse) Loging.recordToLog(jPlayer, info, amount, expAmount); - // JobsPayment event - JobsExpGainEvent JobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount); - Bukkit.getServer().getPluginManager().callEvent(JobsExpGainEvent); - // If event is canceled, don't do anything - if (JobsExpGainEvent.isCancelled()) - continue; - if (prog.addExperience(JobsExpGainEvent.getExp())) + if (prog.addExperience(expAmount)) Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel); } } diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index d6270542..0ef2b624 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -38,6 +38,7 @@ import com.gamingmesh.jobs.api.JobsJoinEvent; import com.gamingmesh.jobs.api.JobsLeaveEvent; import com.gamingmesh.jobs.api.JobsLevelUpEvent; import com.gamingmesh.jobs.container.BoostMultiplier; +import com.gamingmesh.jobs.container.BoostType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobCommands; import com.gamingmesh.jobs.container.JobItems; @@ -230,7 +231,7 @@ public class PlayerManager { Job job = Jobs.getJob(jobdata.getJobName()); if (job == null) continue; - JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1, -1); + JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience()); jPlayer.progression.add(jobProgression); jPlayer.reloadMaxExperience(); jPlayer.reloadLimits(); @@ -570,76 +571,9 @@ public class PlayerManager { return false; } - /** - * Get job money boost - * @param player - * @param job - * @return double of boost - */ - public Double GetMoneyBoost(Player player, Job job) { - Double Boost = 1.0; - if (player != null && job.getName() != null) { - if (Perm.hasPermission(player, "jobs.boost." + job.getName() + ".money") || - Perm.hasPermission(player, "jobs.boost." + job.getName() + ".all") || - Perm.hasPermission(player, "jobs.boost.all.all") || - Perm.hasPermission(player, "jobs.boost.all.money")) { - Boost = Jobs.getGCManager().BoostMoney; - } - } - return Boost; - } - public double GetMoneyBoostInPerc(Player player, Job job) { - double Boost = GetMoneyBoost(player, job) * 100.0 - 100.0; - return Boost; - } - - /** - * Get job point boost - * @param player - * @param job - * @return double of boost - */ - public Double GetPointBoost(Player player, Job job) { - Double Boost = 1.0; - if (player != null && job.getName() != null) { - if (Perm.hasPermission(player, "jobs.boost." + job.getName() + ".points") || - Perm.hasPermission(player, "jobs.boost." + job.getName() + ".all") || - Perm.hasPermission(player, "jobs.boost.all.all") || - Perm.hasPermission(player, "jobs.boost.all.points")) { - Boost = Jobs.getGCManager().BoostPoints; - } - } - return Boost; - } - - public double GetPointBoostInPerc(Player player, Job job) { - double Boost = GetPointBoost(player, job) * 100.0 - 100.0; - return Boost; - } - - /** - * Get job exp boost - * @param player - * @param job - * @return double of boost - */ - public Double GetExpBoost(Player player, Job job) { - Double Boost = 1.0; - if (player == null || job.getName() == null) - return 1.0; - if (Perm.hasPermission(player, "jobs.boost." + job.getName() + ".exp") || - Perm.hasPermission(player, "jobs.boost." + job.getName() + ".all") || - Perm.hasPermission(player, "jobs.boost.all.all") || - Perm.hasPermission(player, "jobs.boost.all.exp")) { - Boost = Jobs.getGCManager().BoostExp; - } - - return Boost; - } - - public double GetExpBoostInPerc(Player player, Job job) { - double Boost = GetExpBoost(player, job) * 100.0 - 100.0; + public double GetBoostInPerc(JobsPlayer player, Job job, BoostType type) { + double Boost = player.getBoost(job.getName(), type) * 100.0 - 100.0; return Boost; } @@ -732,16 +666,16 @@ public class PlayerManager { return new BoostMultiplier(0D, 0D, 0D); } - public BoostMultiplier getFinalBonus(Player player, Job prog) { + public BoostMultiplier getFinalBonus(JobsPlayer player, Job prog) { BoostMultiplier multiplier = new BoostMultiplier(0D, 0D, 0D); if (player == null || prog == null) return multiplier; - double PMoneyBoost = Jobs.getPlayerManager().GetMoneyBoostInPerc(player, prog); + double PMoneyBoost = Jobs.getPlayerManager().GetBoostInPerc(player, prog, BoostType.MONEY); PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D; - double PPointBoost = Jobs.getPlayerManager().GetPointBoostInPerc(player, prog); + double PPointBoost = Jobs.getPlayerManager().GetBoostInPerc(player, prog, BoostType.POINTS); PPointBoost = (int) (PPointBoost * 100D) / 100D; - double PExpBoost = Jobs.getPlayerManager().GetExpBoostInPerc(player, prog); + double PExpBoost = Jobs.getPlayerManager().GetBoostInPerc(player, prog, BoostType.EXP); PExpBoost = (int) (PExpBoost * 100D) / 100D; double GMoneyBoost = prog.getMoneyBoost() * 100.0 - 100.0; @@ -755,7 +689,7 @@ public class PlayerManager { if (!Jobs.getGCManager().useDynamicPayment) DBoost = 0.0; - BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(player, prog); + BoostMultiplier itemboost = Jobs.getPlayerManager().getItemBoost(player.getPlayer(), prog); double IMoneyBoost = itemboost.getMoneyBoost() * 100.0 - 100.0; IMoneyBoost = (int) (IMoneyBoost * 100D) / 100D; @@ -764,7 +698,7 @@ public class PlayerManager { double IExpBoost = itemboost.getExpBoost() * 100.0 - 100.0; IExpBoost = (int) (IExpBoost * 100D) / 100D; - double RBoost = Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player) * 100.0 - 100.0; + double RBoost = Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player.getPlayer()) * 100.0 - 100.0; RBoost = (int) (RBoost * 100D) / 100D; double Fmoney = (int) ((IMoneyBoost + DBoost + GMoneyBoost + PMoneyBoost + RBoost) * 100) / 100D; diff --git a/com/gamingmesh/jobs/api/JobsPaymentEvent.java b/com/gamingmesh/jobs/api/JobsPaymentEvent.java index 6483518a..0d2acaac 100644 --- a/com/gamingmesh/jobs/api/JobsPaymentEvent.java +++ b/com/gamingmesh/jobs/api/JobsPaymentEvent.java @@ -30,6 +30,10 @@ public final class JobsPaymentEvent extends Event implements Cancellable { return this.points; } + public void setPoints(double amount) { + this.points = amount; + } + public boolean isCancelled() { return cancelled; } @@ -37,7 +41,7 @@ public final class JobsPaymentEvent extends Event implements Cancellable { public void setCancelled(boolean cancel) { cancelled = cancel; } - + public void setAmount(double money) { this.money = money; } diff --git a/com/gamingmesh/jobs/commands/JobsCommands.java b/com/gamingmesh/jobs/commands/JobsCommands.java index 09c9ca5e..284991cd 100644 --- a/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/com/gamingmesh/jobs/commands/JobsCommands.java @@ -426,9 +426,7 @@ public class JobsCommands implements CommandExecutor { public static String jobInfoMessage(JobsPlayer player, Job job, ActionType type) { // money exp boost - Player dude = Bukkit.getServer().getPlayer(player.getPlayerUUID()); - - BoostMultiplier finalBoost = Jobs.getPlayerManager().getFinalBonus(dude, job); + BoostMultiplier finalBoost = Jobs.getPlayerManager().getFinalBonus(player, job); StringBuilder message = new StringBuilder(); diff --git a/com/gamingmesh/jobs/commands/list/bonus.java b/com/gamingmesh/jobs/commands/list/bonus.java index 43f2ef40..63ca0a20 100644 --- a/com/gamingmesh/jobs/commands/list/bonus.java +++ b/com/gamingmesh/jobs/commands/list/bonus.java @@ -7,7 +7,9 @@ import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.BoostMultiplier; +import com.gamingmesh.jobs.container.BoostType; import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.ChatColor; public class bonus implements Cmd { @@ -32,13 +34,18 @@ public class bonus implements Cmd { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); return true; } + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); + + if (jPlayer == null) + return false; // sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", job.getChatColor() + job.getName())); - double PMoneyBoost = Jobs.getPlayerManager().GetMoneyBoostInPerc(player, job); + double PMoneyBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.MONEY); PMoneyBoost = (int) (PMoneyBoost * 100D) / 100D; - double PPointBoost = Jobs.getPlayerManager().GetPointBoostInPerc(player, job); + double PPointBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.POINTS); PPointBoost = (int) (PPointBoost * 100D) / 100D; - double PExpBoost = Jobs.getPlayerManager().GetExpBoostInPerc(player, job); + double PExpBoost = Jobs.getPlayerManager().GetBoostInPerc(jPlayer, job, BoostType.EXP); PExpBoost = (int) (PExpBoost * 100D) / 100D; double GMoneyBoost = job.getMoneyBoost() * 100.0 - 100.0; diff --git a/com/gamingmesh/jobs/config/GeneralConfigManager.java b/com/gamingmesh/jobs/config/GeneralConfigManager.java index 73b06d31..1703032b 100644 --- a/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -33,6 +33,7 @@ import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.container.BoostType; import com.gamingmesh.jobs.container.LocaleReader; import com.gamingmesh.jobs.container.Schedule; import com.gamingmesh.jobs.dao.JobsDAOMySQL; @@ -109,11 +110,11 @@ public class GeneralConfigManager { useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; public Integer levelLossPercentage, SoundLevelupVolume, SoundLevelupPitch, SoundTitleChangeVolume, SoundTitleChangePitch, ToplistInScoreboardInterval; - public double BoostExp; public double MinimumOveralPaymentLimit; public double MinimumOveralPointsLimit; - public double BoostMoney; - public double BoostPoints; + + public HashMap Boost = new HashMap (); + public double DynamicPaymentMaxPenalty; public double DynamicPaymentMaxBonus; public double TaxesAmount; @@ -734,9 +735,9 @@ public class GeneralConfigManager { "Use: jobs.boost.[jobname].money or jobs.boost.[jobname].exp or jobs.boost.[jobname].points or jobs.boost.[jobname].all for all of them with specific jobs name.", "Use: jobs.boost.all.money or jobs.boost.all.exp or jobs.boost.all.points or jobs.boost.all.all to get boost for all jobs", "1.25 means that player will get 25% more than others, you can set less than 1 to get less from anothers"); - BoostExp = c.get("boost.exp", 1.00); - BoostMoney = c.get("boost.money", 1.00); - BoostPoints = c.get("boost.points", 1.00); + Boost.put(BoostType.EXP, c.get("boost.exp", 1.00)); + Boost.put(BoostType.MONEY, c.get("boost.money", 1.00)); + Boost.put(BoostType.POINTS, c.get("boost.points", 1.00)); c.getW().addComment("old-job", "Old job save", "Players can leave job and return later with some level loss during that", "You can fix players level if hes job level is at max level"); diff --git a/com/gamingmesh/jobs/container/.gitignore b/com/gamingmesh/jobs/container/.gitignore index db0090b2..de4a14f7 100644 --- a/com/gamingmesh/jobs/container/.gitignore +++ b/com/gamingmesh/jobs/container/.gitignore @@ -32,3 +32,5 @@ /ShopItem.class /LocaleReader.class /BoostMultiplier.class +/BoostCounter.class +/BoostType.class diff --git a/com/gamingmesh/jobs/container/BoostCounter.java b/com/gamingmesh/jobs/container/BoostCounter.java new file mode 100644 index 00000000..30019583 --- /dev/null +++ b/com/gamingmesh/jobs/container/BoostCounter.java @@ -0,0 +1,33 @@ +package com.gamingmesh.jobs.container; + +public class BoostCounter { + BoostType type; + double boost; + Long calculatedon; + + public BoostCounter(BoostType type, double boost, Long calculatedon) { + this.type = type; + this.boost = boost; + this.calculatedon = calculatedon; + } + + public BoostType getType() { + return this.type; + } + + public long getTime() { + return this.calculatedon; + } + + public double getBoost() { + return this.boost; + } + + public void setTime(long time) { + this.calculatedon = time; + } + + public void setBoost(double boost) { + this.boost = boost; + } +} diff --git a/com/gamingmesh/jobs/container/BoostType.java b/com/gamingmesh/jobs/container/BoostType.java new file mode 100644 index 00000000..1505df77 --- /dev/null +++ b/com/gamingmesh/jobs/container/BoostType.java @@ -0,0 +1,34 @@ +/** + * Jobs Plugin for Bukkit + * Copyright (C) 2011 Zak Ford + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.gamingmesh.jobs.container; + +public enum BoostType { + MONEY("Money"), + EXP("Exp"), + POINTS("Points"); + + private String name; + private BoostType(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/com/gamingmesh/jobs/container/JobProgression.java b/com/gamingmesh/jobs/container/JobProgression.java index ae3984ab..f4329da4 100644 --- a/com/gamingmesh/jobs/container/JobProgression.java +++ b/com/gamingmesh/jobs/container/JobProgression.java @@ -26,18 +26,12 @@ public class JobProgression { private double experience; private int level; private transient int maxExperience = -1; - private double MoneyBoost = -1; - private double PointBoost = -1; - private double ExpBoost = -1; - public JobProgression(Job job, JobsPlayer jPlayer, int level, double experience, double MoneyBoost, double PointBoost, double ExpBoost) { + public JobProgression(Job job, JobsPlayer jPlayer, int level, double experience) { this.job = job; this.jPlayer = jPlayer; this.experience = experience; this.level = level; - this.MoneyBoost = MoneyBoost; - this.PointBoost = PointBoost; - this.ExpBoost = ExpBoost; } /** @@ -48,37 +42,7 @@ public class JobProgression { public boolean canLevelUp() { return experience >= maxExperience; } - - /** - * Return the MoneyBoost - * @return the MoneyBoost - */ - public double getMoneyBoost() { - if (this.MoneyBoost == -1) - this.MoneyBoost = JobsPlayer.getMoneyBoost(this.job.getName(), this.jPlayer.getPlayer()); - return this.MoneyBoost; - } - - /** - * Return the PointBoost - * @return the PointBoost - */ - public double getPointBoost() { - if (this.PointBoost == -1) - this.PointBoost = JobsPlayer.getPointBoost(this.job.getName(), this.jPlayer.getPlayer()); - return this.PointBoost; - } - - /** - * Return the ExpBoost - * @return the ExpBoost - */ - public double getExpBoost() { - if (this.ExpBoost == -1) - this.ExpBoost = JobsPlayer.getExpBoost(this.job.getName(), this.jPlayer.getPlayer()); - return this.ExpBoost; - } - + /** * Return the job * @return the job diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index fb00a278..796cd673 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -20,6 +20,7 @@ package com.gamingmesh.jobs.container; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.UUID; @@ -32,6 +33,7 @@ import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAOData; import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.Perm; public class JobsPlayer { @@ -40,6 +42,9 @@ public class JobsPlayer { // progression of the player in each job private UUID playerUUID; public ArrayList progression = new ArrayList(); + + private HashMap> boostCounter = new HashMap>(); + // display honorific private String honorific; // player save status @@ -87,7 +92,7 @@ public class JobsPlayer { continue; // create the progression object - JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1, -1); + JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience()); // calculate the max level // add the progression level. jPlayer.progression.add(jobProgression); @@ -118,7 +123,7 @@ public class JobsPlayer { continue; // create the progression object - JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience(), -1, -1, -1); + JobProgression jobProgression = new JobProgression(job, jPlayer, jobdata.getLevel(), jobdata.getExperience()); // calculate the max level // add the progression level. jPlayer.progression.add(jobProgression); @@ -200,48 +205,60 @@ public class JobsPlayer { } /** - * Get the MoneyBoost - * @return the MoneyBoost + * Get the Boost + * @return the Boost */ - public static double getMoneyBoost(String JobName, Player player) { - double MoneyBoost = 1.0; - if (JobName != null) { - if (Perm.hasPermission(player, "jobs.boost." + JobName + ".money") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission( - player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.money")) { - MoneyBoost = Jobs.getGCManager().BoostMoney; + public double getBoost(String JobName, BoostType type) { + + if (this.player == null) + this.player = Bukkit.getPlayer(this.OffPlayer.getUniqueId()); + + double Boost = 1.0; + + if (this.player == null) + return Boost; + + long time = System.currentTimeMillis(); + + if (this.boostCounter.containsKey(JobName)) { + ArrayList counterList = boostCounter.get(JobName); + for (BoostCounter counter : counterList) { + if (counter.getType() != type) + continue; + if (time - counter.getTime() > 1000 * 60) { + Boost = getPlayerBoost(JobName, type); + counter.setBoost(Boost); + counter.setTime(time); + return Boost; + } else { + return counter.getBoost(); + } } + Boost = getPlayerBoost(JobName, type); + counterList.add(new BoostCounter(type, Boost, time)); + return Boost; } - return MoneyBoost; + + Boost = getPlayerBoost(JobName, type); + + ArrayList counterList = new ArrayList(); + counterList.add(new BoostCounter(type, Boost, time)); + + boostCounter.put(JobName, counterList); + + return Boost; } - /** - * Get the PointBoost - * @return the PointBoost - */ - public static double getPointBoost(String JobName, Player player) { - double PointBoost = 1.0; - if (JobName != null) { - if (Perm.hasPermission(player, "jobs.boost." + JobName + ".points") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission( - player, "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.money")) { - PointBoost = Jobs.getGCManager().BoostPoints; - } + private Double getPlayerBoost(String JobName, BoostType type) { + double Boost = 1.0; + Debug.D("recalculating for " + JobName); + if (Perm.hasPermission(player, "jobs.boost." + JobName + "." + type.getName().toLowerCase()) || + Perm.hasPermission(player, "jobs.boost." + JobName + ".all") || + Perm.hasPermission(player, "jobs.boost.all.all") || + Perm.hasPermission(player, "jobs.boost.all." + type.getName().toLowerCase())) { + Boost = Jobs.getGCManager().Boost.get(type); } - return PointBoost; - } - - /** - * Get the ExpBoost - * @return the ExpBoost - */ - public static double getExpBoost(String JobName, Player player) { - Double ExpBoost = 1.0; - if (player == null || JobName == null) - return 1.0; - if (Perm.hasPermission(player, "jobs.boost." + JobName + ".exp") || Perm.hasPermission(player, "jobs.boost." + JobName + ".both") || Perm.hasPermission(player, - "jobs.boost.all.both") || Perm.hasPermission(player, "jobs.boost.all.exp")) { - ExpBoost = Jobs.getGCManager().BoostExp; - } - return ExpBoost; + return Boost; } /** @@ -382,7 +399,7 @@ public class JobsPlayer { Jobs.getJobsDAO().deleteArchive(jPlayer, job); } - progression.add(new JobProgression(job, this, level, exp, -1, -1, -1)); + progression.add(new JobProgression(job, this, level, exp)); reloadMaxExperience(); reloadLimits(); reloadHonorific(); diff --git a/com/gamingmesh/jobs/dao/JobsDAOMySQL.java b/com/gamingmesh/jobs/dao/JobsDAOMySQL.java index 67947612..1ddd2c93 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOMySQL.java +++ b/com/gamingmesh/jobs/dao/JobsDAOMySQL.java @@ -521,7 +521,13 @@ public class JobsDAOMySQL extends JobsDAO { } } } - + // Create new points table + try { + executeSQL("CREATE TABLE `" + getPrefix() + + "points` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` int, `totalpoints` double, `currentpoints` double);"); + } catch (SQLException e) { + } + if (rows == 0) { HashMap tempMap = new HashMap(); PreparedStatement prest = null; @@ -664,13 +670,7 @@ public class JobsDAOMySQL extends JobsDAO { executeSQL("ALTER TABLE `" + getPrefix() + "log` DROP COLUMN `player_uuid`, DROP COLUMN `username`;"); } catch (Exception e) { } - // Create new points table - try { - executeSQL("CREATE TABLE `" + getPrefix() - + "points` (`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `userid` int, `totalpoints` double, `currentpoints` double);"); - } catch (SQLException e) { - e.printStackTrace(); - } + } } diff --git a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java index f5e797cd..24cda664 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java +++ b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java @@ -29,6 +29,7 @@ import org.bukkit.Bukkit; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.PlayerInfo; +import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.UUIDUtil; public class JobsDAOSQLite extends JobsDAO { @@ -503,6 +504,7 @@ public class JobsDAOSQLite extends JobsDAO { @Override protected synchronized void checkUpdate9() throws SQLException { + Debug.D("checkling 9"); JobsConnection conn = getConnection(); if (conn == null) { Jobs.getPluginLogger().severe("Could not run database updates! Could not connect to SQLite!"); @@ -526,7 +528,14 @@ public class JobsDAOSQLite extends JobsDAO { } } } - + + // Create new points table + try { + executeSQL("CREATE TABLE `" + getPrefix() + + "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);"); + } catch (Exception e) { + } + if (rows != 0) return; @@ -788,13 +797,7 @@ public class JobsDAOSQLite extends JobsDAO { } catch (Exception e) { e.printStackTrace(); } - // Create new points table - try { - executeSQL("CREATE TABLE `" + getPrefix() - + "points` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `userid` int, `totalpoints` double, `currentpoints` double);"); - } catch (Exception e) { - e.printStackTrace(); - } + } diff --git a/com/gamingmesh/jobs/economy/BufferedEconomy.java b/com/gamingmesh/jobs/economy/BufferedEconomy.java index 0f0ca9ec..924b8bab 100644 --- a/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -167,8 +167,8 @@ public class BufferedEconomy { if (JobsPaymentEvent.isCancelled()) continue; - double newAmount = JobsPaymentEvent.getAmount(); - payment.setAmount(newAmount); + payment.setAmount(JobsPaymentEvent.getAmount()); + payment.setPoints(JobsPaymentEvent.getPoints()); if (Jobs.getGCManager().UseServerAccount) { if (!hasMoney) { @@ -184,7 +184,6 @@ public class BufferedEconomy { if (Jobs.getGCManager().isEconomyAsync()) Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new BufferedPaymentTask(this, economy, payment), i); else - Bukkit.getScheduler().runTaskLater(plugin, new BufferedPaymentTask(this, economy, payment), i); } try { diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 857c410c..3dbc0912 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -251,7 +251,7 @@ public class JobsPaymentListener implements Listener { if (block == null) return; - if (block.getType().equals(Material.FURNACE) && block.hasMetadata(furnaceOwnerMetadata)) + if (block.getType() == Material.FURNACE && block.hasMetadata(furnaceOwnerMetadata)) block.removeMetadata(furnaceOwnerMetadata, plugin); if (Jobs.getGCManager().useBlockProtection) @@ -278,7 +278,7 @@ public class JobsPaymentListener implements Listener { return; // check if in creative - if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) + if (player.getGameMode()== GameMode.CREATIVE && !Jobs.getGCManager().payInCreative()) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) diff --git a/plugin.yml b/plugin.yml index be230174..8097758e 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 3.4.3 +version: 3.4.5 author: phrstbrn depend: [Vault] softdepend: [CoreProtect, MythicMobs, McMMO]