1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Merge pull request #126 from Rukes/master

Added 3rd party BP & new schedule event
This commit is contained in:
Zrips 2017-09-01 12:19:51 +03:00 committed by GitHub
commit fbf3f22945
4 changed files with 94 additions and 0 deletions

View File

@ -1099,6 +1099,10 @@ public class Jobs extends JavaPlugin {
return true;
if (info.getType() == ActionType.BREAK) {
if(block.hasMetadata("JobsExploit")){
//player.sendMessage("This block is protected using Rukes' system!");
return false;
}
BlockProtection bp = getBpManager().getBp(block.getLocation());
if (bp != null) {
Long time = bp.getTime();

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.List;
import com.gamingmesh.jobs.api.JobsScheduleStartEvent;
import com.gamingmesh.jobs.api.JobsScheduleStopEvent;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
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()) {
JobsScheduleStartEvent event = new JobsScheduleStartEvent(one);
Bukkit.getPluginManager().callEvent(event);
if(event.isCancelled()){
continue;
}
if (one.isBroadcastOnStart())
if (one.GetMessageOnStart().size() == 0)
Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStarted"));
@ -102,6 +109,11 @@ public class ScheduleManager {
break;
} else if (((one.isNextDay() && Current > one.GetNextUntil() && Current < one.GetFrom() && !one.isStoped()) || !one.isNextDay() && Current > Until
&& ((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.GetMessageOnStop().size() == 0)
Bukkit.broadcastMessage(Jobs.getLanguage().getMessage("message.boostStoped"));