1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Added JobsSchedulerStartEvent & JobsSchedulerStopEvent to developer API

This commit is contained in:
Rukes 2017-08-14 06:25:03 +02:00
parent 3ed7b01ce8
commit 95fcccb35b
3 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package com.gamingmesh.jobs.api;
import com.gamingmesh.jobs.container.Schedule;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class JobsScheduleStartEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private Schedule schedule;
public JobsScheduleStartEvent(Schedule schedule){
this.schedule = schedule;
}
public Schedule getSchedule() {
return schedule;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,39 @@
package com.gamingmesh.jobs.api;
import com.gamingmesh.jobs.container.Schedule;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class JobsScheduleStopEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private Schedule schedule;
public JobsScheduleStopEvent(Schedule schedule){
this.schedule = schedule;
}
public Schedule getSchedule() {
return schedule;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -8,6 +8,8 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.gamingmesh.jobs.api.JobsScheduleStartEvent;
import com.gamingmesh.jobs.api.JobsScheduleStopEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -83,6 +85,11 @@ public class ScheduleManager {
.isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one .isStarted()) || !one.isNextDay() && (Current >= From && Current < Until)) && (days.contains(CurrentDayName) || days.contains("all")) && !one
.isStarted()) { .isStarted()) {
JobsScheduleStartEvent event = new JobsScheduleStartEvent(one);
Bukkit.getPluginManager().callEvent(event);
if(event.isCancelled()){
continue;
}
if (one.isBroadcastOnStart()) if (one.isBroadcastOnStart())
if (one.GetMessageOnStart().size() == 0) if (one.GetMessageOnStart().size() == 0)
Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStarted")); Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStarted"));
@ -102,6 +109,11 @@ public class ScheduleManager {
break; break;
} else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until } else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until
&& ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) { && ((days.contains(CurrentDayName)) || days.contains("all"))) && !one.isStoped()) {
JobsScheduleStopEvent event = new JobsScheduleStopEvent(one);
Bukkit.getPluginManager().callEvent(event);
if(event.isCancelled()){
continue;
}
if (one.isBroadcastOnStop()) if (one.isBroadcastOnStop())
if (one.GetMessageOnStop().size() == 0) if (one.GetMessageOnStop().size() == 0)
Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStoped")); Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStoped"));