mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 22:13:25 +01:00
parent
c162f1a2be
commit
20e54e805c
@ -47,7 +47,10 @@ public class GeneralConfigManager {
|
|||||||
|
|
||||||
public List<Integer> BroadcastingLevelUpLevels = new ArrayList<>();
|
public List<Integer> BroadcastingLevelUpLevels = new ArrayList<>();
|
||||||
public List<String> FwColors = new ArrayList<>(), DisabledWorldsList = new ArrayList<>();
|
public List<String> FwColors = new ArrayList<>(), DisabledWorldsList = new ArrayList<>();
|
||||||
public List<Schedule> BoostSchedule = new ArrayList<>();
|
/**
|
||||||
|
* @deprecated use {@link ScheduleManager}
|
||||||
|
*/
|
||||||
|
@Deprecated public List<Schedule> BoostSchedule = new ArrayList<>();
|
||||||
|
|
||||||
public HashMap<CMIMaterial, HashMap<Enchantment, Integer>> whiteListedItems = new HashMap<>();
|
public HashMap<CMIMaterial, HashMap<Enchantment, Integer>> whiteListedItems = new HashMap<>();
|
||||||
private HashMap<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<>();
|
private HashMap<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<>();
|
||||||
|
@ -25,13 +25,16 @@ public class ScheduleManager {
|
|||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
private int autoTimerBukkitId = -1;
|
private int autoTimerBukkitId = -1;
|
||||||
|
|
||||||
|
public static final List<Schedule> BOOSTSCHEDULE = new ArrayList<>();
|
||||||
|
|
||||||
public ScheduleManager(Jobs plugin) {
|
public ScheduleManager(Jobs plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
if (Jobs.getGCManager().BoostSchedule.isEmpty())
|
if (BOOSTSCHEDULE.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cancel();
|
cancel();
|
||||||
autoTimerBukkitId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoTimer, 20, 30 * 20L);
|
autoTimerBukkitId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoTimer, 20, 30 * 20L);
|
||||||
}
|
}
|
||||||
@ -41,19 +44,14 @@ public class ScheduleManager {
|
|||||||
Bukkit.getScheduler().cancelTask(autoTimerBukkitId);
|
Bukkit.getScheduler().cancelTask(autoTimerBukkitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable autoTimer = () -> {
|
private Runnable autoTimer = this::scheduler;
|
||||||
try {
|
|
||||||
scheduler();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public int getDateByInt() {
|
public int getDateByInt() {
|
||||||
return TimeManage.timeInInt();
|
return TimeManage.timeInInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean scheduler() {
|
private boolean scheduler() {
|
||||||
if (Jobs.getGCManager().BoostSchedule.isEmpty())
|
if (BOOSTSCHEDULE.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||||
@ -65,7 +63,7 @@ public class ScheduleManager {
|
|||||||
|
|
||||||
String CurrentDayName = GetWeekDay();
|
String CurrentDayName = GetWeekDay();
|
||||||
|
|
||||||
for (Schedule one : Jobs.getGCManager().BoostSchedule) {
|
for (Schedule one : BOOSTSCHEDULE) {
|
||||||
|
|
||||||
int From = one.GetFrom();
|
int From = one.GetFrom();
|
||||||
int Until = one.GetUntil();
|
int Until = one.GetUntil();
|
||||||
@ -160,6 +158,8 @@ public class ScheduleManager {
|
|||||||
* loads from Jobs/schedule.yml
|
* loads from Jobs/schedule.yml
|
||||||
*/
|
*/
|
||||||
public void load() {
|
public void load() {
|
||||||
|
BOOSTSCHEDULE.clear();
|
||||||
|
|
||||||
YmlMaker jobSchedule = new YmlMaker(plugin, "schedule.yml");
|
YmlMaker jobSchedule = new YmlMaker(plugin, "schedule.yml");
|
||||||
jobSchedule.saveDefaultConfig();
|
jobSchedule.saveDefaultConfig();
|
||||||
|
|
||||||
@ -175,10 +175,7 @@ public class ScheduleManager {
|
|||||||
for (String OneSection : sections) {
|
for (String OneSection : sections) {
|
||||||
ConfigurationSection path = conf.getConfigurationSection("Boost." + OneSection);
|
ConfigurationSection path = conf.getConfigurationSection("Boost." + OneSection);
|
||||||
|
|
||||||
if (!path.contains("Enabled"))
|
if (!path.contains("Enabled") || !conf.getConfigurationSection("Boost." + OneSection).getBoolean("Enabled"))
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!conf.getConfigurationSection("Boost." + OneSection).getBoolean("Enabled"))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Schedule sched = new Schedule();
|
Schedule sched = new Schedule();
|
||||||
@ -226,9 +223,10 @@ public class ScheduleManager {
|
|||||||
if (path.contains("Points") && path.isDouble("Points"))
|
if (path.contains("Points") && path.isDouble("Points"))
|
||||||
sched.setBoost(CurrencyType.POINTS, path.getDouble("Points", 0D));
|
sched.setBoost(CurrencyType.POINTS, path.getDouble("Points", 0D));
|
||||||
|
|
||||||
Jobs.getGCManager().BoostSchedule.add(sched);
|
BOOSTSCHEDULE.add(sched);
|
||||||
}
|
}
|
||||||
if (Jobs.getGCManager().BoostSchedule.size() != 0)
|
|
||||||
Jobs.consoleMsg("&e[Jobs] Loaded " + Jobs.getGCManager().BoostSchedule.size() + " schedulers!");
|
if (!BOOSTSCHEDULE.isEmpty())
|
||||||
|
Jobs.consoleMsg("&e[Jobs] Loaded " + BOOSTSCHEDULE.size() + " schedulers!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user