diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 9dc6bbfb..52389006 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -753,7 +753,7 @@ public final class Jobs extends JavaPlugin { } HookManager.loadHooks(); - registerListeners(); + registerListeners(); if (Version.isCurrentEqualOrHigher(Version.v1_16_R3) && kyoriSupported) { complement = new Complement2(); @@ -816,7 +816,7 @@ public final class Jobs extends JavaPlugin { // unregister all registered listeners by this plugin and register again if (!startup) { HandlerList.unregisterAll(getInstance()); - registerListeners(); + registerListeners(); } if (saveTask != null) { @@ -870,8 +870,12 @@ public final class Jobs extends JavaPlugin { // Schedule if (getGCManager().enableSchedule) { - getScheduleManager().load(); - getScheduleManager().start(); + try { + getScheduleManager().load(); + getScheduleManager().start(); + } catch (Throwable e) { + e.printStackTrace(); + } } else getScheduleManager().cancel(); } @@ -1501,7 +1505,7 @@ public final class Jobs extends JavaPlugin { .addHover(LC.info_pageCountHover.getLocale("[totalEntries]", totalEntries)); rm.addText(pageCount > currentPage ? LC.info_nextPage.getLocale() : LC.info_nextPageOff.getLocale()) - .addHover(pageCount > currentPage ? LC.info_nextPageHover.getLocale(): LC.info_firstPageHover.getLocale()) + .addHover(pageCount > currentPage ? LC.info_nextPageHover.getLocale() : LC.info_firstPageHover.getLocale()) .addCommand(pageCount > currentPage ? cmd + " " + pagePrefix + nextPage : cmd + " " + pagePrefix + 1); if (pageCount != 0) diff --git a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java index c331fc5c..4c9cef7f 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java @@ -2,6 +2,7 @@ package com.gamingmesh.jobs.config; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -19,6 +20,8 @@ import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Schedule; +import net.Zrips.CMILib.Logs.CMIDebug; + public class ScheduleManager { private Jobs plugin; @@ -166,15 +169,37 @@ public class ScheduleManager { for (String oneSection : sections) { ConfigurationSection path = section.getConfigurationSection(oneSection); - if (path == null || !path.getBoolean("Enabled") || !path.getString("From", "").contains(":") - || !path.getString("Until", "").contains(":") || !path.isList("Days") || !path.isList("Jobs")) + if (path == null) continue; + if (!path.getBoolean("Enabled")) + continue; + + if (!path.getString("From", "").contains(":") || + !path.getString("Until", "").contains(":") || + !path.isList("Days") && !path.isString("Days") || + !path.isList("Jobs") && !path.isString("Jobs")) { + + Jobs.consoleMsg("&cIncorect scheduler format detected for " + oneSection + " scheduler!"); + continue; + } + Schedule sched = new Schedule(); sched.setName(oneSection); - sched.setDays(path.getStringList("Days")); - sched.setJobs(path.getStringList("Jobs")); + + if (path.isString("Days")) { + sched.setDays(Arrays.asList(path.getString("Days"))); + } else { + sched.setDays(path.getStringList("Days")); + } + + if (path.isString("Jobs")) { + sched.setJobs(Arrays.asList(path.getString("Jobs"))); + } else { + sched.setJobs(path.getStringList("Jobs")); + } + sched.setFrom(Integer.parseInt(path.getString("From").replace(":", ""))); sched.setUntil(Integer.parseInt(path.getString("Until").replace(":", ""))); @@ -203,6 +228,6 @@ public class ScheduleManager { } if (!BOOSTSCHEDULE.isEmpty()) - Jobs.consoleMsg("&e[Jobs] Loaded " + BOOSTSCHEDULE.size() + " schedulers!"); + Jobs.consoleMsg("&eLoaded " + BOOSTSCHEDULE.size() + " schedulers!"); } } diff --git a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java index 084e2ad8..3f6c8868 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java @@ -88,7 +88,7 @@ public class HookManager { private static boolean setWorldGuard() { if (JobsHook.WorldGuard.isEnabled()) { worldGuardManager = new WorldGuardManager(); - Jobs.consoleMsg("&e[Jobs] WorldGuard detected."); + Jobs.consoleMsg("&eWorldGuard detected."); return true; } @@ -102,12 +102,12 @@ public class HookManager { try { Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper"); MythicManager = new MythicMobs4(PLUGIN); - Jobs.consoleMsg("&e[Jobs] MythicMobs 4.x detected."); + Jobs.consoleMsg("&eMythicMobs 4.x detected."); } catch (ClassNotFoundException ex) { try { Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper"); MythicManager = new MythicMobs5(PLUGIN); - Jobs.consoleMsg("&e[Jobs] MythicMobs 5.x detected."); + Jobs.consoleMsg("&eMythicMobs 5.x detected."); } catch (ClassNotFoundException e) { Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+"); } @@ -118,17 +118,17 @@ public class HookManager { try { Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType"); pm.registerEvents(new McMMO2_X_listener(), PLUGIN); - Jobs.consoleMsg("&e[Jobs] Registered McMMO 2.x listener"); + Jobs.consoleMsg("&eRegistered McMMO 2.x listener"); } catch (ClassNotFoundException e) { pm.registerEvents(new McMMO1_X_listener(), PLUGIN); - Jobs.consoleMsg("&e[Jobs] Registered McMMO 1.x listener"); + Jobs.consoleMsg("&eRegistered McMMO 1.x listener"); } } private static void setMyPetManager() { if (JobsHook.MyPet.isEnabled()) { myPetManager = new MyPetManager(); - Jobs.consoleMsg("&e[Jobs] MyPet detected."); + Jobs.consoleMsg("&eMyPet detected."); } } diff --git a/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java b/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java index 5bc5e3ac..e73576cf 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java @@ -100,13 +100,13 @@ public class McMMOManager { mcMMOPresent = false; } if (!mcMMOPresent) - Jobs.consoleMsg("&e[Jobs] &6mcMMO was found - &cBut your McMMO version is outdated, please update for full support."); + Jobs.consoleMsg("&6mcMMO was found - &cBut your McMMO version is outdated, please update for full support."); // Still enabling event listener for repair return true; } - Jobs.consoleMsg("&e[Jobs] &6mcMMO" + McMMO.getDescription().getVersion() + " was found - Enabling capabilities."); + Jobs.consoleMsg("&6mcMMO" + McMMO.getDescription().getVersion() + " was found - Enabling capabilities."); return true; }