From e933bc3a84e99dfe12c2ecf79afee9bac4a23a70 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Wed, 26 Aug 2020 22:06:05 +0200 Subject: [PATCH] Split boost times and add info about timed boosts --- .../gamingmesh/jobs/CMILib/ItemManager.java | 10 +- .../jobs/commands/list/expboost.java | 175 +++++++----------- .../jobs/commands/list/moneyboost.java | 175 +++++++----------- .../jobs/commands/list/pointboost.java | 175 +++++++----------- .../gamingmesh/jobs/config/ConfigManager.java | 14 +- .../jobs/config/LanguageManager.java | 12 +- .../jobs/config/NameTranslatorManager.java | 10 +- .../com/gamingmesh/jobs/container/Job.java | 13 +- .../com/gamingmesh/jobs/container/Potion.java | 52 +++--- .../gamingmesh/jobs/stuff/TabComplete.java | 3 + 10 files changed, 244 insertions(+), 395 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index f35f70f2..151ec970 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -9,6 +9,7 @@ import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; +import com.gamingmesh.jobs.container.Potion; import com.gamingmesh.jobs.stuff.Util; public class ItemManager { @@ -50,7 +51,11 @@ public class ItemManager { mojangName = mojangName == null ? mat.toString().replace("_", "").replace(" ", "").toLowerCase() : mojangName.replace("_", "").replace(" ", "").toLowerCase(); - if (byName.containsKey(cmiName)) { + if (one.isCanHavePotionType()) { + for (Potion p : Potion.values()) { + byName.put(cmiName + ":" + p.toString().toLowerCase(), one); + } + } else if (byName.containsKey(cmiName)) { byName.put(cmiName + ":" + data, one); } else byName.put(cmiName, one); @@ -92,7 +97,6 @@ public class ItemManager { if (one.getLegacyData() == 0) byId.put(one.getLegacyId(), one); byRealMaterial.put(mat, one); - } } @@ -206,7 +210,7 @@ public class ItemManager { cmat = CMIMaterial.get(name); } - if (cmat != null && !cmat.equals(CMIMaterial.NONE)) { + if (cmat != null && cmat != CMIMaterial.NONE) { cm = cmat.newCMIItemStack(); } else cmat = CMIMaterial.get(subdata == null ? original : original + ":" + subdata); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java index e4171e34..edd0f1b4 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java @@ -18,91 +18,44 @@ public class expboost implements Cmd { return true; } - String time = ""; double rate = 1.0; if (args[0].equalsIgnoreCase("all")) { - if (args.length > 2) { - time = args[1].toLowerCase(); - - try { - rate = Double.parseDouble(args[2]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "expboost"); - return true; - } - } else { - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "expboost"); - return true; - } - } - - if (args.length > 2) { - int sec = 0, min = 0, hour = 0; - - if (!time.isEmpty()) { - if (time.contains("s")) { - sec = Integer.parseInt(time.split("s")[0]); - } - - if (time.contains("m")) { - min = Integer.parseInt(time.split("m")[0]); - } - - if (time.contains("h")) { - hour = Integer.parseInt(time.split("h")[0]); - } - } - - boolean succeed = false; - for (Job one : Jobs.getJobs()) { - if (time.isEmpty()) { - one.addBoost(CurrencyType.EXP, rate); - succeed = true; - } else if (sec != 0 || min != 0 || hour != 0) { - one.addBoost(CurrencyType.EXP, rate, hour, min, sec); - succeed = true; - } - } - - if (succeed) { - sender.sendMessage( - Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate)); - return true; - } - } else { - for (Job job : Jobs.getJobs()) { - job.addBoost(CurrencyType.EXP, rate); - } - - sender.sendMessage( - Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate)); + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); return true; } - } - if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.addBoost(CurrencyType.EXP, 1.0); + for (Job job : Jobs.getJobs()) { + job.addBoost(CurrencyType.EXP, rate, parseTime(args)); } - sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset")); + sender.sendMessage( + Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate)); return true; } - if (args[0].equalsIgnoreCase("reset") && args.length > 1) { - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; + if (args[0].equalsIgnoreCase("reset")) { + if (args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.addBoost(CurrencyType.EXP, 1.0); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.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.EXP, 1.0); + + sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", + "%jobname%", job.getName())); } - job.addBoost(CurrencyType.EXP, 1.0); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", "%jobname%", - job.getName())); return true; } @@ -112,50 +65,46 @@ public class expboost implements Cmd { return true; } - if (args.length > 2) { - time = args[1].toLowerCase(); - - try { - rate = Double.parseDouble(args[2]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "expboost"); - return true; - } - } else { - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "expboost"); - return true; - } + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); + return true; } - if (!time.isEmpty()) { - int sec = 0, min = 0, hour = 0; - - if (time.contains("s")) { - sec = Integer.parseInt(time.split("s")[0]); - } - - if (time.contains("m")) { - min = Integer.parseInt(time.split("m")[0]); - } - - if (time.contains("h")) { - hour = Integer.parseInt(time.split("h")[0]); - } - - if (sec != 0 || min != 0 || hour != 0) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, - "%jobname%", job.getName())); - job.addBoost(CurrencyType.EXP, rate, hour, min, sec); - return true; - } - } - - job.addBoost(CurrencyType.EXP, rate); + job.addBoost(CurrencyType.EXP, rate, parseTime(args)); sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.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; + } + + if (time.contains("s") || time.contains("second")) { + arr[0] = Integer.parseInt(time.split("s|second")[0]); + } + + if (time.contains("m") || time.contains("minute")) { + arr[1] = Integer.parseInt(time.split("m|minute")[0]); + } + + if (time.contains("h") || time.contains("hour")) { + arr[2] = Integer.parseInt(time.split("h|hour")[0]); + } + + 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/commands/list/moneyboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java index 913922a8..6ee726b6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java @@ -18,91 +18,44 @@ public class moneyboost implements Cmd { return true; } - String time = ""; double rate = 1.0; if (args[0].equalsIgnoreCase("all")) { - if (args.length > 2) { - time = args[1].toLowerCase(); - - try { - rate = Double.parseDouble(args[2]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "moneyboost"); - return true; - } - } else { - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "moneyboost"); - return true; - } - } - - if (args.length > 2) { - int sec = 0, min = 0, hour = 0; - - if (!time.isEmpty()) { - if (time.contains("s")) { - sec = Integer.parseInt(time.split("s")[0]); - } - - if (time.contains("m")) { - min = Integer.parseInt(time.split("m")[0]); - } - - if (time.contains("h")) { - hour = Integer.parseInt(time.split("h")[0]); - } - } - - boolean succeed = false; - for (Job one : Jobs.getJobs()) { - if (time.isEmpty()) { - one.addBoost(CurrencyType.MONEY, rate); - succeed = true; - } else if (sec != 0 || min != 0 || hour != 0) { - one.addBoost(CurrencyType.MONEY, rate, hour, min, sec); - succeed = true; - } - } - - if (succeed) { - sender.sendMessage( - Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate)); - return true; - } - } else { - for (Job job : Jobs.getJobs()) { - job.addBoost(CurrencyType.MONEY, rate); - } - - sender.sendMessage( - Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate)); + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); return true; } - } - if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.addBoost(CurrencyType.MONEY, 1.0); + for (Job job : Jobs.getJobs()) { + job.addBoost(CurrencyType.MONEY, rate, parseTime(args)); } - sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.allreset")); + sender.sendMessage( + Jobs.getLanguage().getMessage("command.moneyboost.output.boostalladded", "%boost%", rate)); return true; } - if (args[0].equalsIgnoreCase("reset") && args.length > 1) { - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - 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())); } - job.addBoost(CurrencyType.MONEY, 1.0); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.jobsboostreset", "%jobname%", - job.getName())); return true; } @@ -112,50 +65,46 @@ public class moneyboost implements Cmd { return true; } - if (args.length > 2) { - time = args[1].toLowerCase(); - - try { - rate = Double.parseDouble(args[2]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "moneyboost"); - return true; - } - } else { - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "moneyboost"); - return true; - } + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "moneyboost"); + return true; } - if (!time.isEmpty()) { - int sec = 0, min = 0, hour = 0; - - if (time.contains("s")) { - sec = Integer.parseInt(time.split("s")[0]); - } - - if (time.contains("m")) { - min = Integer.parseInt(time.split("m")[0]); - } - - if (time.contains("h")) { - hour = Integer.parseInt(time.split("h")[0]); - } - - if (sec != 0 || min != 0 || hour != 0) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", - rate, "%jobname%", job.getName())); - job.addBoost(CurrencyType.MONEY, rate, hour, min, sec); - return true; - } - } - - job.addBoost(CurrencyType.MONEY, rate); + 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; + } + + if (time.contains("s") || time.contains("second")) { + arr[0] = Integer.parseInt(time.split("s|second")[0]); + } + + if (time.contains("m") || time.contains("minute")) { + arr[1] = Integer.parseInt(time.split("m|minute")[0]); + } + + if (time.contains("h") || time.contains("hour")) { + arr[2] = Integer.parseInt(time.split("h|hour")[0]); + } + + 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/commands/list/pointboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java index 78144b47..f2216208 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java @@ -18,91 +18,44 @@ public class pointboost implements Cmd { return true; } - String time = ""; double rate = 1.0; if (args[0].equalsIgnoreCase("all")) { - if (args.length > 2) { - time = args[1].toLowerCase(); - - try { - rate = Double.parseDouble(args[2]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "pointboost"); - return true; - } - } else { - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "pointboost"); - return true; - } - } - - if (args.length > 2) { - int sec = 0, min = 0, hour = 0; - - if (!time.isEmpty()) { - if (time.contains("s")) { - sec = Integer.parseInt(time.split("s")[0]); - } - - if (time.contains("m")) { - min = Integer.parseInt(time.split("m")[0]); - } - - if (time.contains("h")) { - hour = Integer.parseInt(time.split("h")[0]); - } - } - - boolean succeed = false; - for (Job one : Jobs.getJobs()) { - if (time.isEmpty()) { - one.addBoost(CurrencyType.POINTS, rate); - succeed = true; - } else if (sec != 0 || min != 0 || hour != 0) { - one.addBoost(CurrencyType.POINTS, rate, hour, min, sec); - succeed = true; - } - } - - if (succeed) { - sender.sendMessage( - Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate)); - return true; - } - } else { - for (Job job : Jobs.getJobs()) { - job.addBoost(CurrencyType.POINTS, rate); - } - - sender.sendMessage( - Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate)); + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); return true; } - } - if (args[0].equalsIgnoreCase("reset") && args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.addBoost(CurrencyType.POINTS, 1.0); + for (Job job : Jobs.getJobs()) { + job.addBoost(CurrencyType.POINTS, rate, parseTime(args)); } - sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset")); + sender.sendMessage( + Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate)); return true; } - if (args[0].equalsIgnoreCase("reset") && args.length > 1) { - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; + if (args[0].equalsIgnoreCase("reset")) { + if (args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.addBoost(CurrencyType.POINTS, 1.0); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.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.POINTS, 1.0); + + sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", + "%jobname%", job.getName())); } - job.addBoost(CurrencyType.POINTS, 1.0); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", "%jobname%", - job.getName())); return true; } @@ -112,50 +65,46 @@ public class pointboost implements Cmd { return true; } - if (args.length > 2) { - time = args[1].toLowerCase(); - - try { - rate = Double.parseDouble(args[2]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "pointboost"); - return true; - } - } else { - try { - rate = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "pointboost"); - return true; - } + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); + return true; } - if (!time.isEmpty()) { - int sec = 0, min = 0, hour = 0; - - if (time.contains("s")) { - sec = Integer.parseInt(time.split("s")[0]); - } - - if (time.contains("m")) { - min = Integer.parseInt(time.split("m")[0]); - } - - if (time.contains("h")) { - hour = Integer.parseInt(time.split("h")[0]); - } - - if (sec != 0 || min != 0 || hour != 0) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", - rate, "%jobname%", job.getName())); - job.addBoost(CurrencyType.POINTS, rate, hour, min, sec); - return true; - } - } - - job.addBoost(CurrencyType.POINTS, rate); + job.addBoost(CurrencyType.POINTS, rate, parseTime(args)); sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.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; + } + + if (time.contains("s") || time.contains("second")) { + arr[0] = Integer.parseInt(time.split("s|second")[0]); + } + + if (time.contains("m") || time.contains("minute")) { + arr[1] = Integer.parseInt(time.split("m|minute")[0]); + } + + if (time.contains("h") || time.contains("hour")) { + arr[2] = Integer.parseInt(time.split("h|hour")[0]); + } + + 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/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 0caacfb2..a3830086 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -838,11 +838,13 @@ public class ConfigManager { String item = guiSection.getString("Item"); String subType = ""; - if (item.contains("-")) { - // uses subType - subType = ":" + item.split("-")[1]; - item = item.split("-")[0]; - } + if (item.contains("-")) { + // uses subType + subType = ":" + item.split("-")[1]; + item = item.split("-")[0]; + } else if (item.contains(":")) { // when we uses tipped arrow effect types + item = item.split(":")[0]; + } CMIMaterial material = CMIMaterial.get(item + (subType)); @@ -1051,7 +1053,7 @@ public class ConfigManager { itemSection.getStringList("lore").stream().map(CMIChatColor::translate).forEach(lore::add); HashMap enchants = new HashMap<>(); - if (itemSection.contains("enchants")) + if (itemSection.isList("enchants")) for (String eachLine : itemSection.getStringList("enchants")) { if (!eachLine.contains("=")) continue; diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 53dc31ec..90892d09 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -122,8 +122,8 @@ public class LanguageManager { c.get("command.help.output.nextPageGui", "&6Next Page"); c.get("command.moneyboost.help.info", "Boosts money gain for all players"); - c.get("command.moneyboost.help.args", "[jobname]/all/reset [rate]/all"); - Jobs.getGCManager().getCommandArgs().put("moneyboost", Arrays.asList("[jobname]", "[rate]")); + c.get("command.moneyboost.help.args", "[jobname]/all/reset [time]/[rate]"); + Jobs.getGCManager().getCommandArgs().put("moneyboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%[rate]")); c.get("command.moneyboost.output.allreset", "All money boosts turned off"); c.get("command.moneyboost.output.jobsboostreset", "Money boost has been turned off for %jobname%"); c.get("command.moneyboost.output.nothingtoreset", "Nothing to reset"); @@ -132,8 +132,8 @@ public class LanguageManager { c.get("command.moneyboost.output.infostats", "&c-----> &aMoney rate x%boost% enabled&c <-------"); c.get("command.pointboost.help.info", "Boosts point gain for all players"); - c.get("command.pointboost.help.args", "[jobname]/all/reset [rate]/all"); - Jobs.getGCManager().getCommandArgs().put("pointboost", Arrays.asList("[jobname]", "[rate]")); + c.get("command.pointboost.help.args", "[jobname]/all/reset [time]/[rate]"); + Jobs.getGCManager().getCommandArgs().put("pointboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%[rate]")); c.get("command.pointboost.output.allreset", "All point boosts turned off"); c.get("command.pointboost.output.jobsboostreset", "Point boost has been turned off for %jobname%"); c.get("command.pointboost.output.nothingtoreset", "Nothing to reset"); @@ -142,8 +142,8 @@ public class LanguageManager { c.get("command.pointboost.output.infostats", "&c-----> &aPoints rate x%boost% enabled&c <-------"); c.get("command.expboost.help.info", "Boosts exp gain for all players"); - c.get("command.expboost.help.args", "[jobname]/all/reset [rate]/all"); - Jobs.getGCManager().getCommandArgs().put("expboost", Arrays.asList("[jobname]", "[rate]")); + c.get("command.expboost.help.args", "[jobname]/all/reset [time]/[rate]"); + Jobs.getGCManager().getCommandArgs().put("expboost", Arrays.asList("[jobname]%%all%%reset", "[time]%%[rate]")); c.get("command.expboost.output.allreset", "All exp boosts turned off"); c.get("command.expboost.output.jobsboostreset", "Exp boost has been turned off for %jobname%"); c.get("command.expboost.output.nothingtoreset", "Nothing to reset"); diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index a4a58ef8..779cf329 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -83,7 +83,7 @@ public class NameTranslatorManager { return nameLs + ":" + nameMeta; } - if (mat.equals(CMIMaterial.NONE)) { + if (mat == CMIMaterial.NONE) { return fallbackMaterialName; } @@ -106,11 +106,11 @@ public class NameTranslatorManager { case TAME: for (NameList one : ListOfEntities) { String ids = one.getId() + ":" + one.getMeta(); - if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(id + ":" + meta) && !one.getId().equalsIgnoreCase("0")) { + if (!one.getMeta().equalsIgnoreCase("") && ids.equalsIgnoreCase(id + ":" + meta) && !one.getId().equals("0")) { return one.getName(); } ids = one.getId(); - if (ids.equalsIgnoreCase(String.valueOf(id)) && !one.getId().equalsIgnoreCase("0")) { + if (ids.equalsIgnoreCase(String.valueOf(id)) && !one.getId().equals("0")) { return one.getName(); } ids = one.getMinecraftName(); @@ -391,9 +391,7 @@ public class NameTranslatorManager { } for (Enchantment one : Enchantment.values()) { - if (one == null) - continue; - if (CMIEnchantment.getName(one) == null) + if (one == null || CMIEnchantment.getName(one) == null) continue; String name = Util.firstToUpperCase(CMIEnchantment.getName(one).toString()).replace("_", " "); diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index aaa79b01..51ed769f 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -116,13 +116,18 @@ public class Job { boost.add(type, Point); } - public void addBoost(CurrencyType type, double point, int hour, int minute, int second) { + public void addBoost(CurrencyType type, double point, int[] times) { + if (times.length < 3) { + addBoost(type, point); + return; + } + final Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); - cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + hour); - cal.set(Calendar.MINUTE, cal.get(Calendar.MINUTE) + minute); - cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + second); + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + times[2]); + cal.set(Calendar.MINUTE, cal.get(Calendar.MINUTE) + times[1]); + cal.set(Calendar.SECOND, cal.get(Calendar.SECOND) + times[0]); long time = cal.getTimeInMillis(); boost.add(type, point, time); diff --git a/src/main/java/com/gamingmesh/jobs/container/Potion.java b/src/main/java/com/gamingmesh/jobs/container/Potion.java index 4a355475..5e96f47c 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Potion.java +++ b/src/main/java/com/gamingmesh/jobs/container/Potion.java @@ -22,40 +22,30 @@ package com.gamingmesh.jobs.container; * API reference for names */ public enum Potion { - AWKWARD("awkward"), - FIRE_RESISTANCE("fire_resistance"), - INSTANT_DAMAGE("instant_damage"), - INSTANT_HEAL("instant_heal"), - INVISIBILITY("invisibility"), - JUMP("jump"), - LUCK("luck"), - MUNDANE("mundane"), - NIGHT_VISION("night_vision"), - LONG_NIGHT_VISION("long_night_vision"), - POISON("poison"), - REGENERATION("regeneration"), - SLOW_FALLING("slow_falling"), - SLOWNESS("slowness"), - SPEED("speed"), - STRENGTH("strength"), - THICK("thick"), - TURTLE_MASTER("turtle_master"), - WATER_BREATHING("water_breathing"), - WEAKNESS("weakness"); - - private final String name; - - Potion(String name) { - this.name = name.toUpperCase(); - } - - public String getName() { - return name; - } + AWKWARD, + FIRE_RESISTANCE, + INSTANT_DAMAGE, + INSTANT_HEAL, + INVISIBILITY, + JUMP, + LUCK, + MUNDANE, + NIGHT_VISION, + LONG_NIGHT_VISION, + POISON, + REGENERATION, + SLOW_FALLING, + SLOWNESS, + SPEED, + STRENGTH, + THICK, + TURTLE_MASTER, + WATER_BREATHING, + WEAKNESS; public static Potion getByName(String name) { for (Potion one : Potion.values()) { - if (one.name.equalsIgnoreCase(name)) { + if (one.toString().equalsIgnoreCase(name)) { return one; } } diff --git a/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java b/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java index 552408a2..27cfc645 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java @@ -64,6 +64,9 @@ public class TabComplete implements TabCompleter { List temp = new ArrayList<>(); for (String ar : t2) { switch (ar) { + case "[time]": + temp.add("1hour10minute20s"); + break; case "[questname]": case "[quest]": Job job = Jobs.getJob(args[i - 1]);