1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Implement more API event methods to PrePaymentEvent

This commit is contained in:
montlikadani 2019-08-23 17:28:35 +02:00
parent a07cbb246d
commit d84b7d4f03
2 changed files with 41 additions and 2 deletions

View File

@ -1027,7 +1027,8 @@ public class Jobs extends JavaPlugin {
Boost boost = getPlayerManager().getFinalBonus(jPlayer, noneJob);
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, income, pointAmount);
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, income,
pointAmount, block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(JobsPrePaymentEvent);
// If event is canceled, don't do anything
if (JobsPrePaymentEvent.isCancelled()) {
@ -1143,7 +1144,8 @@ public class Jobs extends JavaPlugin {
Boost boost = getPlayerManager().getFinalBonus(jPlayer, prog.getJob(), ent, victim);
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), prog.getJob(), income, pointAmount);
JobsPrePaymentEvent JobsPrePaymentEvent = new JobsPrePaymentEvent(jPlayer.getPlayer(), noneJob, income,
pointAmount, block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(JobsPrePaymentEvent);
// If event is canceled, don't do anything
if (JobsPrePaymentEvent.isCancelled()) {

View File

@ -1,7 +1,11 @@
package com.gamingmesh.jobs.api;
import com.gamingmesh.jobs.container.ActionInfo;
import com.gamingmesh.jobs.container.Job;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
public final class JobsPrePaymentEvent extends BaseEvent implements Cancellable {
@ -9,8 +13,13 @@ public final class JobsPrePaymentEvent extends BaseEvent implements Cancellable
private double money;
private double points;
private Job job;
private Block block;
private Entity entity;
private LivingEntity living;
private ActionInfo info;
private boolean cancelled = false;
@Deprecated
public JobsPrePaymentEvent(OfflinePlayer offlinePlayer, Job job, double money, double points) {
this.job = job;
this.offlinePlayer = offlinePlayer;
@ -18,6 +27,18 @@ public final class JobsPrePaymentEvent extends BaseEvent implements Cancellable
this.points = points;
}
public JobsPrePaymentEvent(OfflinePlayer offlinePlayer, Job job, double money, double points, Block block,
Entity entity, LivingEntity living, ActionInfo info) {
this.job = job;
this.offlinePlayer = offlinePlayer;
this.money = money;
this.points = points;
this.block = block;
this.entity = entity;
this.living = living;
this.info = info;
}
public OfflinePlayer getPlayer() {
return offlinePlayer;
}
@ -42,6 +63,22 @@ public final class JobsPrePaymentEvent extends BaseEvent implements Cancellable
this.points = points;
}
public Block getBlock() {
return block;
}
public Entity getEntity() {
return entity;
}
public LivingEntity getLivingEntity() {
return living;
}
public ActionInfo getActionInfo() {
return info;
}
@Override
public boolean isCancelled() {
return cancelled;