diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 8490cfa3..66c52e3b 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -1415,15 +1415,27 @@ public final class Jobs extends JavaPlugin { return 9 * level - 158; } - public static void perform(JobsPlayer jPlayer, ActionInfo info, BufferedPayment payment, Job job) { + public static void perform(JobsPlayer jPlayer, ActionInfo info, BufferedPayment payment, Job job, Block block, Entity ent, LivingEntity victim) { double expPayment = payment.get(CurrencyType.EXP); + JobsPrePaymentEvent jobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, payment.get(CurrencyType.MONEY), + payment.get(CurrencyType.POINTS), block, ent, victim, info); + Bukkit.getServer().getPluginManager().callEvent(jobsPrePaymentEvent); + // If event is canceled, don't do anything + if (jobsPrePaymentEvent.isCancelled()) + return; + + payment.set(CurrencyType.MONEY, jobsPrePaymentEvent.getAmount()); + payment.set(CurrencyType.POINTS, jobsPrePaymentEvent.getPoints()); + JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(payment.getOfflinePlayer(), job, expPayment); Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent); // If event is canceled, don't do anything if (jobsExpGainEvent.isCancelled()) return; + payment.set(CurrencyType.EXP, jobsExpGainEvent.getExp()); + boolean limited = true; for (CurrencyType one : CurrencyType.values()) { if (jPlayer.isUnderLimit(one, payment.get(one))) { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 28fac998..8c452879 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -444,7 +444,7 @@ public final class JobsPaymentListener implements Listener { if (fp != null) { if (fp.getTime() > System.currentTimeMillis() && (fp.getInfo().getName().equalsIgnoreCase(bInfo.getName()) || fp.getInfo().getNameWithSub().equalsIgnoreCase(bInfo.getNameWithSub()))) { - Jobs.perform(fp.getPlayer(), fp.getInfo(), fp.getPayment(), fp.getJob()); + Jobs.perform(fp.getPlayer(), fp.getInfo(), fp.getPayment(), fp.getJob(), block, null, null); return; } Jobs.FASTPAYMENT.remove(player.getUniqueId()); @@ -485,7 +485,8 @@ public final class JobsPaymentListener implements Listener { return; // A tool should not trigger a BlockPlaceEvent (fixes stripping logs bug #940) - if (CMIMaterial.get(event.getItemInHand().getType()).isTool()) + // Allow this to trigger with a hoe so players can get paid for farmland. + if (CMIMaterial.get(event.getItemInHand().getType()).isTool() && !event.getItemInHand().getType().toString().endsWith("_HOE")) return; Block block = event.getBlock(); @@ -1971,7 +1972,7 @@ public final class JobsPaymentListener implements Listener { if (fp.getTime() > System.currentTimeMillis() - 50L && (fp.getInfo().getName().equalsIgnoreCase(bInfo.getName()) || fp.getInfo().getNameWithSub().equalsIgnoreCase(bInfo.getNameWithSub()))) { - Jobs.perform(fp.getPlayer(), fp.getInfo(), fp.getPayment(), fp.getJob()); + Jobs.perform(fp.getPlayer(), fp.getInfo(), fp.getPayment(), fp.getJob(), block, null, null); breakCache.put(CMILocation.toString(block.getLocation(), ":", true, true), uuid); fp.setTime(System.currentTimeMillis() + 45); }