diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index caa0427a..5986b060 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -973,7 +973,7 @@ public class ItemManager { GREEN_GLAZED_TERRACOTTA(248, 0, 6958, "Green Glazed Terracotta"), GREEN_SHULKER_BOX(232, 0, 9377, "Green Shulker Box"), GREEN_STAINED_GLASS(95, 13, 22503, "Green Stained Glass"), - GREEN_STAINED_GLASS_PANE(160, 13, 4767, "Green Stained Glass Pane", "STAINED_GLASS_PANE"), + GREEN_STAINED_GLASS_PANE(160, 13, 4767, "Green Stained Glass Pane"), GREEN_TERRACOTTA(159, 13, 4105, "Green Terracotta"), GREEN_WALL_BANNER(177, 2, 15046, "Green Banner"), GREEN_WOOL(35, 13, 25085, "Green Wool"), diff --git a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java index 5ace02b0..4400329c 100644 --- a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java +++ b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java @@ -21,8 +21,8 @@ import com.gamingmesh.jobs.container.JobItems; public class ItemBoostManager { - private static HashMap items = new HashMap(); - private static HashMap legacy = new HashMap(); + private static HashMap items = new HashMap<>(); + private static HashMap legacy = new HashMap<>(); public ItemBoostManager() { @@ -137,14 +137,14 @@ public class ItemBoostManager { } List lore = new ArrayList<>(); - if (cfg.getC().getStringList(one + ".lore") != null && !cfg.getC().getStringList(one + ".lore").isEmpty()) { + if (cfg.getC().contains(one + ".lore") && !cfg.getC().getStringList(one + ".lore").isEmpty()) { for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) { lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); } } HashMap enchants = new HashMap<>(); - if (cfg.getC().getStringList(one + ".enchants") != null && !cfg.getC().getStringList(one + ".enchants").isEmpty()) + if (cfg.getC().contains(one + ".enchants") && !cfg.getC().getStringList(one + ".enchants").isEmpty()) for (String eachLine : cfg.get(one + ".enchants", Arrays.asList(""))) { if (!eachLine.contains("=")) continue; diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index 57e5f534..a8a8c5e6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -35,6 +35,7 @@ import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobInfo; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.container.Title; import com.gamingmesh.jobs.stuff.PageInfo; public class JobsCommands implements CommandExecutor { @@ -491,11 +492,17 @@ public class JobsCommands implements CommandExecutor { * @return the message */ public String jobStatsMessage(JobProgression jobProg) { + Title t = null; + for (Title title : new ArrayList()) { + if (t == null) + t = title; + } String message = Jobs.getLanguage().getMessage("command.stats.output", "%joblevel%", jobProg.getLevel(), "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(), "%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0, - "%jobmaxxp%", jobProg.getMaxExperience()); + "%jobmaxxp%", jobProg.getMaxExperience(), + "%titlename%", t == null ? "" : t.getName()); return " " + jobProgressMessage(jobProg.getMaxExperience(), jobProg.getExperience()) + " " + message; } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/area.java b/src/main/java/com/gamingmesh/jobs/commands/list/area.java index a39d03a4..c6b12704 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/area.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/area.java @@ -26,9 +26,8 @@ public class area implements Cmd { } Player player = (Player) sender; - if (args.length == 0) { + if (args.length == 0) return false; - } RestrictedAreaManager ra = Jobs.getRestrictedAreaManager(); @@ -37,7 +36,7 @@ public class area implements Cmd { double bonus = 0D; try { bonus = Double.parseDouble(args[2]); - } catch (Exception e) { + } catch (Throwable e) { return false; } Boolean wg = false; @@ -53,7 +52,7 @@ public class area implements Cmd { } if (!wg && !Jobs.getSelectionManager().hasPlacedBoth(player)) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTooldID).getName())); + sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.select", "%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName())); return true; } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java index 39bf8900..add9f88b 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java @@ -41,7 +41,7 @@ public class employ implements Cmd { } if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { - String message = Jobs.getLanguage().getMessage("command.join.error.fullslots"); + String message = Jobs.getLanguage().getMessage("command.employ.error.fullslots"); message = message.replace("%jobname%", job.getChatColor() + job.getName()); sender.sendMessage(message); return true; diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index fdc574f6..c27eb7cc 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -437,9 +437,13 @@ public class ConfigManager { //conf.options().header(new StringBuilder().append("Jobs configuration.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("Stores information about each job.").append(System.getProperty("line.separator")).append(System.getProperty("line.separator")).append("For example configurations, visit http://dev.bukkit.org/bukkit-plugins/jobs-reborn/.").append(System.getProperty("line.separator")).toString()); ConfigurationSection jobsSection = conf.getConfigurationSection("Jobs"); - //if (jobsSection == null) { - // jobsSection = conf.createSection("Jobs"); - //} + if (jobsSection == null) { + Jobs.getPluginLogger().severe("==================== Jobs ===================="); + Jobs.getPluginLogger().severe("Jobs section not found in jobConfig file!"); + Jobs.getPluginLogger().severe("Check the config for fix the issue."); + Jobs.getPluginLogger().severe("=============================================="); + return; + } for (String jobKey : jobsSection.getKeys(false)) { // Ignoring example job diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 96c273db..4e41fe3f 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -67,7 +67,7 @@ public class GeneralConfigManager { public boolean PaymentMethodsPoints; public boolean PaymentMethodsExp; private HashMap<CurrencyType, Double> generalMulti = new HashMap<>(); - public int getSelectionTooldID; + private String getSelectionTool = ""; private int ResetTimeHour; private int ResetTimeMinute; @@ -357,10 +357,10 @@ public class GeneralConfigManager { Jobs.setNameTranslatorManager(); Jobs.getNameTranslatorManager().load(); // signs information - Jobs.setSignUtil(this.plugin); + Jobs.setSignUtil(plugin); Jobs.getSignUtil().LoadSigns(); // Schedule - Jobs.setScheduleManager(this.plugin); + Jobs.setScheduleManager(plugin); // Shop Jobs.setShopManager(); Jobs.getShopManager().load(); @@ -374,12 +374,12 @@ public class GeneralConfigManager { private synchronized void loadGeneralSettings() { try { c = new ConfigReader("generalConfig.yml"); - } catch (Exception e1) { - e1.printStackTrace(); + } catch (Throwable t) { + t.printStackTrace(); } - if (c == null){ + if (c == null) return; - } + c.header(Arrays.asList("General configuration.", " The general configuration for the jobs plugin mostly includes how often the plugin", " saves user data (when the user is in the game), the storage method, whether", @@ -392,11 +392,10 @@ public class GeneralConfigManager { localeString = c.get("locale-language", "en"); try { int i = localeString.indexOf('_'); - if (i == -1) { + if (i == -1) locale = new Locale(localeString); - } else { + else locale = new Locale(localeString.substring(0, i), localeString.substring(i + 1)); - } } catch (IllegalArgumentException e) { locale = Locale.getDefault(); Jobs.getPluginLogger().warning("Invalid locale \"" + localeString + "\" defaulting to " + locale.getLanguage()); @@ -404,25 +403,6 @@ public class GeneralConfigManager { Jobs.getDBManager().start(); -// c.getW().addComment("storage-method", "storage method, can be MySQL, sqlite"); -// storageMethod = c.get("storage-method", "sqlite"); -// if (storageMethod.equalsIgnoreCase("mysql")) { -// startMysql(); -// } else if (storageMethod.equalsIgnoreCase("sqlite")) { -// startSqlite(); -// } else { -// Jobs.getPluginLogger().warning("Invalid storage method! Changing method to sqlite!"); -// c.getC().set("storage-method", "sqlite"); -// startSqlite(); -// } -// -// c.getW().addComment("mysql-username", "Requires Mysql."); -// c.get("mysql-username", "root"); -// c.get("mysql-password", ""); -// c.get("mysql-hostname", "localhost:3306"); -// c.get("mysql-database", "minecraft"); -// c.get("mysql-table-prefix", "jobs_"); - c.addComment("save-period", "How often in minutes you want it to save. This must be a non-zero number"); c.get("save-period", 10); if (c.getInt("save-period") <= 0) { @@ -436,18 +416,15 @@ public class GeneralConfigManager { "Only enable this if you have a multi-server setup, or have a really good reason for enabling this.", "Turning this on will decrease database performance."); saveOnDisconnect = c.get("save-on-disconnect", false); - c.addComment("selectionTool", "Tool used when selecting bounds for restricted area"); - if (CMIMaterial.get(getSelectionTooldID) == null) - getSelectionTooldID = 294; - else - getSelectionTooldID = c.get("selectionTool", 294); + c.addComment("selectionTool", "Tool used when selecting bounds for restricted area."); + getSelectionTool = c.get("selectionTool", "golden_hoe"); c.addComment("MultiServerCompatability", "Enable if you are using one data base for multiple servers across bungee network", "This will force to load players data every time he is logging in to have most up to date data instead of having preloaded data", "This will enable automatically save-on-disconnect feature"); MultiServerCompatability = c.get("MultiServerCompatability", false); if (MultiServerCompatability) - saveOnDisconnect = true; + c.set("save-on-disconnect", true); c.addComment("Optimizations.NewVersion", "When set to true staff will be informed about new Jobs plugin version", "You need to have jobs.versioncheck permission node"); @@ -600,7 +577,7 @@ public class GeneralConfigManager { DynamicPaymentEquation.setVariable("totaljobs", 10); DynamicPaymentEquation.setVariable("jobstotalplayers", 10); DynamicPaymentEquation.getValue(); - } catch (Exception e) { + } catch (Throwable e) { Jobs.consoleMsg("&cDynamic payment equation has an invalid property. Disabling feature!"); useDynamicPayment = false; } @@ -654,7 +631,7 @@ public class GeneralConfigManager { Equation.setVariable("totallevel", 1); Equation.getValue(); limit.setMaxEquation(Equation); - } catch (Exception e) { + } catch (Throwable e) { Jobs.getPluginLogger().warning("MoneyLimit has an invalid value. Disabling money limit!"); limit.setEnabled(false); } @@ -688,7 +665,7 @@ public class GeneralConfigManager { Equation.setVariable("totallevel", 1); Equation.getValue(); limit.setMaxEquation(Equation); - } catch (Exception e) { + } catch (Throwable e) { Jobs.getPluginLogger().warning("PointLimit has an invalid value. Disabling money limit!"); limit.setEnabled(false); } @@ -722,7 +699,7 @@ public class GeneralConfigManager { Equation.setVariable("totallevel", 1); Equation.getValue(); limit.setMaxEquation(Equation); - } catch (Exception e) { + } catch (Throwable e) { Jobs.getPluginLogger().warning("ExpLimit has an invalid value. Disabling money limit!"); limit.setEnabled(false); } @@ -928,7 +905,7 @@ public class GeneralConfigManager { tmat = CMIMaterial.get(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN")); guiBackButton = tmat == null ? CMIMaterial.JACK_O_LANTERN.newItemStack() : tmat.newItemStack(); - tmat = CMIMaterial.get(c.get("JobsGUI.Filler.Material", "STAINED_GLASS_PANE")); + tmat = CMIMaterial.get(c.get("JobsGUI.Filler.Material", "GREEN_STAINED_GLASS_PANE")); guiFiller = tmat == null ? CMIMaterial.GREEN_STAINED_GLASS_PANE.newItemStack() : tmat.newItemStack(); // c.addComment("Schedule.Boost.Enable", "Do you want to enable scheduler for global boost?"); @@ -937,8 +914,8 @@ public class GeneralConfigManager { c.save(); } - public int getSelectionTooldID() { - return getSelectionTooldID; + public String getSelectionTool() { + return getSelectionTool; } public boolean isShowNewVersion() { diff --git a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java index 6540cda4..7544d441 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java @@ -17,7 +17,6 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; @@ -322,7 +321,7 @@ public class ShopManager { ConfigurationSection ConfCategory = f.getConfigurationSection("Items"); ArrayList<String> categoriesList = new ArrayList<>(ConfCategory.getKeys(false)); - if (categoriesList.size() == 0) + if (categoriesList.isEmpty()) return; int i = 0; int y = 1; @@ -433,13 +432,13 @@ public class ShopManager { name = ChatColor.translateAlternateColorCodes('&', itemSection.getString("Name")); List<String> lore = new ArrayList<>(); - if (itemSection.getStringList("Lore") != null && !itemSection.getStringList("Lore").isEmpty()) + if (itemSection.contains("Lore") && !itemSection.getStringList("Lore").isEmpty()) for (String eachLine : itemSection.getStringList("Lore")) { lore.add(ChatColor.translateAlternateColorCodes('&', eachLine)); } HashMap<Enchantment, Integer> enchants = new HashMap<>(); - if (itemSection.getStringList("Enchants") != null && !itemSection.getStringList("Enchants").isEmpty()) + if (itemSection.contains("Enchants") && !itemSection.getStringList("Enchants").isEmpty()) for (String eachLine : itemSection.getStringList("Enchants")) { if (!eachLine.contains("=")) @@ -487,9 +486,8 @@ public class ShopManager { public void CloseInventories() { for (Entry<String, Integer> one : GuiList.entrySet()) { Player player = Bukkit.getPlayer(one.getKey()); - if (player != null) { + if (player != null) player.closeInventory(); - } } } } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobItems.java b/src/main/java/com/gamingmesh/jobs/container/JobItems.java index a5a7be0b..5477bcf4 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobItems.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobItems.java @@ -36,9 +36,9 @@ import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; public class JobItems { private String node; private String legacyKey = null; - ItemStack item; + private ItemStack item; private BoostMultiplier boostMultiplier = new BoostMultiplier(); - private List<Job> jobs = new ArrayList<Job>(); + private List<Job> jobs = new ArrayList<>(); private int fromLevel = 0; private int untilLevel = Integer.MAX_VALUE; @@ -48,24 +48,29 @@ public class JobItems { item = mat.newItemStack(); item.setAmount(amount); ItemMeta meta = item.getItemMeta(); + if (meta == null) + return; + if (name != null) meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); - if (lore != null && !lore.isEmpty()) { + if (lore != null && !lore.isEmpty()) meta.setLore(lore); - } - if (enchants != null) + + if (enchants != null) { if (mat == CMIMaterial.ENCHANTED_BOOK) { EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta) meta; for (Entry<Enchantment, Integer> oneEnch : bookMeta.getEnchants().entrySet()) { bookMeta.addStoredEnchant(oneEnch.getKey(), oneEnch.getValue(), true); } - } else + } else { for (Entry<Enchantment, Integer> OneEnchant : enchants.entrySet()) { meta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true); } + } + } item.setItemMeta(meta); item = Jobs.getReflections().setNbt(item, "JobsItemBoost", node); - } catch (Exception e) { + } catch (Throwable e) { e.printStackTrace(); } @@ -80,7 +85,7 @@ public class JobItems { public ItemStack getItemStack(Player player) { if (player == null) - return this.item; + return item; try { ItemStack item = this.item.clone(); @@ -96,8 +101,7 @@ public class JobItems { } item.setItemMeta(meta); return item; - } catch (Exception e) { - + } catch (Throwable e) { } return null; } diff --git a/src/main/java/com/gamingmesh/jobs/economy/PointsData.java b/src/main/java/com/gamingmesh/jobs/economy/PointsData.java index cc871d39..3c630a30 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/PointsData.java +++ b/src/main/java/com/gamingmesh/jobs/economy/PointsData.java @@ -26,11 +26,12 @@ public class PointsData { } public void addPlayer(UUID uuid, double points, double total) { - addPlayer(uuid, new PlayerPoints(points,total)); + addPlayer(uuid, new PlayerPoints(points, total)); } public void addPlayer(UUID uuid, PlayerPoints points) { - if (Jobs.getGCManager().MultiServerCompatability()&&Pointbase.containsKey(uuid)) Pointbase.remove(uuid); + if (Jobs.getGCManager().MultiServerCompatability() && Pointbase.containsKey(uuid)) + Pointbase.remove(uuid); if (!Pointbase.containsKey(uuid)) Pointbase.put(uuid, points); } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 0cd55113..ddaa26af 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -71,6 +71,7 @@ import org.bukkit.permissions.PermissionDefault; import org.bukkit.plugin.PluginManager; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; import com.gamingmesh.jobs.Gui.GuiInfoList; import com.gamingmesh.jobs.api.JobsAreaSelectionEvent; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; @@ -149,9 +150,7 @@ public class JobsListener implements Listener { ItemStack iih = Jobs.getNms().getItemInMainHand(player); if (iih == null || iih.getType() == Material.AIR) return; - @SuppressWarnings("deprecation") - int heldItemId = iih.getType().getId(); - if (heldItemId != Jobs.getGCManager().getSelectionTooldID()) + if (!iih.getType().equals(CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getMaterial())) return; if (!player.hasPermission("jobs.area.select")) diff --git a/src/main/resources/locale/messages_hu.yml b/src/main/resources/locale/messages_hu.yml index 87859fdb..8abf2908 100644 --- a/src/main/resources/locale/messages_hu.yml +++ b/src/main/resources/locale/messages_hu.yml @@ -32,9 +32,9 @@ general: fromconsole: '&cEz a parancs csak a konzolon használható!' worldisdisabled: '&cNem tudsz használni parancsot ebben a világban!' newFurnaceRegistration: '&eA kemence új tulajdonosa regisztrálva &7[current]&e/&f[max]' - newBrewingRegistration: '&eA Potions Support új tulajdonosa regisztrálva &7[current]&e/&f[max]' + newBrewingRegistration: '&eA főzőállvány új tulajdonosa regisztrálva &7[current]&e/&f[max]' noFurnaceRegistration: '&cElérted a kemencék maximális számát!' - noBrewingRegistration: '&cElérted a bájital főzés maximális számát!' + noBrewingRegistration: '&cElérted a főzőállvány regisztrációk maximális számát!' command: help: output: @@ -91,6 +91,8 @@ command: args: '' output: list: '&e[jobname]: %money% %points% %exp%' + hover: '&7%itemtype%' + hoverLevelLimits: '&7Szinttől kezdve: %from% \n&7Eddig a szintig: %until%' edititembonus: help: info: 'Tárgybónusz szerkesztése.'