diff --git a/com/gamingmesh/jobs/HookEconomyTask.java b/com/gamingmesh/jobs/HookEconomyTask.java index 027b3c9f..a656a8ec 100644 --- a/com/gamingmesh/jobs/HookEconomyTask.java +++ b/com/gamingmesh/jobs/HookEconomyTask.java @@ -30,9 +30,9 @@ import com.gamingmesh.jobs.economy.BlackholeEconomy; import com.gamingmesh.jobs.economy.VaultEconomy; public class HookEconomyTask implements Runnable { - private JobsPlugin plugin; + private Jobs plugin; - public HookEconomyTask(JobsPlugin plugin) { + public HookEconomyTask(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index 1ea7dfe3..2a15dbec 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -20,6 +20,7 @@ package com.gamingmesh.jobs; import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -29,8 +30,10 @@ import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + import com.gamingmesh.jobs.Gui.GuiManager; import com.gamingmesh.jobs.Signs.SignUtil; import com.gamingmesh.jobs.api.JobsExpGainEvent; @@ -47,6 +50,7 @@ import com.gamingmesh.jobs.config.ScboardManager; import com.gamingmesh.jobs.config.ScheduleManager; import com.gamingmesh.jobs.config.ShopManager; import com.gamingmesh.jobs.config.TitleManager; +import com.gamingmesh.jobs.config.YmlMaker; import com.gamingmesh.jobs.container.ActionInfo; import com.gamingmesh.jobs.container.BoostMultiplier; import com.gamingmesh.jobs.container.Job; @@ -61,18 +65,20 @@ import com.gamingmesh.jobs.economy.BufferedPayment; import com.gamingmesh.jobs.economy.Economy; import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.i18n.Language; +import com.gamingmesh.jobs.listeners.JobsListener; +import com.gamingmesh.jobs.listeners.JobsPaymentListener; import com.gamingmesh.jobs.listeners.McMMOlistener; import com.gamingmesh.jobs.listeners.MythicMobsListener; import com.gamingmesh.jobs.listeners.PistonProtectionListener; import com.gamingmesh.jobs.stuff.ActionBar; import com.gamingmesh.jobs.stuff.JobsClassLoader; import com.gamingmesh.jobs.stuff.Loging; +import com.gamingmesh.jobs.stuff.TabComplete; import com.gamingmesh.jobs.tasks.BufferedPaymentThread; import com.gamingmesh.jobs.tasks.DatabaseSaveThread; -public class Jobs { - public static Jobs instance = new Jobs(); -// public static JobsPlugin plugin = new JobsPlugin(); +public class Jobs extends JavaPlugin { +// public static Jobs plugin = new Jobs(); private static PlayerManager pManager = null; private static JobsCommands cManager = null; private static Language lManager = null; @@ -100,7 +106,7 @@ public class Jobs { private static Logger pLogger; private static File dataFolder; - private static JobsClassLoader classLoader = new JobsClassLoader(instance); + private static JobsClassLoader classLoader; private static JobsDAO dao = null; private static List jobs = null; private static Job noneJob = null; @@ -124,31 +130,31 @@ public class Jobs { private static ActionBar actionbar; - public static void setMcMMOlistener(JobsPlugin plugin) { - McMMOlistener = new McMMOlistener(plugin); + public void setMcMMOlistener() { + McMMOlistener = new McMMOlistener(this); } public static McMMOlistener getMcMMOlistener() { return McMMOlistener; } - public static void setPistonProtectionListener(JobsPlugin plugin) { - PistonProtectionListener = new PistonProtectionListener(plugin); + public void setPistonProtectionListener() { + PistonProtectionListener = new PistonProtectionListener(this); } public static PistonProtectionListener getPistonProtectionListener() { return PistonProtectionListener; } - public static void setMythicManager(JobsPlugin plugin) { - MythicManager = new MythicMobsListener(plugin); + public void setMythicManager() { + MythicManager = new MythicMobsListener(this); } public static MythicMobsListener getMythicManager() { return MythicManager; } - public static void setLoging() { + public void setLoging() { loging = new Loging(); } @@ -156,7 +162,7 @@ public class Jobs { return loging; } - public static void setShopManager(JobsPlugin plugin) { + public static void setShopManager(Jobs plugin) { shopManager = new ShopManager(plugin); } @@ -164,24 +170,24 @@ public class Jobs { return shopManager; } - public static void setConfigManager(JobsPlugin plugin) { - configManager = new ConfigManager(plugin); + public void setConfigManager() { + configManager = new ConfigManager(this); } public static ConfigManager getConfigManager() { return configManager; } - public static void setGCManager(JobsPlugin plugin) { - GconfigManager = new GeneralConfigManager(plugin); + public void setGCManager() { + GconfigManager = new GeneralConfigManager(this); } public static GeneralConfigManager getGCManager() { return GconfigManager; } - public static void setActionBar(ActionBar bar) { - actionbar = bar; + public void setActionBar() { + actionbar = new ActionBar(); } public static ActionBar getActionBar() { @@ -204,11 +210,11 @@ public class Jobs { return pManager; } - public static void setPlayerManager(JobsPlugin jobsPlugin) { - pManager = new PlayerManager(jobsPlugin); + public void setPlayerManager() { + pManager = new PlayerManager(this); } - public static void setRestrictedBlockManager(JobsPlugin plugin) { + public static void setRestrictedBlockManager(Jobs plugin) { RBManager = new RestrictedBlockManager(plugin); } @@ -216,7 +222,7 @@ public class Jobs { return RBManager; } - public static void setRestrictedAreaManager(JobsPlugin plugin) { + public static void setRestrictedAreaManager(Jobs plugin) { RAManager = new RestrictedAreaManager(plugin); } @@ -224,7 +230,7 @@ public class Jobs { return RAManager; } - public static void setTitleManager(JobsPlugin plugin) { + public static void setTitleManager(Jobs plugin) { titleManager = new TitleManager(plugin); } @@ -232,8 +238,8 @@ public class Jobs { return titleManager; } - public static void setBBManager(JobsPlugin plugin) { - BBManager = new BossBarManager(plugin); + public void setBBManager() { + BBManager = new BossBarManager(this); } public static BossBarManager getBBManager() { @@ -256,7 +262,7 @@ public class Jobs { return scheduleManager; } - public static void setScheduleManager(JobsPlugin plugin) { + public static void setScheduleManager(Jobs plugin) { scheduleManager = new ScheduleManager(plugin); } @@ -264,7 +270,7 @@ public class Jobs { return NameTranslatorManager; } - public static void setNameTranslatorManager(JobsPlugin plugin) { + public static void setNameTranslatorManager(Jobs plugin) { NameTranslatorManager = new NameTranslatorManager(plugin); } @@ -272,7 +278,7 @@ public class Jobs { return GUIManager; } - public static void setGUIManager() { + public void setGUIManager() { GUIManager = new GuiManager(); } @@ -280,15 +286,15 @@ public class Jobs { return cManager; } - public static void setCommandManager(JobsPlugin plugin) { - cManager = new JobsCommands(plugin); + public void setCommandManager() { + cManager = new JobsCommands(this); } public static ExploreManager getExplore() { return exploreManager; } - public static void setExplore() { + public void setExplore() { exploreManager = new ExploreManager(); } @@ -300,8 +306,8 @@ public class Jobs { return scboardManager; } - public static void setScboard(JobsPlugin plugin) { - scboardManager = new ScboardManager(plugin); + public void setScboard() { + scboardManager = new ScboardManager(this); } /** @@ -312,7 +318,7 @@ public class Jobs { return signManager; } - public static void setSignUtil(JobsPlugin plugin) { + public static void setSignUtil(Jobs plugin) { signManager = new SignUtil(plugin); } @@ -324,22 +330,22 @@ public class Jobs { return lManager; } - public static void setLanguage(JobsPlugin plugin) { - lManager = new Language(plugin); + public void setLanguage() { + lManager = new Language(this); } public static LanguageManager getLanguageManager() { return lmManager; } - public static void setLanguageManager(JobsPlugin plugin) { + public static void setLanguageManager(Jobs plugin) { lmManager = new LanguageManager(plugin); } /** * Sets the plugin logger */ - public static void setPluginLogger(Logger logger) { + public void setPluginLogger(Logger logger) { pLogger = logger; } @@ -355,7 +361,7 @@ public class Jobs { * Sets the data folder * @param dir - the data folder */ - public static void setDataFolder(File dir) { + public void setDataFolder(File dir) { dataFolder = dir; } @@ -363,7 +369,7 @@ public class Jobs { * Retrieves the data folder * @return data folder */ - public static File getDataFolder() { + public static File getFolder() { return dataFolder; } @@ -432,40 +438,35 @@ public class Jobs { * Executes startup * @throws IOException */ - public static void startup(JobsPlugin plugin) { + public void startup() { try { reload(); } catch (IOException e1) { e1.printStackTrace(); } - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - @Override - public void run() { - int i = 0; - int y = 0; - int total = Jobs.getPlayerManager().getPlayerMap().size(); - long time = System.currentTimeMillis(); - for (Entry one : Jobs.getPlayerManager().getPlayerMap().entrySet()) { - try { - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(one); - if (jPlayer == null) - continue; - Jobs.getPlayerManager().getPlayersCache().put(one.getValue().getName().toLowerCase(), jPlayer); - } catch (Exception e) { - } - i++; - y++; - if (y >= 1000) { - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + i + "/" + total + " players data"); - y = 0; - } - } - Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Preloaded " + i + " players data in " + ((int) (((System.currentTimeMillis() - time) - / 1000d) * 100) / 100D)); - - return; + int i = 0; + int y = 0; + int total = Jobs.getPlayerManager().getPlayerMap().size(); + long time = System.currentTimeMillis(); + for (Entry one : Jobs.getPlayerManager().getPlayerMap().entrySet()) { + try { + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(one); + if (jPlayer == null) + continue; + Jobs.getPlayerManager().getPlayersCache().put(one.getValue().getName().toLowerCase(), jPlayer); + } catch (Exception e) { } - }); + i++; + y++; + if (y >= 1000) { + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Loaded " + i + "/" + total + " players data"); + y = 0; + } + } + dao.getMap().clear(); + Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[Jobs] Preloaded " + i + " players data in " + ((int) (((System.currentTimeMillis() - time) + / 1000d) * 100) / 100D)); + // add all online players for (Player online : Bukkit.getServer().getOnlinePlayers()) { Jobs.getPlayerManager().playerJoin(online); @@ -491,8 +492,8 @@ public class Jobs { dao.closeConnections(); } - Jobs.getGCManager().reload(); - Jobs.getLanguage().reload(); + GconfigManager.reload(); + lManager.reload(); Jobs.getConfigManager().reload(); usedSlots.clear(); for (Job job : jobs) { @@ -502,20 +503,20 @@ public class Jobs { permissionHandler.registerPermissions(); // set the system to auto save - if (Jobs.getGCManager().getSavePeriod() > 0) { - saveTask = new DatabaseSaveThread(Jobs.getGCManager().getSavePeriod()); + if (GconfigManager.getSavePeriod() > 0) { + saveTask = new DatabaseSaveThread(GconfigManager.getSavePeriod()); saveTask.start(); } // schedule payouts to buffered payments - paymentThread = new BufferedPaymentThread(Jobs.getGCManager().getEconomyBatchDelay()); + paymentThread = new BufferedPaymentThread(GconfigManager.getEconomyBatchDelay()); paymentThread.start(); Jobs.getJobsDAO().loadPlayerData(); // Schedule Jobs.getScheduleManager().load(); - if (Jobs.getGCManager().useGlobalBoostScheduler) + if (GconfigManager.useGlobalBoostScheduler) Jobs.getScheduleManager().scheduler(); } @@ -543,10 +544,10 @@ public class Jobs { if (dao != null) { dao.closeConnections(); } - if (Jobs.getGCManager().storageMethod.equals("mysql")) - Jobs.getGCManager().startSqlite(); + if (GconfigManager.storageMethod.equals("mysql")) + GconfigManager.startSqlite(); else - Jobs.getGCManager().startMysql(); + GconfigManager.startMysql(); pManager.reload(); } @@ -587,11 +588,15 @@ public class Jobs { return classLoader; } + public void setJobsClassloader() { + classLoader = new JobsClassLoader(this); + } + /** * Sets the permission handler * @param h - the permission handler */ - public static void setPermissionHandler(PermissionHandler h) { + public void setPermissionHandler(PermissionHandler h) { permissionHandler = h; } @@ -607,7 +612,7 @@ public class Jobs { * Sets the economy handler * @param eco - the economy handler */ - public static void setEconomy(JobsPlugin plugin, Economy eco) { + public static void setEconomy(Jobs plugin, Economy eco) { economy = new BufferedEconomy(plugin, eco); } @@ -619,127 +624,113 @@ public class Jobs { return economy; } - public static boolean isUnderMoneyLimit(OfflinePlayer player, Double amount) { + @Override + public void onEnable() { - if (player == null) - return true; + String packageName = getServer().getClass().getPackage().getName(); + String[] packageSplit = packageName.split("\\."); + String version = packageSplit[packageSplit.length - 1].substring(0, packageSplit[packageSplit.length - 1].length() - 3); + try { + Class nmsClass; + nmsClass = Class.forName("com.gamingmesh.jobs.nmsUtil." + version); + if (NMS.class.isAssignableFrom(nmsClass)) { + setNms((NMS) nmsClass.getConstructor().newInstance()); + } else { + System.out.println("Something went wrong, please note down version and contact author v:" + version); + this.setEnabled(false); + } + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException + | SecurityException e) { + System.out.println("Your server version is not compatible with this plugins version! Plugin will be disabled: " + version); + this.setEnabled(false); + e.printStackTrace(); + return; + } - if (amount == 0) - return true; + try { + setActionBar(); + YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml"); + jobConfig.saveDefaultConfig(); - String playername = player.getName(); + YmlMaker jobSigns = new YmlMaker(this, "Signs.yml"); + jobSigns.saveDefaultConfig(); - if (!Jobs.getGCManager().MoneyLimitUse) - return true; + YmlMaker jobSchedule = new YmlMaker(this, "schedule.yml"); + jobSchedule.saveDefaultConfig(); - if (!paymentLimit.containsKey(playername)) { - PaymentData data = new PaymentData(System.currentTimeMillis(), amount, 0.0, 0.0, 0L, false); - //data.AddNewAmount(amount); - paymentLimit.put(playername, data); - } else { - PaymentData data = paymentLimit.get(playername); - JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player); - if (data.IsReachedMoneyLimit(Jobs.getGCManager().MoneyTimeLimit, JPlayer.getMoneyLimit())) { - if (player.isOnline() && !data.Informed && !data.isReseted()) { - ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedlimit")); - ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedlimit2")); - data.Setinformed(); - } - if (data.IsAnnounceTime(Jobs.getGCManager().MoneyAnnouncmentDelay) && player.isOnline()) { - String message = Jobs.getLanguage().getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(Jobs - .getGCManager().MoneyTimeLimit)); - message = message.replace("%min%", String.valueOf(data.GetLeftMin(Jobs.getGCManager().MoneyTimeLimit))); - message = message.replace("%sec%", String.valueOf(data.GetLeftsec(Jobs.getGCManager().MoneyTimeLimit))); - Jobs.getActionBar().send(((Player) player), ChatColor.RED + message); - } - if (data.isReseted()) - data.setReseted(false); - return false; + YmlMaker jobShopItems = new YmlMaker(this, "shopItems.yml"); + jobShopItems.saveDefaultConfig(); + + setPermissionHandler(new PermissionHandler(this)); + setJobsClassloader(); + setPlayerManager(); + setScboard(); + setLanguage(); + setGUIManager(); + setExplore(); + setBBManager(); + setPluginLogger(getLogger()); + setDataFolder(getDataFolder()); + setLoging(); + setGCManager(); + setConfigManager(); + setCommandManager(); + + getCommand("jobs").setExecutor(cManager); + this.getCommand("jobs").setTabCompleter(new TabComplete()); + + startup(); + + // register the listeners + getServer().getPluginManager().registerEvents(new JobsListener(this), this); + getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this); + + setMcMMOlistener(); + if (McMMOlistener.CheckmcMMO()) { + getServer().getPluginManager().registerEvents(McMMOlistener, this); } - data.AddAmount(amount); - paymentLimit.put(playername, data); + setMythicManager(); + if (MythicManager.Check() && GconfigManager.MythicMobsEnabled) { + getServer().getPluginManager().registerEvents(MythicManager, this); + } + + setPistonProtectionListener(); + if (GconfigManager.useBlockProtection) { + getServer().getPluginManager().registerEvents(PistonProtectionListener, this); + } + + // register economy + Bukkit.getScheduler().runTask(this, new HookEconomyTask(this)); + + // all loaded properly. + + scheduleManager.DateUpdater(); + + String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Plugin has been enabled succesfully."); + ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); + console.sendMessage(message); + lManager.reload(); + + dao.loadExplore(); + + cManager.fillCommands(); + } catch (Exception e) { + System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled."); + this.setEnabled(false); + e.printStackTrace(); } - return true; } - public static boolean isUnderExpLimit(final OfflinePlayer player, Double amount) { - if (player == null) - return false; - - String playername = player.getName(); - - if (!Jobs.getGCManager().ExpLimitUse) - return true; - - if (!ExpLimit.containsKey(playername)) { - PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, 0.0, amount, 0L, false); - //data.AddNewAmount(amount); - ExpLimit.put(playername, data); - } else { - PaymentData data = ExpLimit.get(playername); - JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player); - if (data.IsReachedExpLimit(Jobs.getGCManager().ExpTimeLimit, JPlayer.getExpLimit())) { - if (player.isOnline() && !data.Informed && !data.isReseted()) { - ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedExplimit")); - ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedExplimit2")); - data.Setinformed(); - } - if (data.IsAnnounceTime(Jobs.getGCManager().ExpAnnouncmentDelay) && player.isOnline()) { - String message = Jobs.getLanguage().getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(Jobs.getGCManager().ExpTimeLimit)); - message = message.replace("%min%", String.valueOf(data.GetLeftMin(Jobs.getGCManager().ExpTimeLimit))); - message = message.replace("%sec%", String.valueOf(data.GetLeftsec(Jobs.getGCManager().ExpTimeLimit))); - Jobs.getActionBar().send(((Player) player), ChatColor.RED + message); - } - if (data.isReseted()) - data.setReseted(false); - return false; - } - data.AddExpAmount(amount); - ExpLimit.put(playername, data); - } - return true; - } - - public static boolean isUnderPointLimit(final OfflinePlayer player, Double amount) { - if (player == null) - return false; - - if (amount == 0) - return true; - - String playername = player.getName(); - - if (!Jobs.getGCManager().PointLimitUse) - return true; - - if (!PointLimit.containsKey(playername)) { - PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, amount, 0.0, 0L, false); - //data.AddNewAmount(amount); - PointLimit.put(playername, data); - } else { - PaymentData data = PointLimit.get(playername); - JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayerOffline(player); - if (data.IsReachedPointLimit(Jobs.getGCManager().PointTimeLimit, JPlayer.getPointLimit())) { - if (player.isOnline() && !data.Informed && !data.isReseted()) { - ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedPointlimit")); - ((Player) player).sendMessage(Jobs.getLanguage().getMessage("command.limit.output.reachedPointlimit2")); - data.Setinformed(); - } - if (data.IsAnnounceTime(Jobs.getGCManager().PointAnnouncmentDelay) && player.isOnline()) { - String message = Jobs.getLanguage().getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(Jobs.getGCManager().PointTimeLimit)); - message = message.replace("%min%", String.valueOf(data.GetLeftMin(Jobs.getGCManager().PointTimeLimit))); - message = message.replace("%sec%", String.valueOf(data.GetLeftsec(Jobs.getGCManager().PointTimeLimit))); - Jobs.getActionBar().send(((Player) player), ChatColor.RED + message); - } - if (data.isReseted()) - data.setReseted(false); - return false; - } - data.AddPoints(amount); - PointLimit.put(playername, data); - } - return true; + @Override + public void onDisable() { + GUIManager.CloseInventories(); + shopManager.CloseInventories(); + dao.saveExplore(); + Jobs.shutdown(); + String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &2Plugin has been disabled succesfully."); + ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); + console.sendMessage(message); } /** @@ -760,11 +751,9 @@ public class Jobs { // no job if (numjobs == 0) { - Job jobNone = Jobs.getNoneJob(); - Player dude = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); - if (jobNone != null) { - JobInfo jobinfo = jobNone.getJobInfo(info, 1); + if (noneJob != null) { + JobInfo jobinfo = noneJob.getJobInfo(info, 1); if (jobinfo == null) return; @@ -776,15 +765,15 @@ public class Jobs { // jPlayer - BoostMultiplier FinalBoost = Jobs.getPlayerManager().getFinalBonus(jPlayer, Jobs.getNoneJob()); + BoostMultiplier FinalBoost = pManager.getFinalBonus(jPlayer, Jobs.getNoneJob()); // Calculate income Double amount = 0D; if (income != 0D) { amount = income + (income * FinalBoost.getMoneyBoost() / 100); - if (Jobs.getGCManager().useMinimumOveralPayment && income > 0) { - double maxLimit = income * Jobs.getGCManager().MinimumOveralPaymentLimit; + if (GconfigManager.useMinimumOveralPayment && income > 0) { + double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit; if (amount < maxLimit) { amount = maxLimit; } @@ -796,23 +785,23 @@ public class Jobs { Double pointAmount = 0D; if (points != 0D) { pointAmount = points + (points * FinalBoost.getPointsBoost() / 100); - if (Jobs.getGCManager().useMinimumOveralPoints && points > 0) { - double maxLimit = points * Jobs.getGCManager().MinimumOveralPaymentLimit; + if (GconfigManager.useMinimumOveralPoints && points > 0) { + double maxLimit = points * GconfigManager.MinimumOveralPaymentLimit; if (pointAmount < maxLimit) { pointAmount = maxLimit; } } } - if (!isUnderMoneyLimit(dude, amount)) { + if (!isUnderMoneyLimit(jPlayer, amount)) { amount = 0D; - if (Jobs.getGCManager().MoneyStopPoint) + if (GconfigManager.MoneyStopPoint) pointAmount = 0D; } - if (!isUnderPointLimit(dude, pointAmount)) { + if (!isUnderPointLimit(jPlayer, pointAmount)) { pointAmount = 0D; - if (Jobs.getGCManager().PointStopMoney) + if (GconfigManager.PointStopMoney) amount = 0D; } if (amount == 0D && pointAmount == 0D) @@ -823,8 +812,8 @@ public class Jobs { Jobs.getEconomy().pay(jPlayer, amount, pointAmount, 0.0); - if (Jobs.getGCManager().LoggingUse) - Jobs.getLoging().recordToLog(jPlayer, info, amount, 0); + if (GconfigManager.LoggingUse) + loging.recordToLog(jPlayer, info, amount, 0); } } } else { @@ -842,7 +831,7 @@ public class Jobs { if (income == 0D && points == 0D && exp == 0D) continue; - if (Jobs.getGCManager().addXpPlayer()) { + if (GconfigManager.addXpPlayer()) { Player player = Bukkit.getServer().getPlayer(jPlayer.getPlayerUUID()); if (player != null) { /* @@ -871,15 +860,15 @@ public class Jobs { FinalBoost.getPointsBoost() + multiplier, FinalBoost.getExpBoost() + multiplier); - OfflinePlayer dude = jPlayer.getPlayer(); +// OfflinePlayer dude = jPlayer.getPlayer(); // Calculate income Double amount = 0D; if (income != 0D) { amount = income + (income * FinalBoost.getMoneyBoost() / 100); - if (Jobs.getGCManager().useMinimumOveralPayment && income > 0) { - double maxLimit = income * Jobs.getGCManager().MinimumOveralPaymentLimit; + if (GconfigManager.useMinimumOveralPayment && income > 0) { + double maxLimit = income * GconfigManager.MinimumOveralPaymentLimit; if (amount < maxLimit) { amount = maxLimit; } @@ -891,8 +880,8 @@ public class Jobs { Double pointAmount = 0D; if (points != 0D) { pointAmount = points + (points * FinalBoost.getPointsBoost() / 100); - if (Jobs.getGCManager().useMinimumOveralPoints && points > 0) { - double maxLimit = points * Jobs.getGCManager().MinimumOveralPaymentLimit; + if (GconfigManager.useMinimumOveralPoints && points > 0) { + double maxLimit = points * GconfigManager.MinimumOveralPaymentLimit; if (pointAmount < maxLimit) { pointAmount = maxLimit; } @@ -902,34 +891,34 @@ public class Jobs { // Calculate exp double expAmount = exp + (exp * FinalBoost.getExpBoost() / 100); - if (Jobs.getGCManager().useMinimumOveralPayment && exp > 0) { - double maxLimit = exp * Jobs.getGCManager().MinimumOveralPaymentLimit; + if (GconfigManager.useMinimumOveralPayment && exp > 0) { + double maxLimit = exp * GconfigManager.MinimumOveralPaymentLimit; if (exp < maxLimit) { exp = maxLimit; } } - if (!isUnderMoneyLimit(dude, amount)) { + if (!isUnderMoneyLimit(jPlayer, amount)) { amount = 0D; - if (Jobs.getGCManager().MoneyStopExp) + if (GconfigManager.MoneyStopExp) expAmount = 0D; - if (Jobs.getGCManager().MoneyStopPoint) + if (GconfigManager.MoneyStopPoint) pointAmount = 0D; } - if (!isUnderExpLimit(dude, expAmount)) { + if (!isUnderExpLimit(jPlayer, expAmount)) { expAmount = 0D; - if (Jobs.getGCManager().ExpStopMoney) + if (GconfigManager.ExpStopMoney) amount = 0D; - if (Jobs.getGCManager().ExpStopPoint) + if (GconfigManager.ExpStopPoint) pointAmount = 0D; } - if (!isUnderPointLimit(dude, pointAmount)) { + if (!isUnderPointLimit(jPlayer, pointAmount)) { pointAmount = 0D; - if (Jobs.getGCManager().PointStopMoney) + if (GconfigManager.PointStopMoney) amount = 0D; - if (Jobs.getGCManager().PointStopExp) + if (GconfigManager.PointStopExp) expAmount = 0D; } @@ -938,9 +927,9 @@ public class Jobs { try { if (expAmount != 0D) - if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction) { + if (GconfigManager.BossBarEnabled && GconfigManager.BossBarShowOnEachAction) { Jobs.getBBManager().ShowJobProgression(jPlayer, prog); - } else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction) + } else if (GconfigManager.BossBarEnabled && !GconfigManager.BossBarShowOnEachAction) jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); } catch (Exception e) { Bukkit.getConsoleSender().sendMessage("[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it."); @@ -955,15 +944,16 @@ public class Jobs { else expAmount = JobsExpGainEvent.getExp(); - Jobs.getEconomy().pay(jPlayer, amount, pointAmount, expAmount); + economy.pay(jPlayer, amount, pointAmount, expAmount); int oldLevel = prog.getLevel(); - if (Jobs.getGCManager().LoggingUse) - Jobs.getLoging().recordToLog(jPlayer, info, amount, expAmount); + if (GconfigManager.LoggingUse) + loging.recordToLog(jPlayer, info, amount, expAmount); if (prog.addExperience(expAmount)) - Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel); + pManager.performLevelUp(jPlayer, prog.getJob(), oldLevel); + FastPayment.clear(); FastPayment.put(jPlayer.getUserName(), new FastPayment(jPlayer, info, new BufferedPayment(jPlayer.getPlayer(), amount, points, exp), prog.getJob())); } } @@ -980,16 +970,145 @@ public class Jobs { else expAmount = JobsExpGainEvent.getExp(); - Jobs.getEconomy().pay(jPlayer, payment.getAmount(), payment.getPoints(), expAmount); + economy.pay(jPlayer, payment.getAmount(), payment.getPoints(), expAmount); JobProgression prog = jPlayer.getJobProgression(job); int oldLevel = prog.getLevel(); - if (Jobs.getGCManager().LoggingUse) - Jobs.getLoging().recordToLog(jPlayer, info, payment.getAmount(), expAmount); + if (GconfigManager.LoggingUse) + loging.recordToLog(jPlayer, info, payment.getAmount(), expAmount); if (prog.addExperience(expAmount)) - Jobs.getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel); + pManager.performLevelUp(jPlayer, prog.getJob(), oldLevel); } + + public static boolean isUnderMoneyLimit(JobsPlayer jPlayer, Double amount) { + + Player player = jPlayer.getPlayer(); + + if (player == null) + return true; + + if (amount == 0) + return true; + + String playername = player.getName(); + + if (!GconfigManager.MoneyLimitUse) + return true; + + if (!paymentLimit.containsKey(playername)) { + PaymentData data = new PaymentData(System.currentTimeMillis(), amount, 0.0, 0.0, 0L, false); + //data.AddNewAmount(amount); + paymentLimit.put(playername, data); + } else { + PaymentData data = paymentLimit.get(playername); + if (data.IsReachedMoneyLimit(GconfigManager.MoneyTimeLimit, jPlayer.getMoneyLimit())) { + if (player.isOnline() && !data.Informed && !data.isReseted()) { + player.sendMessage(lManager.getMessage("command.limit.output.reachedlimit")); + player.sendMessage(lManager.getMessage("command.limit.output.reachedlimit2")); + data.Setinformed(); + } + if (data.IsAnnounceTime(GconfigManager.MoneyAnnouncmentDelay) && player.isOnline()) { + String message = lManager.getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(GconfigManager.MoneyTimeLimit)); + message = message.replace("%min%", String.valueOf(data.GetLeftMin(GconfigManager.MoneyTimeLimit))); + message = message.replace("%sec%", String.valueOf(data.GetLeftsec(GconfigManager.MoneyTimeLimit))); + Jobs.getActionBar().send((player), ChatColor.RED + message); + } + if (data.isReseted()) + data.setReseted(false); + return false; + } + + data.AddAmount(amount); + paymentLimit.put(playername, data); + } + return true; + } + + public static boolean isUnderExpLimit(JobsPlayer jPlayer, Double amount) { + Player player = jPlayer.getPlayer(); + + if (player == null) + return true; + + if (amount == 0) + return true; + + String playername = player.getName(); + + if (!GconfigManager.ExpLimitUse) + return true; + + if (!ExpLimit.containsKey(playername)) { + PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, 0.0, amount, 0L, false); + //data.AddNewAmount(amount); + ExpLimit.put(playername, data); + } else { + PaymentData data = ExpLimit.get(playername); + if (data.IsReachedExpLimit(GconfigManager.ExpTimeLimit, jPlayer.getExpLimit())) { + if (player.isOnline() && !data.Informed && !data.isReseted()) { + player.sendMessage(lManager.getMessage("command.limit.output.reachedExplimit")); + player.sendMessage(lManager.getMessage("command.limit.output.reachedExplimit2")); + data.Setinformed(); + } + if (data.IsAnnounceTime(GconfigManager.ExpAnnouncmentDelay) && player.isOnline()) { + String message = lManager.getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(GconfigManager.ExpTimeLimit)); + message = message.replace("%min%", String.valueOf(data.GetLeftMin(GconfigManager.ExpTimeLimit))); + message = message.replace("%sec%", String.valueOf(data.GetLeftsec(GconfigManager.ExpTimeLimit))); + Jobs.getActionBar().send((player), ChatColor.RED + message); + } + if (data.isReseted()) + data.setReseted(false); + return false; + } + data.AddExpAmount(amount); + ExpLimit.put(playername, data); + } + return true; + } + + public static boolean isUnderPointLimit(JobsPlayer jPlayer, Double amount) { + Player player = jPlayer.getPlayer(); + + if (player == null) + return true; + + if (amount == 0) + return true; + + String playername = player.getName(); + + if (!GconfigManager.PointLimitUse) + return true; + + if (!PointLimit.containsKey(playername)) { + PaymentData data = new PaymentData(System.currentTimeMillis(), 0.0, amount, 0.0, 0L, false); + //data.AddNewAmount(amount); + PointLimit.put(playername, data); + } else { + PaymentData data = PointLimit.get(playername); + if (data.IsReachedPointLimit(GconfigManager.PointTimeLimit, jPlayer.getPointLimit())) { + if (player.isOnline() && !data.Informed && !data.isReseted()) { + player.sendMessage(lManager.getMessage("command.limit.output.reachedPointlimit")); + player.sendMessage(lManager.getMessage("command.limit.output.reachedPointlimit2")); + data.Setinformed(); + } + if (data.IsAnnounceTime(GconfigManager.PointAnnouncmentDelay) && player.isOnline()) { + String message = lManager.getMessage("command.limit.output.lefttime", "%hour%", data.GetLeftHour(GconfigManager.PointTimeLimit)); + message = message.replace("%min%", String.valueOf(data.GetLeftMin(GconfigManager.PointTimeLimit))); + message = message.replace("%sec%", String.valueOf(data.GetLeftsec(GconfigManager.PointTimeLimit))); + Jobs.getActionBar().send((player), ChatColor.RED + message); + } + if (data.isReseted()) + data.setReseted(false); + return false; + } + data.AddPoints(amount); + PointLimit.put(playername, data); + } + return true; + } + } diff --git a/com/gamingmesh/jobs/JobsPlugin.java b/com/gamingmesh/jobs/JobsPlugin.java deleted file mode 100644 index e8e58adc..00000000 --- a/com/gamingmesh/jobs/JobsPlugin.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Jobs Plugin for Bukkit - * Copyright (C) 2011 Zak Ford - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.gamingmesh.jobs; - -import java.lang.reflect.InvocationTargetException; -import org.bukkit.Bukkit; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.ChatColor; - -import com.gamingmesh.jobs.listeners.JobsListener; -import com.gamingmesh.jobs.listeners.JobsPaymentListener; -import com.gamingmesh.jobs.stuff.ActionBar; -import com.gamingmesh.jobs.stuff.TabComplete; -import com.gamingmesh.jobs.config.YmlMaker; - -public class JobsPlugin extends JavaPlugin { - - @Override - public void onEnable() { - - String packageName = getServer().getClass().getPackage().getName(); - String[] packageSplit = packageName.split("\\."); - String version = packageSplit[packageSplit.length - 1].substring(0, packageSplit[packageSplit.length - 1].length() - 3); - try { - Class nmsClass; - nmsClass = Class.forName("com.gamingmesh.jobs.nmsUtil." + version); - if (NMS.class.isAssignableFrom(nmsClass)) { - Jobs.setNms((NMS) nmsClass.getConstructor().newInstance()); - } else { - System.out.println("Something went wrong, please note down version and contact author v:" + version); - this.setEnabled(false); - } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException - | SecurityException e) { - System.out.println("Your server version is not compatible with this plugins version! Plugin will be disabled: " + version); - this.setEnabled(false); - e.printStackTrace(); - return; - } - - try { - Jobs.setActionBar(new ActionBar()); -// OfflinePlayerList.fillList(); - YmlMaker jobConfig = new YmlMaker(this, "jobConfig.yml"); - jobConfig.saveDefaultConfig(); - - YmlMaker jobSigns = new YmlMaker(this, "Signs.yml"); - jobSigns.saveDefaultConfig(); - - YmlMaker jobSchedule = new YmlMaker(this, "schedule.yml"); - jobSchedule.saveDefaultConfig(); - - YmlMaker jobShopItems = new YmlMaker(this, "shopItems.yml"); - jobShopItems.saveDefaultConfig(); - - Jobs.setPermissionHandler(new PermissionHandler(this)); - - Jobs.setPlayerManager(this); - - Jobs.setScboard(this); - Jobs.setLanguage(this); - Jobs.setGUIManager(); - Jobs.setExplore(); - - Jobs.setBBManager(this); - - Jobs.setPluginLogger(getLogger()); - - Jobs.setDataFolder(getDataFolder()); - - Jobs.setLoging(); - Jobs.setGCManager(this); - Jobs.setConfigManager(this); - - Jobs.setCommandManager(this); - - getCommand("jobs").setExecutor(Jobs.getCommandManager()); - - this.getCommand("jobs").setTabCompleter(new TabComplete()); - - Jobs.startup(this); - - // register the listeners - getServer().getPluginManager().registerEvents(new JobsListener(this), this); - getServer().getPluginManager().registerEvents(new JobsPaymentListener(this), this); - - Jobs.setMcMMOlistener(this); - if (Jobs.getMcMMOlistener().CheckmcMMO()) { - getServer().getPluginManager().registerEvents(Jobs.getMcMMOlistener(), this); - } - - Jobs.setMythicManager(this); - if (Jobs.getMythicManager().Check() && Jobs.getGCManager().MythicMobsEnabled) { - getServer().getPluginManager().registerEvents(Jobs.getMythicManager(), this); - } - - Jobs.setPistonProtectionListener(this); - if (Jobs.getGCManager().useBlockProtection) { - getServer().getPluginManager().registerEvents(Jobs.getPistonProtectionListener(), this); - } - - // register economy - Bukkit.getScheduler().runTask(this, new HookEconomyTask(this)); - - // all loaded properly. - - Jobs.getScheduleManager().DateUpdater(); - - String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] Plugin has been enabled succesfully."); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); - console.sendMessage(message); - Jobs.getLanguage().reload(); - - Jobs.getJobsDAO().loadExplore(); - - Jobs.getCommandManager().fillCommands(); - } catch (Exception e) { - System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled."); - this.setEnabled(false); - e.printStackTrace(); - } - } - - @Override - public void onDisable() { - Jobs.getGUIManager().CloseInventories(); - Jobs.getShopManager().CloseInventories(); - Jobs.getJobsDAO().saveExplore(); - Jobs.shutdown(); - String message = ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &2Plugin has been disabled succesfully."); - ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); - console.sendMessage(message); - } -} diff --git a/com/gamingmesh/jobs/PermissionHandler.java b/com/gamingmesh/jobs/PermissionHandler.java index 01c82646..0e328cb0 100644 --- a/com/gamingmesh/jobs/PermissionHandler.java +++ b/com/gamingmesh/jobs/PermissionHandler.java @@ -37,9 +37,9 @@ import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; public class PermissionHandler { - private JobsPlugin plugin; + private Jobs plugin; - public PermissionHandler(JobsPlugin plugin) { + public PermissionHandler(Jobs plugin) { this.plugin = plugin; } @@ -50,7 +50,7 @@ public class PermissionHandler { Player player = jPlayer.getPlayer(); if (player == null) - return; + return; boolean changed = false; @@ -72,7 +72,7 @@ public class PermissionHandler { if (job != null) { for (JobPermission perm : job.getPermissions()) { if (perm.getLevelRequirement() <= 0) { - if (perm.getValue()) { + if (perm.isValue()) { permissions.put(perm.getNode(), true); } else { /* @@ -107,7 +107,7 @@ public class PermissionHandler { break; } } - if (found == false) + if (!found) ok = false; } @@ -140,7 +140,7 @@ public class PermissionHandler { * If the key exists, don't put a false node in * This is in case we already have a true node there */ - if (perm.getValue()) { + if (perm.isValue()) { permissions.put(perm.getNode(), true); } else { if (!permissions.containsKey(perm.getNode())) { @@ -171,7 +171,7 @@ public class PermissionHandler { break; } } - if (found == false) + if (!found) ok = false; } if (!ok) @@ -209,7 +209,7 @@ public class PermissionHandler { // find old attachment PermissionAttachment attachment = null; for (PermissionAttachmentInfo pai : player.getEffectivePermissions()) { - if (pai.getAttachment() != null && pai.getAttachment().getPlugin() instanceof JobsPlugin) { + if (pai.getAttachment() != null && pai.getAttachment().getPlugin() instanceof Jobs) { attachment = pai.getAttachment(); } } diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index b7e658a6..d29eee64 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -60,9 +60,9 @@ public class PlayerManager { private PointsData PointsDatabase = new PointsData(); private HashMap PlayerMap = new HashMap(); - JobsPlugin plugin; + Jobs plugin; - public PlayerManager(JobsPlugin plugin) { + public PlayerManager(Jobs plugin) { this.plugin = plugin; } @@ -166,8 +166,7 @@ public class PlayerManager { * 2) Perform save on all players on copied list. * 3) Garbage collect the real list to remove any offline players with saved data */ - ArrayList list = null; - list = new ArrayList(this.players.values()); + ArrayList list = new ArrayList(this.players.values()); for (JobsPlayer jPlayer : list) { jPlayer.save(); @@ -263,7 +262,7 @@ public class PlayerManager { jPlayer.setPlayerUUID(UUID.fromString(info.getKey())); jPlayer.setUserId(info.getValue().getID()); - List list = Jobs.getJobsDAO().getAllJobs(info.getValue().getName(), jPlayer.getPlayerUUID()); + List list = Jobs.getJobsDAO().getAllJobs(info.getValue()); for (JobsDAOData jobdata : list) { if (Jobs.getJob(jobdata.getJobName()) == null) continue; @@ -692,8 +691,8 @@ public class PlayerManager { } for (Entry oneE : enchants.entrySet()) { - if (oneItem.getenchants().containsKey(oneE.getKey())) { - if (oneItem.getenchants().get(oneE.getKey()) < oneE.getValue()) { + if (oneItem.getEnchants().containsKey(oneE.getKey())) { + if (oneItem.getEnchants().get(oneE.getKey()) < oneE.getValue()) { continue main; } } else diff --git a/com/gamingmesh/jobs/Signs/SignUtil.java b/com/gamingmesh/jobs/Signs/SignUtil.java index 41104e4d..bf331a59 100644 --- a/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/com/gamingmesh/jobs/Signs/SignUtil.java @@ -15,16 +15,15 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.config.CommentedYamlConfiguration; import com.gamingmesh.jobs.container.TopList; public class SignUtil { public SignInfo Signs = new SignInfo(); - private JobsPlugin plugin; + private Jobs plugin; - public SignUtil(JobsPlugin plugin) { + public SignUtil(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/actions/CustomKillInfo.java b/com/gamingmesh/jobs/actions/CustomKillInfo.java index 68bf76dd..1e5bf429 100644 --- a/com/gamingmesh/jobs/actions/CustomKillInfo.java +++ b/com/gamingmesh/jobs/actions/CustomKillInfo.java @@ -1,42 +1,42 @@ -/** - * Jobs Plugin for Bukkit - * Copyright (C) 2011 Zak Ford - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.gamingmesh.jobs.actions; - -import com.gamingmesh.jobs.container.ActionInfo; -import com.gamingmesh.jobs.container.ActionType; -import com.gamingmesh.jobs.container.BaseActionInfo; - -public class CustomKillInfo extends BaseActionInfo implements ActionInfo { - private String name; - - public CustomKillInfo(String name, ActionType type) { - super(type); - this.name = name; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getNameWithSub() { - return name; - } -} +/** + * Jobs Plugin for Bukkit + * Copyright (C) 2011 Zak Ford + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.gamingmesh.jobs.actions; + +import com.gamingmesh.jobs.container.ActionInfo; +import com.gamingmesh.jobs.container.ActionType; +import com.gamingmesh.jobs.container.BaseActionInfo; + +public class CustomKillInfo extends BaseActionInfo implements ActionInfo { + private String name; + + public CustomKillInfo(String name, ActionType type) { + super(type); + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getNameWithSub() { + return name; + } +} diff --git a/com/gamingmesh/jobs/actions/ItemActionInfo.java b/com/gamingmesh/jobs/actions/ItemActionInfo.java index 1753ecfd..ce18d3d7 100644 --- a/com/gamingmesh/jobs/actions/ItemActionInfo.java +++ b/com/gamingmesh/jobs/actions/ItemActionInfo.java @@ -25,7 +25,7 @@ import com.gamingmesh.jobs.container.ActionType; public class ItemActionInfo extends MaterialActionInfo implements ActionInfo { @SuppressWarnings("deprecation") - public ItemActionInfo(ItemStack items, ActionType type) { - super(items.getType(), items.getData().getData(), type); + public ItemActionInfo(ItemStack items, ActionType type) { + super(items.getType(), items.getData().getData(), type); } } diff --git a/com/gamingmesh/jobs/actions/MaterialActionInfo.java b/com/gamingmesh/jobs/actions/MaterialActionInfo.java index f092f35e..06827786 100644 --- a/com/gamingmesh/jobs/actions/MaterialActionInfo.java +++ b/com/gamingmesh/jobs/actions/MaterialActionInfo.java @@ -35,7 +35,7 @@ public abstract class MaterialActionInfo extends BaseActionInfo implements Actio @Override public String getName() { - return material.toString(); + return material.name(); } @Override diff --git a/com/gamingmesh/jobs/commands/Cmd.java b/com/gamingmesh/jobs/commands/Cmd.java index 07dbf1e4..3bc89dd3 100644 --- a/com/gamingmesh/jobs/commands/Cmd.java +++ b/com/gamingmesh/jobs/commands/Cmd.java @@ -2,8 +2,8 @@ package com.gamingmesh.jobs.commands; import org.bukkit.command.CommandSender; -import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.Jobs; public interface Cmd { - public boolean perform(JobsPlugin plugin, CommandSender sender, String[] args); + boolean perform(Jobs plugin, CommandSender sender, String[] args); } diff --git a/com/gamingmesh/jobs/commands/JobsCommands.java b/com/gamingmesh/jobs/commands/JobsCommands.java index e95a43ff..63fbcae0 100644 --- a/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/com/gamingmesh/jobs/commands/JobsCommands.java @@ -27,7 +27,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.BoostMultiplier; import com.gamingmesh.jobs.container.Job; @@ -38,13 +37,12 @@ import com.gamingmesh.jobs.container.JobsPlayer; public class JobsCommands implements CommandExecutor { private static final String label = "jobs"; private static final String packagePath = "com.gamingmesh.jobs.commands.list"; - private static final List hidenCommands = Arrays.asList(); + private static final List hidenCommands = new ArrayList(); Map CommandList = new HashMap(); - final String baseCmd = "jobs"; - protected JobsPlugin plugin; + protected Jobs plugin; - public JobsCommands(JobsPlugin plugin) { + public JobsCommands(Jobs plugin) { this.plugin = plugin; } @@ -106,10 +104,7 @@ public class JobsCommands implements CommandExecutor { } private static String[] reduceArgs(String[] args) { - if (args.length <= 1) - return new String[0]; - - return Arrays.copyOfRange(args, 1, args.length); + return args.length <= 1 ? new String[0] : Arrays.copyOfRange(args, 1, args.length); } private static boolean hasCommandPermission(CommandSender sender, String cmd) { @@ -188,11 +183,11 @@ public class JobsCommands implements CommandExecutor { sender.sendMessage(getUsage(one.getKey()) + " - " + Jobs.getLanguage().getMessage("command." + one.getKey() + ".help.info")); } - String prevCmd = "/" + baseCmd + " ? " + (page - 1); + String prevCmd = "/" + label + " ? " + (page - 1); String prev = "[\"\",{\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.prev") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + prevCmd + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + "<<<" + "\"}]}}}"; - String nextCmd = "/" + baseCmd + " ? " + (page + 1); + String nextCmd = "/" + label + " ? " + (page + 1); String next = " {\"text\":\"" + Jobs.getLanguage().getMessage("command.help.output.next") + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"" + nextCmd + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + ">>>" + "\"}]}}}]"; @@ -201,10 +196,10 @@ public class JobsCommands implements CommandExecutor { return true; } - public static List getClassesFromPackage(String pckgname) throws ClassNotFoundException { + private static List getClassesFromPackage(String pckgname) throws ClassNotFoundException { List result = new ArrayList(); try { - for (URL jarURL : ((URLClassLoader) JobsPlugin.class.getClassLoader()).getURLs()) { + for (URL jarURL : ((URLClassLoader) Jobs.class.getClassLoader()).getURLs()) { try { result.addAll(getClassesInSamePackageFromJar(pckgname, jarURL.toURI().getPath())); } catch (URISyntaxException e) { @@ -287,9 +282,7 @@ public class JobsCommands implements CommandExecutor { Class nmsClass = null; try { nmsClass = Class.forName(packagePath + "." + cmd.toLowerCase()); - } catch (ClassNotFoundException e) { - } catch (IllegalArgumentException e) { - } catch (SecurityException e) { + } catch (ClassNotFoundException | IllegalArgumentException | SecurityException e) { } return nmsClass; } @@ -302,13 +295,8 @@ public class JobsCommands implements CommandExecutor { if (Cmd.class.isAssignableFrom(nmsClass)) { cmdClass = (Cmd) nmsClass.getConstructor().newInstance(); } - } catch (ClassNotFoundException e) { - } catch (InstantiationException e) { - } catch (IllegalAccessException e) { - } catch (IllegalArgumentException e) { - } catch (InvocationTargetException e) { - } catch (NoSuchMethodException e) { - } catch (SecurityException e) { + } catch (ClassNotFoundException | InstantiationException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | InvocationTargetException + | SecurityException e) { } return cmdClass; } diff --git a/com/gamingmesh/jobs/commands/list/archive.java b/com/gamingmesh/jobs/commands/list/archive.java index defb459b..56bc10fe 100644 --- a/com/gamingmesh/jobs/commands/list/archive.java +++ b/com/gamingmesh/jobs/commands/list/archive.java @@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobsPlayer; @@ -18,7 +17,7 @@ public class archive implements Cmd { @Override @JobCommand(1400) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { JobsPlayer jPlayer = null; if (args.length >= 1) { if (!sender.hasPermission("jobs.command.admin.archive")) { diff --git a/com/gamingmesh/jobs/commands/list/blockinfo.java b/com/gamingmesh/jobs/commands/list/blockinfo.java index 24a1d907..8a1d9322 100644 --- a/com/gamingmesh/jobs/commands/list/blockinfo.java +++ b/com/gamingmesh/jobs/commands/list/blockinfo.java @@ -5,7 +5,6 @@ import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; @@ -14,7 +13,7 @@ public class blockinfo implements Cmd { @Override @SuppressWarnings("deprecation") @JobCommand(1450) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); return false; diff --git a/com/gamingmesh/jobs/commands/list/bonus.java b/com/gamingmesh/jobs/commands/list/bonus.java index 6e0bd4ff..58908aee 100644 --- a/com/gamingmesh/jobs/commands/list/bonus.java +++ b/com/gamingmesh/jobs/commands/list/bonus.java @@ -3,7 +3,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.BoostMultiplier; @@ -16,7 +15,7 @@ public class bonus implements Cmd { @Override @JobCommand(300) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); return false; diff --git a/com/gamingmesh/jobs/commands/list/browse.java b/com/gamingmesh/jobs/commands/list/browse.java index eaa81b5c..a0247ac8 100644 --- a/com/gamingmesh/jobs/commands/list/browse.java +++ b/com/gamingmesh/jobs/commands/list/browse.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -18,7 +17,7 @@ public class browse implements Cmd { @Override @JobCommand(200) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, CommandSender sender, final String[] args) { ArrayList lines = new ArrayList(); for (Job job : Jobs.getJobs()) { if (Jobs.getGCManager().getHideJobsWithoutPermission()) { @@ -59,6 +58,7 @@ public class browse implements Cmd { } if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) { + Inventory inv = null; try { inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender); @@ -71,6 +71,8 @@ public class browse implements Cmd { return true; ((Player) sender).openInventory(inv); + + } if (Jobs.getGCManager().JobsGUIShowChatBrowse) { diff --git a/com/gamingmesh/jobs/commands/list/convert.java b/com/gamingmesh/jobs/commands/list/convert.java index 9cd6329a..dfb707fe 100644 --- a/com/gamingmesh/jobs/commands/list/convert.java +++ b/com/gamingmesh/jobs/commands/list/convert.java @@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Convert; @@ -18,7 +17,7 @@ public class convert implements Cmd { @Override @JobCommand(2600) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (sender instanceof Player) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.fromconsole")); diff --git a/com/gamingmesh/jobs/commands/list/demote.java b/com/gamingmesh/jobs/commands/list/demote.java index 6258d1c4..72e40536 100644 --- a/com/gamingmesh/jobs/commands/list/demote.java +++ b/com/gamingmesh/jobs/commands/list/demote.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -17,7 +16,7 @@ public class demote implements Cmd { @Override @JobCommand(1700) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { if (args.length < 3) { Jobs.getCommandManager().sendUsage(sender, "demote"); return true; diff --git a/com/gamingmesh/jobs/commands/list/editpoints.java b/com/gamingmesh/jobs/commands/list/editpoints.java index a012a3fb..be312660 100644 --- a/com/gamingmesh/jobs/commands/list/editpoints.java +++ b/com/gamingmesh/jobs/commands/list/editpoints.java @@ -2,7 +2,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.command.CommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobsPlayer; @@ -12,7 +11,7 @@ public class editpoints implements Cmd { @Override @JobCommand(475) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { if (args.length != 3) { Jobs.getCommandManager().sendUsage(sender, "editpoints"); diff --git a/com/gamingmesh/jobs/commands/list/employ.java b/com/gamingmesh/jobs/commands/list/employ.java index 44cc82ec..02af18ae 100644 --- a/com/gamingmesh/jobs/commands/list/employ.java +++ b/com/gamingmesh/jobs/commands/list/employ.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -17,7 +16,7 @@ public class employ implements Cmd { @Override @JobCommand(1800) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { if (args.length < 2) { Jobs.getCommandManager().sendUsage(sender, "employ"); return true; diff --git a/com/gamingmesh/jobs/commands/list/expboost.java b/com/gamingmesh/jobs/commands/list/expboost.java index ef63acce..6dab38e0 100644 --- a/com/gamingmesh/jobs/commands/list/expboost.java +++ b/com/gamingmesh/jobs/commands/list/expboost.java @@ -3,7 +3,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.command.CommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -13,7 +12,7 @@ public class expboost implements Cmd { @Override @JobCommand(2300) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { if (args.length > 2 || args.length <= 1) { Jobs.getCommandManager().sendUsage(sender, "expboost"); return true; diff --git a/com/gamingmesh/jobs/commands/list/fire.java b/com/gamingmesh/jobs/commands/list/fire.java index 3f14c2dd..ff4d9c40 100644 --- a/com/gamingmesh/jobs/commands/list/fire.java +++ b/com/gamingmesh/jobs/commands/list/fire.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -17,7 +16,7 @@ public class fire implements Cmd { @Override @JobCommand(1900) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 2) { Jobs.getCommandManager().sendUsage(sender, "fire"); return true; diff --git a/com/gamingmesh/jobs/commands/list/fireall.java b/com/gamingmesh/jobs/commands/list/fireall.java index 48048371..891974ed 100644 --- a/com/gamingmesh/jobs/commands/list/fireall.java +++ b/com/gamingmesh/jobs/commands/list/fireall.java @@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobProgression; @@ -19,7 +18,7 @@ public class fireall implements Cmd { @Override @JobCommand(2000) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 1) { Jobs.getCommandManager().sendUsage(sender, "fireall"); return true; diff --git a/com/gamingmesh/jobs/commands/list/give.java b/com/gamingmesh/jobs/commands/list/give.java index 2a4b75ac..5544210e 100644 --- a/com/gamingmesh/jobs/commands/list/give.java +++ b/com/gamingmesh/jobs/commands/list/give.java @@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -16,7 +15,7 @@ public class give implements Cmd { @Override @JobCommand(2500) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 1 || Jobs.getJob(args[0]) == null && Jobs.getJob(args[1]) == null) { Jobs.getCommandManager().sendUsage(sender, "give"); @@ -27,7 +26,7 @@ public class give implements Cmd { Job job = Jobs.getJob(args[0]); for (JobItems item : job.getItems()) { if (item.getNode().equalsIgnoreCase(args[1])) { - GiveItem.GiveItemForPlayer((Player) sender, item.getId(), 0, 1, item.getName(), item.getLore(), item.getenchants()); + GiveItem.GiveItemForPlayer((Player) sender, item.getId(), 0, 1, item.getName(), item.getLore(), item.getEnchants()); return true; } } @@ -42,7 +41,7 @@ public class give implements Cmd { } for (JobItems item : job.getItems()) { if (item.getNode().equalsIgnoreCase(args[2])) { - GiveItem.GiveItemForPlayer(player, item.getId(), 0, 1, item.getName(), item.getLore(), item.getenchants()); + GiveItem.GiveItemForPlayer(player, item.getId(), 0, 1, item.getName(), item.getLore(), item.getEnchants()); return true; } } diff --git a/com/gamingmesh/jobs/commands/list/glog.java b/com/gamingmesh/jobs/commands/list/glog.java index 47331be9..1328f8af 100644 --- a/com/gamingmesh/jobs/commands/list/glog.java +++ b/com/gamingmesh/jobs/commands/list/glog.java @@ -9,7 +9,6 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobsPlayer; @@ -23,7 +22,7 @@ public class glog implements Cmd { @Override @JobCommand(1200) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length != 0) { Jobs.getCommandManager().sendUsage(sender, "glog"); return true; diff --git a/com/gamingmesh/jobs/commands/list/grantxp.java b/com/gamingmesh/jobs/commands/list/grantxp.java index 16ca8c35..5d7ce094 100644 --- a/com/gamingmesh/jobs/commands/list/grantxp.java +++ b/com/gamingmesh/jobs/commands/list/grantxp.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -18,7 +17,7 @@ public class grantxp implements Cmd { @Override @JobCommand(2100) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 3) { Jobs.getCommandManager().sendUsage(sender, "grantxp"); return true; diff --git a/com/gamingmesh/jobs/commands/list/gtop.java b/com/gamingmesh/jobs/commands/list/gtop.java index cd1f96a6..5981e853 100644 --- a/com/gamingmesh/jobs/commands/list/gtop.java +++ b/com/gamingmesh/jobs/commands/list/gtop.java @@ -12,7 +12,6 @@ import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.ScoreboardManager; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.TopList; @@ -22,7 +21,7 @@ public class gtop implements Cmd { @Override @JobCommand(600) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length != 1 && args.length != 0) { Jobs.getCommandManager().sendUsage(sender, "gtop"); diff --git a/com/gamingmesh/jobs/commands/list/info.java b/com/gamingmesh/jobs/commands/list/info.java index 0caf50c9..dbfcd9bf 100644 --- a/com/gamingmesh/jobs/commands/list/info.java +++ b/com/gamingmesh/jobs/commands/list/info.java @@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -15,7 +14,7 @@ public class info implements Cmd { @Override @JobCommand(300) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); return false; diff --git a/com/gamingmesh/jobs/commands/list/join.java b/com/gamingmesh/jobs/commands/list/join.java index 3bb86703..0f28c9f8 100644 --- a/com/gamingmesh/jobs/commands/list/join.java +++ b/com/gamingmesh/jobs/commands/list/join.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -17,7 +16,7 @@ public class join implements Cmd { @Override @JobCommand(100) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); return false; diff --git a/com/gamingmesh/jobs/commands/list/leave.java b/com/gamingmesh/jobs/commands/list/leave.java index 1f68faec..7502b445 100644 --- a/com/gamingmesh/jobs/commands/list/leave.java +++ b/com/gamingmesh/jobs/commands/list/leave.java @@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -15,7 +14,7 @@ public class leave implements Cmd { @Override @JobCommand(800) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) return false; diff --git a/com/gamingmesh/jobs/commands/list/leaveall.java b/com/gamingmesh/jobs/commands/list/leaveall.java index 6f4d02d2..b3145ff7 100644 --- a/com/gamingmesh/jobs/commands/list/leaveall.java +++ b/com/gamingmesh/jobs/commands/list/leaveall.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobProgression; @@ -16,7 +15,7 @@ public class leaveall implements Cmd { @Override @JobCommand(900) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); return false; diff --git a/com/gamingmesh/jobs/commands/list/limit.java b/com/gamingmesh/jobs/commands/list/limit.java index d172a6c9..b49acb26 100644 --- a/com/gamingmesh/jobs/commands/list/limit.java +++ b/com/gamingmesh/jobs/commands/list/limit.java @@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobsPlayer; @@ -14,7 +13,7 @@ public class limit implements Cmd { @Override @JobCommand(700) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length > 0) { Jobs.getCommandManager().sendUsage(sender, "limit"); return true; diff --git a/com/gamingmesh/jobs/commands/list/log.java b/com/gamingmesh/jobs/commands/list/log.java index 4495d550..8773d9bd 100644 --- a/com/gamingmesh/jobs/commands/list/log.java +++ b/com/gamingmesh/jobs/commands/list/log.java @@ -9,7 +9,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobsPlayer; @@ -21,7 +20,7 @@ public class log implements Cmd { @Override @JobCommand(1100) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player) && args.length != 1) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); diff --git a/com/gamingmesh/jobs/commands/list/moneyboost.java b/com/gamingmesh/jobs/commands/list/moneyboost.java index c1d1a6f4..a4fab6db 100644 --- a/com/gamingmesh/jobs/commands/list/moneyboost.java +++ b/com/gamingmesh/jobs/commands/list/moneyboost.java @@ -3,7 +3,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.command.CommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -13,7 +12,7 @@ public class moneyboost implements Cmd { @Override @JobCommand(2400) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length > 2 || args.length <= 1) { Jobs.getCommandManager().sendUsage(sender, "moneyboost"); diff --git a/com/gamingmesh/jobs/commands/list/playerinfo.java b/com/gamingmesh/jobs/commands/list/playerinfo.java index 29f74263..905f84c3 100644 --- a/com/gamingmesh/jobs/commands/list/playerinfo.java +++ b/com/gamingmesh/jobs/commands/list/playerinfo.java @@ -5,7 +5,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -16,7 +15,7 @@ public class playerinfo implements Cmd { @Override @JobCommand(1300) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 2) { Jobs.getCommandManager().sendUsage(sender, "playerinfo"); Jobs.getCommandManager().sendValidActions(sender); diff --git a/com/gamingmesh/jobs/commands/list/pointboost.java b/com/gamingmesh/jobs/commands/list/pointboost.java index fe47c8d2..2c0f6930 100644 --- a/com/gamingmesh/jobs/commands/list/pointboost.java +++ b/com/gamingmesh/jobs/commands/list/pointboost.java @@ -3,7 +3,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.command.CommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -13,7 +12,7 @@ public class pointboost implements Cmd { @Override @JobCommand(2400) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length > 2 || args.length <= 1) { Jobs.getCommandManager().sendUsage(sender, "pointboost"); diff --git a/com/gamingmesh/jobs/commands/list/points.java b/com/gamingmesh/jobs/commands/list/points.java index 14c86aa9..5cfaa3e5 100644 --- a/com/gamingmesh/jobs/commands/list/points.java +++ b/com/gamingmesh/jobs/commands/list/points.java @@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobsPlayer; @@ -15,7 +14,7 @@ public class points implements Cmd { @Override @JobCommand(450) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length != 0 && args.length != 1) { Jobs.getCommandManager().sendUsage(sender, "points"); diff --git a/com/gamingmesh/jobs/commands/list/promote.java b/com/gamingmesh/jobs/commands/list/promote.java index 00028ee5..4231eb93 100644 --- a/com/gamingmesh/jobs/commands/list/promote.java +++ b/com/gamingmesh/jobs/commands/list/promote.java @@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -17,7 +16,7 @@ public class promote implements Cmd { @Override @JobCommand(1600) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 3) { Jobs.getCommandManager().sendUsage(sender, "promote"); return true; diff --git a/com/gamingmesh/jobs/commands/list/reload.java b/com/gamingmesh/jobs/commands/list/reload.java index bc3ae4a9..80c496e2 100644 --- a/com/gamingmesh/jobs/commands/list/reload.java +++ b/com/gamingmesh/jobs/commands/list/reload.java @@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.stuff.ChatColor; @@ -13,7 +12,7 @@ import com.gamingmesh.jobs.stuff.ChatColor; public class reload implements Cmd { @Override @JobCommand(2900) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { try { Jobs.reload(); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); diff --git a/com/gamingmesh/jobs/commands/list/removexp.java b/com/gamingmesh/jobs/commands/list/removexp.java index bd2ccbab..8e23aca7 100644 --- a/com/gamingmesh/jobs/commands/list/removexp.java +++ b/com/gamingmesh/jobs/commands/list/removexp.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -18,7 +17,7 @@ public class removexp implements Cmd { @Override @JobCommand(2200) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 3) { Jobs.getCommandManager().sendUsage(sender, "removexp"); return true; diff --git a/com/gamingmesh/jobs/commands/list/shop.java b/com/gamingmesh/jobs/commands/list/shop.java index 363b6c58..52803a7d 100644 --- a/com/gamingmesh/jobs/commands/list/shop.java +++ b/com/gamingmesh/jobs/commands/list/shop.java @@ -3,7 +3,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; @@ -11,7 +10,7 @@ public class shop implements Cmd { @Override @JobCommand(750) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); diff --git a/com/gamingmesh/jobs/commands/list/signupdate.java b/com/gamingmesh/jobs/commands/list/signupdate.java index caf4dabd..02990afc 100644 --- a/com/gamingmesh/jobs/commands/list/signupdate.java +++ b/com/gamingmesh/jobs/commands/list/signupdate.java @@ -3,7 +3,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.command.CommandSender; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -13,7 +12,7 @@ public class signupdate implements Cmd { @Override @JobCommand(2700) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length != 1) { Jobs.getCommandManager().sendUsage(sender, "signupdate"); return true; diff --git a/com/gamingmesh/jobs/commands/list/stats.java b/com/gamingmesh/jobs/commands/list/stats.java index 8f848eb0..73b41cb0 100644 --- a/com/gamingmesh/jobs/commands/list/stats.java +++ b/com/gamingmesh/jobs/commands/list/stats.java @@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobProgression; @@ -15,7 +14,7 @@ public class stats implements Cmd { @Override @JobCommand(400) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { JobsPlayer jPlayer = null; if (args.length >= 1) { if (!sender.hasPermission("jobs.command.admin.stats")) { diff --git a/com/gamingmesh/jobs/commands/list/toggle.java b/com/gamingmesh/jobs/commands/list/toggle.java index d511b20b..169759ea 100644 --- a/com/gamingmesh/jobs/commands/list/toggle.java +++ b/com/gamingmesh/jobs/commands/list/toggle.java @@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.JobsPlayer; @@ -15,7 +14,7 @@ public class toggle implements Cmd { @Override @JobCommand(1000) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); diff --git a/com/gamingmesh/jobs/commands/list/top.java b/com/gamingmesh/jobs/commands/list/top.java index 7b4507b4..3af56acd 100644 --- a/com/gamingmesh/jobs/commands/list/top.java +++ b/com/gamingmesh/jobs/commands/list/top.java @@ -12,7 +12,6 @@ import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.ScoreboardManager; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -23,7 +22,7 @@ public class top implements Cmd { @Override @JobCommand(500) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length != 1 && args.length != 2) { Jobs.getCommandManager().sendUsage(sender, "top"); diff --git a/com/gamingmesh/jobs/commands/list/transfer.java b/com/gamingmesh/jobs/commands/list/transfer.java index f0d77225..fc064a89 100644 --- a/com/gamingmesh/jobs/commands/list/transfer.java +++ b/com/gamingmesh/jobs/commands/list/transfer.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; @@ -18,7 +17,7 @@ public class transfer implements Cmd { @Override @JobCommand(1500) - public boolean perform(JobsPlugin plugin, final CommandSender sender, final String[] args) { + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { if (args.length < 3) { Jobs.getCommandManager().sendUsage(sender, "transfer"); return true; diff --git a/com/gamingmesh/jobs/config/BossBarManager.java b/com/gamingmesh/jobs/config/BossBarManager.java index c8bf8114..16f223fe 100644 --- a/com/gamingmesh/jobs/config/BossBarManager.java +++ b/com/gamingmesh/jobs/config/BossBarManager.java @@ -14,16 +14,15 @@ import org.bukkit.boss.BossBar; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.BossBarInfo; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; public class BossBarManager { - JobsPlugin plugin; + Jobs plugin; - public BossBarManager(JobsPlugin plugin) { + public BossBarManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/ConfigManager.java b/com/gamingmesh/jobs/config/ConfigManager.java index b148bc58..00b8e167 100644 --- a/com/gamingmesh/jobs/config/ConfigManager.java +++ b/com/gamingmesh/jobs/config/ConfigManager.java @@ -36,7 +36,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.DisplayMethod; import com.gamingmesh.jobs.container.Job; @@ -50,9 +49,9 @@ import com.gamingmesh.jobs.resources.jfep.Parser; import com.gamingmesh.jobs.stuff.ChatColor; public class ConfigManager { - private JobsPlugin plugin; + private Jobs plugin; - public ConfigManager(JobsPlugin plugin) { + public ConfigManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/GeneralConfigManager.java b/com/gamingmesh/jobs/config/GeneralConfigManager.java index 44189178..38831933 100644 --- a/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -32,7 +32,6 @@ import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.resources.jfep.Parser; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.BoostType; import com.gamingmesh.jobs.container.LocaleReader; import com.gamingmesh.jobs.container.Schedule; @@ -41,7 +40,7 @@ import com.gamingmesh.jobs.dao.JobsDAOSQLite; import com.gamingmesh.jobs.stuff.ChatColor; public class GeneralConfigManager { - private JobsPlugin plugin; + private Jobs plugin; public List BroadcastingLevelUpLevels = new ArrayList(); protected Locale locale; protected int savePeriod; @@ -151,7 +150,7 @@ public class GeneralConfigManager { return commandArgs; } - public GeneralConfigManager(JobsPlugin plugin) { + public GeneralConfigManager(Jobs plugin) { this.plugin = plugin; } @@ -315,27 +314,27 @@ public class GeneralConfigManager { // general settings loadGeneralSettings(); // Load locale - Jobs.setLanguageManager(plugin); + Jobs.setLanguageManager(this.plugin); Jobs.getLanguageManager().load(); // title settings - Jobs.setTitleManager(plugin); + Jobs.setTitleManager(this.plugin); Jobs.gettitleManager().load(); // restricted areas - Jobs.setRestrictedAreaManager(plugin); + Jobs.setRestrictedAreaManager(this.plugin); Jobs.getRestrictedAreaManager().load(); // restricted blocks - Jobs.setRestrictedBlockManager(plugin); + Jobs.setRestrictedBlockManager(this.plugin); Jobs.getRestrictedBlockManager().load(); // Item/Block/mobs name list - Jobs.setNameTranslatorManager(plugin); + Jobs.setNameTranslatorManager(this.plugin); Jobs.getNameTranslatorManager().load(); // signs information - Jobs.setSignUtil(plugin); + Jobs.setSignUtil(this.plugin); Jobs.getSignUtil().LoadSigns(); // Schedule - Jobs.setScheduleManager(plugin); + Jobs.setScheduleManager(this.plugin); // Shop - Jobs.setShopManager(plugin); + Jobs.setShopManager(this.plugin); Jobs.getShopManager().load(); } diff --git a/com/gamingmesh/jobs/config/LanguageManager.java b/com/gamingmesh/jobs/config/LanguageManager.java index 69a69ffd..9ec8a9f2 100644 --- a/com/gamingmesh/jobs/config/LanguageManager.java +++ b/com/gamingmesh/jobs/config/LanguageManager.java @@ -8,14 +8,13 @@ import java.util.List; import org.bukkit.configuration.file.YamlConfiguration; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.LocaleReader; import com.gamingmesh.jobs.stuff.Debug; public class LanguageManager { - private JobsPlugin plugin; + private Jobs plugin; - public LanguageManager(JobsPlugin plugin) { + public LanguageManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/NameTranslatorManager.java b/com/gamingmesh/jobs/config/NameTranslatorManager.java index 26c44cff..d394792a 100644 --- a/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -10,7 +10,6 @@ import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.JobInfo; import com.gamingmesh.jobs.container.LocaleReader; import com.gamingmesh.jobs.container.NameList; @@ -18,14 +17,14 @@ import com.gamingmesh.jobs.stuff.ChatColor; public class NameTranslatorManager { - private JobsPlugin plugin; + private Jobs plugin; public ArrayList ListOfNames = new ArrayList(); public ArrayList ListOfEntities = new ArrayList(); public ArrayList ListOfEnchants = new ArrayList(); public ArrayList ListOfColors = new ArrayList(); - public NameTranslatorManager(JobsPlugin plugin) { + public NameTranslatorManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/RestrictedAreaManager.java b/com/gamingmesh/jobs/config/RestrictedAreaManager.java index 37cb555a..c5d55293 100644 --- a/com/gamingmesh/jobs/config/RestrictedAreaManager.java +++ b/com/gamingmesh/jobs/config/RestrictedAreaManager.java @@ -11,7 +11,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.RestrictedArea; import com.gamingmesh.jobs.stuff.ChatColor; @@ -19,9 +19,9 @@ public class RestrictedAreaManager { protected ArrayList restrictedAreas = new ArrayList(); - private JobsPlugin plugin; + private Jobs plugin; - public RestrictedAreaManager(JobsPlugin plugin) { + public RestrictedAreaManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/RestrictedBlockManager.java b/com/gamingmesh/jobs/config/RestrictedBlockManager.java index 120ff796..28915973 100644 --- a/com/gamingmesh/jobs/config/RestrictedBlockManager.java +++ b/com/gamingmesh/jobs/config/RestrictedBlockManager.java @@ -6,7 +6,8 @@ import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; -import com.gamingmesh.jobs.JobsPlugin; + +import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.LocaleReader; import com.gamingmesh.jobs.stuff.ChatColor; @@ -16,9 +17,9 @@ public class RestrictedBlockManager { public ArrayList restrictedBlocksTimer = new ArrayList(); public ArrayList restrictedPlaceBlocksTimer = new ArrayList(); - private JobsPlugin plugin; + private Jobs plugin; - public RestrictedBlockManager(JobsPlugin plugin) { + public RestrictedBlockManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/ScboardManager.java b/com/gamingmesh/jobs/config/ScboardManager.java index a34e8a5d..59030230 100644 --- a/com/gamingmesh/jobs/config/ScboardManager.java +++ b/com/gamingmesh/jobs/config/ScboardManager.java @@ -9,14 +9,13 @@ import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; public class ScboardManager { private ConcurrentHashMap timerMap = new ConcurrentHashMap(); - private JobsPlugin plugin; + private Jobs plugin; - public ScboardManager(JobsPlugin plugin) { + public ScboardManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/ScheduleManager.java b/com/gamingmesh/jobs/config/ScheduleManager.java index b9eb3b61..5403e357 100644 --- a/com/gamingmesh/jobs/config/ScheduleManager.java +++ b/com/gamingmesh/jobs/config/ScheduleManager.java @@ -13,7 +13,6 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Schedule; import com.gamingmesh.jobs.stuff.ChatColor; @@ -23,9 +22,9 @@ public class ScheduleManager { public int dateByInt = 0; - private JobsPlugin plugin; + private Jobs plugin; - public ScheduleManager(JobsPlugin plugin) { + public ScheduleManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/ShopManager.java b/com/gamingmesh/jobs/config/ShopManager.java index b97c6bee..a63ad417 100644 --- a/com/gamingmesh/jobs/config/ShopManager.java +++ b/com/gamingmesh/jobs/config/ShopManager.java @@ -20,7 +20,6 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobItems; import com.gamingmesh.jobs.container.JobProgression; @@ -30,11 +29,11 @@ import com.gamingmesh.jobs.container.ShopItem; import com.gamingmesh.jobs.stuff.Perm; public class ShopManager { - private JobsPlugin plugin; + private Jobs plugin; public List list = new ArrayList(); public HashMap GuiList = new HashMap(); - public ShopManager(JobsPlugin plugin) { + public ShopManager(Jobs plugin) { this.plugin = plugin; } @@ -135,13 +134,13 @@ public class ShopManager { if (itemStack.getType() == Material.ENCHANTED_BOOK) { EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) itemStack.getItemMeta(); - for (Entry oneEnch : one.getenchants().entrySet()) { + for (Entry oneEnch : one.getEnchants().entrySet()) { bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true); } if (bookMeta != null) itemStack.setItemMeta(bookMeta); } else - for (Entry oneEnch : one.getenchants().entrySet()) { + for (Entry oneEnch : one.getEnchants().entrySet()) { itemStack.addUnsafeEnchantment(oneEnch.getKey(), oneEnch.getValue()); } diff --git a/com/gamingmesh/jobs/config/TitleManager.java b/com/gamingmesh/jobs/config/TitleManager.java index 4707027d..c32f57d9 100644 --- a/com/gamingmesh/jobs/config/TitleManager.java +++ b/com/gamingmesh/jobs/config/TitleManager.java @@ -10,7 +10,6 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.container.LocaleReader; import com.gamingmesh.jobs.container.Title; import com.gamingmesh.jobs.stuff.ChatColor; @@ -19,9 +18,9 @@ public class TitleManager { protected List titles = new ArrayList<Title>(); - private JobsPlugin plugin; + private Jobs plugin; - public TitleManager(JobsPlugin plugin) { + public TitleManager(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/config/YmlMaker.java b/com/gamingmesh/jobs/config/YmlMaker.java index 058090d8..1b362664 100644 --- a/com/gamingmesh/jobs/config/YmlMaker.java +++ b/com/gamingmesh/jobs/config/YmlMaker.java @@ -13,16 +13,16 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; -import com.gamingmesh.jobs.JobsPlugin; +import com.gamingmesh.jobs.Jobs; public class YmlMaker { - JobsPlugin Plugin; + Jobs Plugin; public String fileName; private JavaPlugin plugin; public File ConfigFile; private FileConfiguration Configuration; - public YmlMaker(JobsPlugin Plugin) { + public YmlMaker(Jobs Plugin) { this.Plugin = Plugin; } diff --git a/com/gamingmesh/jobs/container/JobItems.java b/com/gamingmesh/jobs/container/JobItems.java index cc4c9a0b..d572fa30 100644 --- a/com/gamingmesh/jobs/container/JobItems.java +++ b/com/gamingmesh/jobs/container/JobItems.java @@ -73,7 +73,7 @@ public class JobItems { return this.lore; } - public HashMap<Enchantment, Integer> getenchants() { + public HashMap<Enchantment, Integer> getEnchants() { return this.enchants; } diff --git a/com/gamingmesh/jobs/container/JobPermission.java b/com/gamingmesh/jobs/container/JobPermission.java index 42828e40..65a96644 100644 --- a/com/gamingmesh/jobs/container/JobPermission.java +++ b/com/gamingmesh/jobs/container/JobPermission.java @@ -32,7 +32,7 @@ public class JobPermission { return node; } - public boolean getValue() { + public boolean isValue() { return value; } diff --git a/com/gamingmesh/jobs/dao/JobsDAO.java b/com/gamingmesh/jobs/dao/JobsDAO.java index 4537dd2e..03046d4d 100644 --- a/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/com/gamingmesh/jobs/dao/JobsDAO.java @@ -23,6 +23,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.UUID; import java.util.Map.Entry; @@ -58,6 +60,7 @@ public abstract class JobsDAO { private JobsConnectionPool pool; private String prefix; + private HashMap<Integer, ArrayList<JobsDAOData>> map = new HashMap<Integer, ArrayList<JobsDAOData>>(); protected JobsDAO(String driverName, String url, String username, String password, String prefix) { this.prefix = prefix; @@ -97,6 +100,7 @@ public abstract class JobsDAO { updateSchemaVersion(version); } finally { } + loadAllSavedJobs(); } protected abstract void setupConfig() throws SQLException; @@ -140,6 +144,7 @@ public abstract class JobsDAO { * @param playerUUID - the player being searched for * @return list of all of the names of the jobs the players are part of. */ + public List<JobsDAOData> getAllJobs(String playerName, UUID uuid) { int id = -1; @@ -180,29 +185,32 @@ public abstract class JobsDAO { return jobs; } - /** - * Get all jobs the player is part of. - * @param playerUUID - the player being searched for - * @return list of all of the names of the jobs the players are part of. - */ - public List<JobsDAOData> getAllJobs(JobsPlayer jPlayer) { - - ArrayList<JobsDAOData> jobs = new ArrayList<JobsDAOData>(); - - int id = jPlayer.getUserId(); + public List<JobsDAOData> getAllJobs(PlayerInfo pInfo) { + List<JobsDAOData> list = map.get(pInfo.getID()); + if (list != null) + return list; + return new ArrayList<JobsDAOData>(); + } + private void loadAllSavedJobs() { JobsConnection conn = getConnection(); if (conn == null) - return jobs; - + return; PreparedStatement prest = null; ResultSet res = null; try { - prest = conn.prepareStatement("SELECT `job`, `level`, `experience` FROM `" + prefix + "jobs` WHERE `userid` = ?;"); - prest.setInt(1, id); + prest = conn.prepareStatement("SELECT * FROM `" + prefix + "jobs`;"); res = prest.executeQuery(); while (res.next()) { - jobs.add(new JobsDAOData(res.getString(1), res.getInt(2), res.getInt(3))); + int id = res.getInt("userid"); + ArrayList<JobsDAOData> list = map.get(id); + if (list == null) { + list = new ArrayList<JobsDAOData>(); + list.add(new JobsDAOData(res.getString("job"), res.getInt("level"), res.getInt("experience"))); + map.put(id, list); + } else { + list.add(new JobsDAOData(res.getString("job"), res.getInt("level"), res.getInt("experience"))); + } } } catch (SQLException e) { e.printStackTrace(); @@ -210,7 +218,6 @@ public abstract class JobsDAO { close(res); close(prest); } - return jobs; } public void recordNewPlayer(Player player) { @@ -1211,4 +1218,8 @@ public abstract class JobsDAO { e.printStackTrace(); } } + + public HashMap<Integer, ArrayList<JobsDAOData>> getMap() { + return map; + } } diff --git a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java index 31459a18..01659d3e 100644 --- a/com/gamingmesh/jobs/dao/JobsDAOSQLite.java +++ b/com/gamingmesh/jobs/dao/JobsDAOSQLite.java @@ -34,7 +34,7 @@ import com.gamingmesh.jobs.stuff.UUIDUtil; public class JobsDAOSQLite extends JobsDAO { public static JobsDAOSQLite initialize() { JobsDAOSQLite dao = new JobsDAOSQLite(); - File dir = Jobs.getDataFolder(); + File dir = Jobs.getFolder(); if (!dir.exists()) dir.mkdirs(); try { @@ -46,7 +46,7 @@ public class JobsDAOSQLite extends JobsDAO { } private JobsDAOSQLite() { - super("org.sqlite.JDBC", "jdbc:sqlite:" + new File(Jobs.getDataFolder(), "jobs.sqlite.db").getPath(), null, null, ""); + super("org.sqlite.JDBC", "jdbc:sqlite:" + new File(Jobs.getFolder(), "jobs.sqlite.db").getPath(), null, null, ""); } private static void close(ResultSet res) { diff --git a/com/gamingmesh/jobs/economy/BufferedEconomy.java b/com/gamingmesh/jobs/economy/BufferedEconomy.java index 4eee3157..d6eb7811 100644 --- a/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -27,14 +27,13 @@ import java.util.concurrent.LinkedBlockingQueue; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.api.JobsPaymentEvent; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.stuff.ChatColor; import com.gamingmesh.jobs.tasks.BufferedPaymentTask; public class BufferedEconomy { - private JobsPlugin plugin; + private Jobs plugin; private Economy economy; private LinkedBlockingQueue<BufferedPayment> payments = new LinkedBlockingQueue<BufferedPayment>(); private final Map<UUID, BufferedPayment> paymentCache = Collections.synchronizedMap(new HashMap<UUID, BufferedPayment>()); @@ -44,7 +43,7 @@ public class BufferedEconomy { PaymentData PaymentData = new PaymentData(); - public BufferedEconomy(JobsPlugin plugin, Economy economy) { + public BufferedEconomy(Jobs plugin, Economy economy) { this.plugin = plugin; this.economy = economy; } diff --git a/com/gamingmesh/jobs/i18n/Language.java b/com/gamingmesh/jobs/i18n/Language.java index 3d04f56d..8c59bdbb 100644 --- a/com/gamingmesh/jobs/i18n/Language.java +++ b/com/gamingmesh/jobs/i18n/Language.java @@ -21,15 +21,14 @@ package com.gamingmesh.jobs.i18n; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.config.YmlMaker; public class Language { - public static FileConfiguration enlocale; - public static FileConfiguration customlocale; - private JobsPlugin plugin; + public FileConfiguration enlocale; + public FileConfiguration customlocale; + private Jobs plugin; - public Language(JobsPlugin plugin) { + public Language(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/listeners/JobsListener.java b/com/gamingmesh/jobs/listeners/JobsListener.java index d9fb4f4f..d0bbfbd0 100644 --- a/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/com/gamingmesh/jobs/listeners/JobsListener.java @@ -60,7 +60,6 @@ import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.PluginManager; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.Gui.GuiInfoList; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; import com.gamingmesh.jobs.container.Job; @@ -71,9 +70,9 @@ import com.gamingmesh.jobs.stuff.Debug; public class JobsListener implements Listener { // hook to the main plugin - private JobsPlugin plugin; + private Jobs plugin; - public JobsListener(JobsPlugin plugin) { + public JobsListener(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 5460e111..77a7fcb7 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -69,7 +69,6 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.actions.BlockActionInfo; import com.gamingmesh.jobs.actions.CustomKillInfo; import com.gamingmesh.jobs.actions.EnchantActionInfo; @@ -87,7 +86,7 @@ import com.gamingmesh.jobs.stuff.Perm; import com.google.common.base.Objects; public class JobsPaymentListener implements Listener { - private JobsPlugin plugin; + private Jobs plugin; private final String furnaceOwnerMetadata = "jobsFurnaceOwner"; public final static String brewingOwnerMetadata = "jobsBrewingOwner"; private final String mobSpawnerMetadata = "jobsMobSpawner"; @@ -97,7 +96,7 @@ public class JobsPaymentListener implements Listener { public static final String GlobalMetadata = "GlobalTimer"; public static final String CowMetadata = "CowTimer"; - public JobsPaymentListener(JobsPlugin plugin) { + public JobsPaymentListener(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/listeners/McMMOlistener.java b/com/gamingmesh/jobs/listeners/McMMOlistener.java index 04138ed2..781745b0 100644 --- a/com/gamingmesh/jobs/listeners/McMMOlistener.java +++ b/com/gamingmesh/jobs/listeners/McMMOlistener.java @@ -13,7 +13,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.actions.ItemActionInfo; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.JobsPlayer; @@ -24,12 +23,12 @@ import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; public class McMMOlistener implements Listener { - private JobsPlugin plugin; + private Jobs plugin; public boolean mcMMOPresent = false; HashMap<String, HashMap<AbilityType, Long>> map = new HashMap<String, HashMap<AbilityType, Long>>(); - public McMMOlistener(JobsPlugin plugin) { + public McMMOlistener(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/listeners/MythicMobsListener.java b/com/gamingmesh/jobs/listeners/MythicMobsListener.java index e6173544..9014cfed 100644 --- a/com/gamingmesh/jobs/listeners/MythicMobsListener.java +++ b/com/gamingmesh/jobs/listeners/MythicMobsListener.java @@ -12,7 +12,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.plugin.Plugin; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; import com.gamingmesh.jobs.actions.MMKillInfo; import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.JobsPlayer; @@ -25,10 +24,10 @@ import net.elseland.xikage.MythicMobs.Mobs.MythicMob; public class MythicMobsListener implements Listener { - private JobsPlugin plugin; + private Jobs plugin; public MythicMobsAPI MMAPI = null; - public MythicMobsListener(JobsPlugin plugin) { + public MythicMobsListener(Jobs plugin) { this.plugin = plugin; } diff --git a/com/gamingmesh/jobs/listeners/PistonProtectionListener.java b/com/gamingmesh/jobs/listeners/PistonProtectionListener.java index cafa7b5f..3d15e3f2 100644 --- a/com/gamingmesh/jobs/listeners/PistonProtectionListener.java +++ b/com/gamingmesh/jobs/listeners/PistonProtectionListener.java @@ -11,14 +11,13 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.JobsPlugin; public class PistonProtectionListener implements Listener { @SuppressWarnings("unused") - private JobsPlugin plugin; + private Jobs plugin; - public PistonProtectionListener(JobsPlugin plugin) { + public PistonProtectionListener(Jobs plugin) { this.plugin = plugin; } diff --git a/plugin.yml b/plugin.yml index 435099d1..159b6280 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Jobs description: Jobs Plugin for the BukkitAPI -main: com.gamingmesh.jobs.JobsPlugin +main: com.gamingmesh.jobs.Jobs version: 3.5.6 author: phrstbrn depend: [Vault]