diff --git a/Changelog.txt b/Changelog.txt index 0691f279..e5a7130f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -2,6 +2,8 @@ - Fixed issue when the quest description only showed one lines of list. - Added cost for skipping quests - Fixed SQLException when inserting a job +- Adding and taking exp should calculating correctly +- Fixed exception if the enchantment level is null # 4.14.0 - Fixed %titlename% placeholder does not showed anything diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 97b07e9d..b75f71d3 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -819,7 +819,7 @@ public class ConfigManager { name = itemSection.getString("name"); List lore = new ArrayList<>(); - if (itemSection.contains("lore") && !itemSection.getStringList("lore").isEmpty()) + if (itemSection.contains("lore")) for (String eachLine : itemSection.getStringList("lore")) { lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); } diff --git a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java index 72230a8a..9d8b646f 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java @@ -208,8 +208,6 @@ public class ShopManager { gui.addButton(new CMIGuiButton(i, GUIitem) { @Override public void click(GUIClickType type) { - - //if (!player.hasPermission("jobs.items.bypass")) { for (String onePerm : item.getRequiredPerm()) { if (!player.hasPermission(onePerm)) { player.sendMessage(Jobs.getLanguage().getMessage("command.shop.info.NoPermForItem")); @@ -376,13 +374,17 @@ public class ShopManager { if (!one.contains("-")) continue; - String job = one.split("-")[0]; - int lvl = -1; - try { - lvl = Integer.parseInt(one.split("-")[1]); - } catch (NumberFormatException e) { - continue; + String[] split = one.split("-"); + String job = split[0]; + int lvl = 1; + if (split.length > 2) { + try { + lvl = Integer.parseInt(split[1]); + } catch (NumberFormatException e) { + continue; + } } + RequiredJobs.put(job, lvl); } Sitem.setRequiredJobs(RequiredJobs); @@ -435,15 +437,18 @@ public class ShopManager { if (!eachLine.contains("=")) continue; - Enchantment ench = CMIEnchantment.getEnchantment(eachLine.split("=")[0]); - Integer level = -1; - try { - level = Integer.parseInt(eachLine.split("=")[1]); - } catch (NumberFormatException e) { - continue; + String[] split = eachLine.split("="); + Enchantment ench = CMIEnchantment.getEnchantment(split[0]); + Integer level = 1; + if (split.length > 2) { + try { + level = Integer.parseInt(split[1]); + } catch (NumberFormatException e) { + continue; + } } - if (ench != null && level != -1) + if (ench != null) enchants.put(ench, level); } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java b/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java index 9d13762f..66847562 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java @@ -12,7 +12,8 @@ public class JobsMySQL extends JobsDAO { private String database; JobsMySQL(Jobs plugin, String hostname, String database, String username, String password, String prefix, boolean certificate, boolean ssl, boolean autoReconnect) { - super(plugin, "com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database + "?useUnicode=true&characterEncoding=UTF-8&autoReconnect=" + autoReconnect + "&useSSL=" + ssl + super(plugin, "com.mysql.jdbc.Driver", "jdbc:mysql://" + hostname + "/" + database + + "?maxReconnects=1&useUnicode=true&characterEncoding=UTF-8&autoReconnect=" + autoReconnect + "&useSSL=" + ssl + "&verifyServerCertificate=" + certificate, username, password, prefix); this.database = database; this.setDbType(DataBaseType.MySQL); @@ -111,9 +112,8 @@ public class JobsMySQL extends JobsDAO { @Override public boolean createTable(String query) { - Jobs.consoleMsg(query); Statement statement = null; - if (query == null || query.equals("")) { + if (query == null || query.isEmpty()) { Jobs.consoleMsg("&cCould not create table: query is empty or null."); return false; } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java b/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java index 1658fdcb..6c56d0a2 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java @@ -114,7 +114,7 @@ public class JobsSQLite extends JobsDAO { public boolean createTable(String query) { Statement statement = null; try { - if (query == null || query.equals("")) { + if (query == null || query.isEmpty()) { Jobs.consoleMsg("&cCould not create table: query is empty or null."); return false; }