From 3af38fdaa490541e6f75c0d9183cd47522d36ab8 Mon Sep 17 00:00:00 2001 From: Zrips Date: Sun, 11 Feb 2018 13:30:19 +0200 Subject: [PATCH] We dont need separate option for scheduler enable option --- pom.xml | 2 +- src/main/java/com/gamingmesh/jobs/Jobs.java | 11 +++----- .../jobs/config/GeneralConfigManager.java | 6 ++--- .../jobs/config/ScheduleManager.java | 26 +++++++++++-------- src/main/resources/plugin.yml | 2 +- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index a404b831..2034de70 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Jobs jobs - 4.3.1 + 4.4.0 Jobs http://maven.apache.org diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index f3147802..da9ae259 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -618,8 +618,7 @@ public class Jobs extends JavaPlugin { // Schedule Jobs.getScheduleManager().load(); - if (GconfigManager.useGlobalBoostScheduler) - Jobs.getScheduleManager().start(); + Jobs.getScheduleManager().start(); permissionManager = new PermissionManager(); } @@ -782,7 +781,6 @@ public class Jobs extends JavaPlugin { YmlMaker jobShopItems = new YmlMaker(this, "shopItems.yml"); jobShopItems.saveDefaultConfig(); - setPermissionHandler(new PermissionHandler(this)); setJobsClassloader(); setPlayerManager(); @@ -834,7 +832,7 @@ public class Jobs extends JavaPlugin { getExplore().load(); FurnaceBrewingHandling.load(); - + String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Plugin has been enabled succesfully."); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); console.sendMessage(message); @@ -842,7 +840,6 @@ public class Jobs extends JavaPlugin { cManager.fillCommands(); - } catch (Exception e) { System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled."); e.printStackTrace(); @@ -856,9 +853,9 @@ public class Jobs extends JavaPlugin { shopManager.CloseInventories(); dao.saveExplore(); dao.saveBlockProtection(); - + FurnaceBrewingHandling.save(); - + Jobs.shutdown(); String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &2Plugin has been disabled succesfully."); ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 1ba20534..3ceb290f 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -101,7 +101,7 @@ public class GeneralConfigManager { public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat, EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, - useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; + JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; private int JobsGUIRows, JobsGUIBackButton, JobsGUIStartPosition, @@ -913,8 +913,8 @@ public class GeneralConfigManager { tmat = Material.getMaterial(c.get("JobsGUI.Filler.Material", "STAINED_GLASS_PANE")); guiFiller = new ItemStack(tmat == null ? Material.STAINED_GLASS_PANE : tmat, 1, (byte) c.get("JobsGUI.Filler.Data", 15)); - c.getW().addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost"); - useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false); +// c.getW().addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost"); +// useGlobalBoostScheduler = c.get("Schedule.Boost.Enable", false); try { c.getW().save(f); diff --git a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java index b4f8f9a5..cf630c71 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java @@ -20,6 +20,7 @@ import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Schedule; import com.gamingmesh.jobs.stuff.ChatColor; +import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.TimeManage; public class ScheduleManager { @@ -32,6 +33,8 @@ public class ScheduleManager { } public void start() { + if (Jobs.getGCManager().BoostSchedule.isEmpty()) + return; autoTimerBukkitId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, autoTimer, 20, 30 * 20L); } @@ -55,7 +58,7 @@ public class ScheduleManager { } private boolean scheduler() { - if (Jobs.getGCManager().BoostSchedule.isEmpty() || !Jobs.getGCManager().useGlobalBoostScheduler) + if (Jobs.getGCManager().BoostSchedule.isEmpty()) return false; DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); @@ -85,11 +88,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; - } + 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")); @@ -109,11 +112,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; - } + 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")); @@ -232,6 +235,7 @@ public class ScheduleManager { sched.setBoost(CurrencyType.MONEY, path.getDouble("Money", 0D)); if (path.contains("Points") && path.isDouble("Points")) sched.setBoost(CurrencyType.POINTS, path.getDouble("Points", 0D)); + Jobs.getGCManager().BoostSchedule.add(sched); } Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + Jobs.getGCManager().BoostSchedule.size() + " schedulers!"); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6b131389..0e3a09cd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.Jobs -version: 4.3.1 +version: 4.4.0 website: https://www.spigotmc.org/resources/jobs-reborn.4216/ author: phrstbrn softdepend: [Vault, iConomy, MythicMobs, McMMO, WorldGuard, MyPet]