mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
commit
a9155efbc2
@ -55,6 +55,7 @@ import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.WorldGuard.WorldGuardManager;
|
||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||
import com.gamingmesh.jobs.api.JobsPrePaymentEvent;
|
||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||
import com.gamingmesh.jobs.config.BlockProtectionManager;
|
||||
import com.gamingmesh.jobs.config.BossBarManager;
|
||||
@ -997,6 +998,17 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
Boost boost = getPlayerManager().getFinalBonus(jPlayer, noneJob);
|
||||
|
||||
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, income, pointAmount);
|
||||
Bukkit.getServer().getPluginManager().callEvent(JobsPrePaymentEvent);
|
||||
// If event is canceled, don't do anything
|
||||
if (JobsPrePaymentEvent.isCancelled()) {
|
||||
income = 0D;
|
||||
pointAmount = 0D;
|
||||
} else {
|
||||
income = JobsPrePaymentEvent.getAmount();
|
||||
pointAmount = JobsPrePaymentEvent.getPoints();
|
||||
}
|
||||
|
||||
// Calculate income
|
||||
|
||||
if (income != 0D) {
|
||||
@ -1097,8 +1109,20 @@ public class Jobs extends JavaPlugin {
|
||||
player.giveExp(expInt);
|
||||
}
|
||||
}
|
||||
|
||||
Boost boost = getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim);
|
||||
|
||||
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), prog.getJob(), income, pointAmount);
|
||||
Bukkit.getServer().getPluginManager().callEvent(JobsPrePaymentEvent);
|
||||
// If event is canceled, don't do anything
|
||||
if (JobsPrePaymentEvent.isCancelled()) {
|
||||
income = 0D;
|
||||
pointAmount = 0D;
|
||||
} else {
|
||||
income = JobsPrePaymentEvent.getAmount();
|
||||
pointAmount = JobsPrePaymentEvent.getPoints();
|
||||
}
|
||||
|
||||
// Calculate income
|
||||
if (income != 0D) {
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
|
@ -0,0 +1,56 @@
|
||||
package com.gamingmesh.jobs.api;
|
||||
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public final class JobsPrePaymentEvent extends BaseEvent implements Cancellable {
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private double money;
|
||||
private double points;
|
||||
private Job job;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public JobsPrePaymentEvent(OfflinePlayer offlinePlayer, Job job, double money, double points) {
|
||||
this.job = job;
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
this.money = money;
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public Job getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
public void setAmount(double money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public void setPoints(double points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user