diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 1bb7d3ed..8b1db251 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -378,7 +378,7 @@ public class ConfigManager { type = myKey; PotionType potion = PotionType.valueOf(myKey); if (potion != null) - type = potion.name().toUpperCase().replace("_", "").toLowerCase(); + type = potion.name().toString().replace("_", "").toLowerCase(); } if (type == null) { @@ -620,16 +620,15 @@ public class ConfigManager { GUIitem = material.newItemStack(); if (guiSection.contains("Enchantments")) { List enchants = guiSection.getStringList("Enchantments"); - if (enchants.size() > 0) { + if (!enchants.isEmpty()) { for (String str4 : enchants) { String[] enchantid = str4.split(":"); if ((GUIitem.getItemMeta() instanceof EnchantmentStorageMeta)) { EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta(); enchantMeta.addStoredEnchant(Enchantment.getByName(enchantid[0]), Integer.parseInt(enchantid[1]), true); GUIitem.setItemMeta(enchantMeta); - } else { + } else GUIitem.addUnsafeEnchantment(Enchantment.getByName(enchantid[0]), Integer.parseInt(enchantid[1])); - } } } } else if (guiSection.contains("CustomSkull")) { @@ -657,9 +656,8 @@ public class ConfigManager { EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta) GUIitem.getItemMeta(); enchantMeta.addStoredEnchant(Enchantment.getByName(id[0]), Integer.parseInt(id[1]), true); GUIitem.setItemMeta(enchantMeta); - } else { + } else GUIitem.addUnsafeEnchantment(Enchantment.getByName(id[0]), Integer.parseInt(id[1])); - } } } } else if (guiSection.contains("CustomSkull")) { @@ -723,15 +721,13 @@ public class ConfigManager { // Command on leave List JobsCommandOnLeave = new ArrayList<>(); - if (jobSection.isList("cmd-on-leave")) { + if (jobSection.isList("cmd-on-leave")) JobsCommandOnLeave = jobSection.getStringList("cmd-on-leave"); - } // Command on join List JobsCommandOnJoin = new ArrayList<>(); - if (jobSection.isList("cmd-on-join")) { + if (jobSection.isList("cmd-on-join")) JobsCommandOnJoin = jobSection.getStringList("cmd-on-join"); - } // Commands ArrayList jobCommand = new ArrayList<>(); @@ -883,7 +879,15 @@ public class ConfigManager { String name = sqsection.getString("Name", one); ActionType actionType = ActionType.getByName(sqsection.getString("Action")); - KeyValues kv = getKeyValue(sqsection.getString("Target"), actionType, jobName); + KeyValues kv = null; + if (sqsection.isString("Target")) + kv = getKeyValue(sqsection.getString("Target"), actionType, jobName); + else if (sqsection.isList("Target")) { + for (int i = 0; i < sqsection.getStringList("Target").size(); i++) { + kv = getKeyValue(sqsection.getStringList("Target").get(i), actionType, jobName); + } + } + if (kv == null) continue; int amount = sqsection.getInt("Amount"); @@ -894,13 +898,11 @@ public class ConfigManager { Quest quest = new Quest(name, job, actionType); - if (sqsection.contains("fromLevel") && sqsection.isInt("fromLevel")) { + if (sqsection.contains("fromLevel") && sqsection.isInt("fromLevel")) quest.setMinLvl(sqsection.getInt("fromLevel")); - } - if (sqsection.contains("toLevel") && sqsection.isInt("toLevel")) { + if (sqsection.contains("toLevel") && sqsection.isInt("toLevel")) quest.setMaxLvl(sqsection.getInt("toLevel")); - } quest.setConfigName(one); quest.setAmount(amount); @@ -1137,8 +1139,17 @@ public class ConfigManager { } Jobs.getExplore().setExploreEnabled(); Jobs.getExplore().setPlayerAmount(amount + 1); - } else if (actionType == ActionType.CRAFT && myKey.startsWith("!")) { + } else if (actionType == ActionType.CRAFT && myKey.startsWith("!")) type = myKey.substring(1, myKey.length()); + else if (actionType == ActionType.DRINK) { + type = myKey; + try { + PotionType potion = PotionType.valueOf(myKey); + if (potion != null) + type = potion.name().toString().replace("_", "").toLowerCase(); + } catch (IllegalArgumentException i) { + Jobs.getPluginLogger().warning("Job" + jobKey + " has an invalid potion " + myKey + "!"); + } } if (type == null) { @@ -1178,17 +1189,16 @@ public class ConfigManager { job.setJobInfo(actionType, jobInfo); } - if (jobKey.equalsIgnoreCase("none")) { + if (jobKey.equalsIgnoreCase("none")) Jobs.setNoneJob(job); - } else { + else jobs.add(job); - } } Jobs.consoleMsg("&e[Jobs] Loaded " + Jobs.getJobs().size() + " jobs!"); - if (!Jobs.getExplore().isExploreEnabled()) { + if (!Jobs.getExplore().isExploreEnabled()) Jobs.consoleMsg("&6[Jobs] Explorer jobs manager are not enabled!"); - } else + else Jobs.consoleMsg("&e[Jobs] Explorer job manager registered!"); // Lets load item boosts diff --git a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java index ef19deb2..1a64c6b9 100644 --- a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java @@ -15,9 +15,6 @@ public class TitleManager { protected List titles = new ArrayList<>(); - public TitleManager() { - } - /** * Function to return the title for a given level * @return the correct title @@ -27,13 +24,11 @@ public class TitleManager { Title title = null; for (Title t : titles) { if (title == null) { - if (t.getLevelReq() <= level && (t.getJobName() == null || t.getJobName().equalsIgnoreCase(jobName))) { + if (t.getLevelReq() <= level && (t.getJobName() == null || t.getJobName().equalsIgnoreCase(jobName))) title = t; - } } else { - if (t.getLevelReq() <= level && t.getLevelReq() > title.getLevelReq() && (t.getJobName() == null || t.getJobName().equalsIgnoreCase(jobName))) { + if (t.getLevelReq() <= level && t.getLevelReq() > title.getLevelReq() && (t.getJobName() == null || t.getJobName().equalsIgnoreCase(jobName))) title = t; - } } } return title; @@ -45,7 +40,7 @@ public class TitleManager { * loads from Jobs/titleConfig.yml */ synchronized void load() { - this.titles.clear(); + titles.clear(); ConfigReader c = null; try { @@ -72,56 +67,56 @@ public class TitleManager { if (titleSection == null) { titleSection = c.getC().createSection("Titles"); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Novice.Name", "N"), c.get("Titles.Novice.ShortName", "N"), ChatColor.matchColor(c.get("Titles.Novice.ChatColour", "YELLOW")), c.get("Titles.Novice.levelReq", 0), null)); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Apprentice.Name", "A"), c.get("Titles.Apprentice.ShortName", "A"), ChatColor.matchColor(c.get("Titles.Apprentice.ChatColour", "WHITE")), c.get("Titles.Apprentice.levelReq", 25), null)); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Initiate.Name", "I"), c.get("Titles.Initiate.ShortName", "I"), ChatColor.matchColor(c.get("Titles.Initiate.ChatColour", "GOLD")), c.get("Titles.Initiate.levelReq", 50), null)); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Journeyman.Name", "J"), c.get("Titles.Journeyman.ShortName", "J"), ChatColor.matchColor(c.get("Titles.Journeyman.ChatColour", "DARK_GREEN")), c.get("Titles.Journeyman.levelReq", 75), null)); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Adept.Name", "Ad"), c.get("Titles.Adept.ShortName", "Ad"), ChatColor.matchColor(c.get("Titles.Adept.ChatColour", "DARK_PURPLE")), c.get("Titles.Adept.levelReq", 100), null)); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Master.Name", "M"), c.get("Titles.Master.ShortName", "M"), ChatColor.matchColor(c.get("Titles.Master.ChatColour", "GRAY")), c.get("Titles.Master.levelReq", 125), null)); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Grandmaster.Name", "GM"), c.get("Titles.Grandmaster.ShortName", "GM"), ChatColor.matchColor(c.get("Titles.Grandmaster.ChatColour", "DARK_GRAY")), c.get("Titles.Grandmaster.levelReq", 150), null)); - this.titles.add(new Title( + titles.add(new Title( c.get("Titles.Legendary.Name", "L"), c.get("Titles.Legendary.ShortName", "L"), ChatColor.matchColor(c.get("Titles.Legendary.ChatColour", "BLACK")), @@ -136,9 +131,8 @@ public class TitleManager { ChatColor titleColor = ChatColor.matchColor(titleSection.getString(titleKey + ".ChatColour", "")); int levelReq = titleSection.getInt(titleKey + ".levelReq", -1); - if (titleSection.isString(titleKey + ".JobName")) { + if (titleSection.isString(titleKey + ".JobName")) jobName = titleSection.getString(titleKey + ".JobName"); - } if (titleName == null) { Jobs.getPluginLogger().severe("Title " + titleKey + " has an invalid Name property. Skipping!"); @@ -158,9 +152,9 @@ public class TitleManager { continue; } - this.titles.add(new Title(titleName, titleShortName, titleColor, levelReq, jobName)); + titles.add(new Title(titleName, titleShortName, titleColor, levelReq, jobName)); } - if (titles.size() != 0) + if (titles.size() > 0) Jobs.consoleMsg("&e[Jobs] Loaded " + titles.size() + " titles!"); } } diff --git a/src/main/resources/jobConfig.yml b/src/main/resources/jobConfig.yml index 008c25d7..b67f19e9 100644 --- a/src/main/resources/jobConfig.yml +++ b/src/main/resources/jobConfig.yml @@ -105,7 +105,11 @@ Jobs: # Quest action can be any valid job action. Look at lower for all possible action types Action: Break # Target id or name. Comes in same format as it is for regular job action + # You can use only string or list to add more items in one quest Target: "17-0" + # Target: + # - "17-0" + # - stone # Amount of actions players should perform to complete this quest Amount: 300 # Command list to be performed after quest is finished. @@ -150,6 +154,17 @@ Jobs: RewardDesc: - "Cook some chicken breasts" - "Get 300 for this!" + 4: + Name: "Strip logs" + Action: StripLogs + Target: + - stripped_birch_log + - stripped_acacia_log + Amount: 50 + RewardCommands: + - "msg [playerName] Completed quest!" + RewardDesc: + - "Strip 50 birch and acacia logs!" ######################################################################## # Section used to configure what items the job gets paid for, how much # they get paid and how much experience they gain.