Skip to content
montlikadani edited this page Jun 14, 2021 · 9 revisions

Events

JobsAreaSelectionEvent

The event is called when selected an area with the specified item.

Example

@EventHandler
public void onJobsAreaSelection(JobsAreaSelectionEvent event) {
    event.getPlayer().sendMessage("You have selected the area in high and low location: " + event.getArea().getHighLoc() + " " + event.getArea().getLowLoc());
}

JobsChunkChangeEvent

The event is called when the chunk has changed.

Example

@EventHandler
public void onJobsChunkChange(JobsChunkChangeEvent event) {
    event.getPlayer().sendMessage("The new chunk is: " + event.getNewChunk());
}

JobsExpGainEvent

The event is called when a player gain exp from job.

Example

@EventHandler
public void onJobsExpGain(JobsExpGainEvent event) {
    event.getPlayer().sendMessage("You got " + event.getExp() + " amount exp in job " + event.getJob().getName());
}

JobsJoinEvent

The event is called when a player join to a specified job.

Example

@EventHandler
public void onJobsJoin(JobsJoinEvent event) {
    event.getPlayer().getPlayer().sendMessage("You have joined to " + event.getJob().getName() + " job!");
}

JobsLeaveEvent

The event is called when a player left from a specified job.

Example

@EventHandler
public void onJobsLeave(JobsLeaveEvent event) {
    event.getPlayer().getPlayer().sendMessage("You have left from " + event.getJob().getName() + " job!");
}

JobsLevelUpEvent

The event is called when a player leveled up in that job.

Example

@EventHandler
public void onJobsLevelUp(JobsLevelUpEvent event) {
    event.getPlayer().getPlayer().sendMessage("You have leveled up in " + event.getJob().getName() + " job!");
}

JobsPaymentEvent

The event is called when calculating the payment.

Example

@EventHandler
public void onJobsPayment(JobsPaymentEvent event) {
    event.getPlayer().sendMessage("You got " + event.get(CurrencyType.MONEY) + " money!");
}

JobsPrePaymentEvent

Event fired, before the payment calculation process should beginning.

Example

@EventHandler
public void onJobsPrePayment(JobsPrePaymentEvent e) {
    e.getPlayer().sendMessage("Payment event is cancelled in " + e.getJob().getName() + " job!");
    e.getPlayer().sendMessage("You not get any income for doing actions.");
    e.setCancelled(true);
}

JobsScheduleStartEvent

The event is called when started the schedule.

Example

@EventHandler
public void onJobsScheduleStart(JobsScheduleStartEvent ev) {
    if (e.getSchedule().isStarted()) {
        Bukkit.getLogger().log(Level.INFO, "The scheduler has started.");
    }
}

JobsScheduleStopEvent

The event is called when stopped the schedule.

Example

@EventHandler
public void onJobsScheduleStop(JobsScheduleStopEvent ev) {
    if (e.getSchedule().isStoped()) {
        Bukkit.getLogger().log(Level.INFO, "The scheduler has stopped.");
    }
}

Player information

To get player's information object, use:

JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);

Then you can get things such as their log, left times, quests, total levels and more. Remember that this method can return null if the given player is not cached into memory.

To get player's job progression list (unmodifiable) use:

JobsPlayer jobsPlayer = Jobs.getPlayerManager().getJobsPlayer(player);

if (jobsPlayer != null) {
    List<JobProgression> jobs = jobsPlayer.getJobProgression();

    for (JobProgression prog : jobs) {
      // Do your stuff here
    }
}

To get an unmodifiable jobs list:

Jobs.getJobs();