diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index ff40360b..7a29d675 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -125,8 +125,9 @@ public class PlayerManager { // Checking duplicated UUID's which usually is a cause of previous bugs if (playerUUIDMap.containsKey(info.getUuid()) && playerUUIDMap.get(info.getUuid()).getID() != info.getID()) { int id = playerUUIDMap.get(info.getUuid()).getID(); - CMIMessages.consoleMessage("&7Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info.getID()); - + if (Jobs.getGCManager().isInformDuplicates()) + CMIMessages.consoleMessage("&7Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info + .getID()); if (id < info.getID()) { return; } @@ -135,8 +136,9 @@ public class PlayerManager { // Checking duplicated names which usually is a cause of previous bugs if (playerNameMap.containsKey(info.getName().toLowerCase()) && playerNameMap.get(info.getName().toLowerCase()).getID() != info.getID()) { int id = playerNameMap.get(info.getName().toLowerCase()).getID(); - CMIMessages.consoleMessage("&7Name Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info - .getID()); + if (Jobs.getGCManager().isInformDuplicates()) + CMIMessages.consoleMessage("&7Name Duplicate! &5" + info.getName() + " &7same UUID for 2 entries in database. Please remove of one them from users table id1: &2" + id + " &7id2: &2" + info + .getID()); if (id < info.getID()) { return; } @@ -283,7 +285,7 @@ public class PlayerManager { jPlayer.onConnect(); jPlayer.reloadHonorific(); Jobs.getPermissionHandler().recalculatePermissions(jPlayer); - + addPlayerToCache(jPlayer); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java index 02aa22f5..75f8c753 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java @@ -9,123 +9,123 @@ import com.gamingmesh.jobs.container.Job; public class moneyboost implements Cmd { - @Override - public boolean perform(Jobs plugin, CommandSender sender, String[] args) { - if (args.length > 3 || args.length <= 1) { - Jobs.getCommandManager().sendUsage(sender, "moneyboost"); - return true; - } + @Override + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { + if (args.length > 3 || args.length <= 1) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); + return true; + } - double rate = 1.0; - if (args[0].equalsIgnoreCase("all")) { - try { - rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "moneyboost"); - return true; - } - - int[] times = parseTime(args); - - for (Job job : Jobs.getJobs()) { - job.addBoost(CurrencyType.MONEY, rate, times); - } - - sender.sendMessage( - Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate)); - return true; - } - - if (args[0].equalsIgnoreCase("reset")) { - if (args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.addBoost(CurrencyType.MONEY, 1.0); - } - - sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset")); - } else if (args.length > 1) { - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; - } - - job.addBoost(CurrencyType.MONEY, 1.0); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", - "%jobname%", job.getName())); - } - - return true; - } - - Job job = Jobs.getJob(args[0]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; - } - - try { - rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "moneyboost"); - return true; - } - - job.addBoost(CurrencyType.MONEY, rate, parseTime(args)); - sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, - "%jobname%", job.getName())); + double rate = 1.0; + if (args[0].equalsIgnoreCase("all")) { + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); return true; + } + + int[] times = parseTime(args); + + for (Job job : Jobs.getJobs()) { + job.addBoost(CurrencyType.MONEY, rate, times); + } + + sender.sendMessage( + Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate)); + return true; } - private int[] parseTime(String[] args) { - int[] arr = new int[3]; - - if (args.length < 2) { - return arr; + if (args[0].equalsIgnoreCase("reset")) { + if (args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.addBoost(CurrencyType.MONEY, 1.0); } - String time = args[1].toLowerCase(); - if (time.isEmpty()) { - return arr; + sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset")); + } else if (args.length > 1) { + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; } - String[] split = time.split("h|hour", 2); + job.addBoost(CurrencyType.MONEY, 1.0); - if (split.length > 0) { - try { - arr[2] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[2] = 0; - } + sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", + "%jobname%", job.getName())); + } - time = time.replaceAll(arr[2] + "+[h|hour]+", ""); - } - - if ((split = time.split("m|minute", 2)).length > 0) { - try { - arr[1] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[1] = 0; - } - - time = time.replaceAll(arr[1] + "+[m|minute]+", ""); - } - - if ((split = time.split("s|second", 2)).length > 0) { - try { - arr[0] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[0] = 0; - } - - time = time.replaceAll(arr[0] + "+[s|second]+", ""); - } - - if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) { - return new int[3]; - } - - return arr; + return true; } + + Job job = Jobs.getJob(args[0]); + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); + return true; + } + + job.addBoost(CurrencyType.MONEY, rate, parseTime(args)); + sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, + "%jobname%", job.getName())); + return true; + } + + private int[] parseTime(String[] args) { + int[] arr = new int[3]; + + if (args.length < 2) { + return arr; + } + + String time = args[1].toLowerCase(); + if (time.isEmpty()) { + return arr; + } + + String[] split = time.split("h|hour", 2); + + if (split.length > 0) { + try { + arr[2] = Integer.parseInt(split[0]); + } catch (NumberFormatException e) { + arr[2] = 0; + } + + time = time.replaceAll(arr[2] + "+[h|hour]+", ""); + } + + if ((split = time.split("m|minute", 2)).length > 0) { + try { + arr[1] = Integer.parseInt(split[0]); + } catch (NumberFormatException e) { + arr[1] = 0; + } + + time = time.replaceAll(arr[1] + "+[m|minute]+", ""); + } + + if ((split = time.split("s|second", 2)).length > 0) { + try { + arr[0] = Integer.parseInt(split[0]); + } catch (NumberFormatException e) { + arr[0] = 0; + } + + time = time.replaceAll(arr[0] + "+[s|second]+", ""); + } + + if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) { + return new int[3]; + } + + return arr; + } } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 7aba3c5f..68e2cf66 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -82,6 +82,7 @@ public class GeneralConfigManager { public float maxPaymentCurveFactor; private boolean FurnacesReassign, BrewingStandsReassign, useTnTFinder = false, ShowNewVersion; + private boolean InformDuplicates; private FireworkEffect fireworkEffect; @@ -341,6 +342,10 @@ public class GeneralConfigManager { 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"); ShowNewVersion = c.get("Optimizations.NewVersion", true); + + c.addComment("Optimizations.InformDuplicates", + "Can be used to check if your database contains any duplicated user entries."); + InformDuplicates = c.get("Optimizations.InformDuplicates", false); c.addComment("Optimizations.DecimalPlaces.Money", "Decimal places to be shown"); @@ -1154,4 +1159,8 @@ public class GeneralConfigManager { public FireworkEffect getFireworkEffect() { return fireworkEffect; } + + public boolean isInformDuplicates() { + return InformDuplicates; + } }