From 5083a2c50a406b8b5829ddb8a2863a9fd28b7bfd Mon Sep 17 00:00:00 2001 From: montlikadani Date: Thu, 30 Aug 2018 13:20:55 +0200 Subject: [PATCH] Fix potion names --- .../gamingmesh/jobs/CMILib/ItemManager.java | 1 - .../jobs/actions/PotionDrinkInfo.java | 4 +- .../gamingmesh/jobs/config/ConfigManager.java | 9 +- .../jobs/config/NameTranslatorManager.java | 99 +++++++++++++++++++ .../jobs/config/RestrictedBlockManager.java | 3 +- .../jobs/config/ScheduleManager.java | 3 +- .../gamingmesh/jobs/config/TitleManager.java | 3 +- src/main/resources/jobConfig.yml | 21 ++-- 8 files changed, 126 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index 4d7bfa14..ab1a52fe 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -2076,7 +2076,6 @@ public class ItemManager { return false; } - // TODO public static boolean isPotion(Material mat) { CMIMaterial m = CMIMaterial.get(mat); if (m == null) diff --git a/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java b/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java index a399230d..1249b1ae 100644 --- a/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java +++ b/src/main/java/com/gamingmesh/jobs/actions/PotionDrinkInfo.java @@ -27,9 +27,9 @@ import com.gamingmesh.jobs.container.BaseActionInfo; public class PotionDrinkInfo extends BaseActionInfo implements ActionInfo { private String potion; - public PotionDrinkInfo(String item, ActionType type) { + public PotionDrinkInfo(String potion, ActionType type) { super(type); - this.potion = item; + this.potion = potion; } @Override diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 7811f650..ce56abd6 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -39,6 +39,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.potion.PotionType; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.CMILib.ItemManager.CMIEntityType; @@ -84,7 +85,7 @@ public class ConfigManager { try { f.createNewFile(); } catch (IOException e) { - Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!"); + Jobs.getPluginLogger().severe("Unable to create jobConfig.yml! No jobs were loaded!"); try { if (s != null) s.close(); @@ -340,6 +341,11 @@ public class ConfigManager { Jobs.getExplore().setPlayerAmount(amount + 1); } else if (actionType == ActionType.CRAFT && myKey.startsWith("!")) { type = myKey.substring(1, myKey.length()); + } else if (actionType == ActionType.DRINK) { + type = myKey; + PotionType potion = PotionType.valueOf(myKey); + if (potion != null) + type = potion.name().toUpperCase().replace("_", "").toLowerCase(); } if (type == null) { @@ -1041,6 +1047,7 @@ public class ConfigManager { case ENCHANT: case DYE: case EAT: + case DRINK: case CRAFT: case BREAK: if (Jobs.getVersionCheckManager().getVersion().isEqualOrHigher(Version.v1_13_R1)) { diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index 8c824437..23b87a4b 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -19,6 +19,7 @@ public class NameTranslatorManager { private Jobs plugin; public ArrayList ListOfNames = new ArrayList<>(); + public ArrayList ListOfPotionNames = new ArrayList<>(); public ArrayList ListOfEntities = new ArrayList<>(); public ArrayList ListOfEnchants = new ArrayList<>(); public ArrayList ListOfColors = new ArrayList<>(); @@ -112,6 +113,13 @@ public class NameTranslatorManager { case MMKILL: return Jobs.getMythicManager().getDisplayName(materialName); + case DRINK: + for (NameList one : ListOfPotionNames) { + String ids = one.getMinecraftName(); + if (ids.equalsIgnoreCase(String.valueOf(info.getName()))) { + return one.getName(); + } + } default: break; } @@ -170,6 +178,18 @@ public class NameTranslatorManager { ListOfColors.add(new NameList(id, meta, Name, MCName)); } Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfColors.size() + " custom color names!"); + + section = ItemFile.getConfig().getConfigurationSection("PotionNamesList"); + keys = section.getKeys(false); + ListOfPotionNames.clear(); + for (String one : keys) { + String id = one.contains(":") ? one.split(":")[0] : one; + String meta = one.contains(":") ? one.split(":")[1] : ""; + String MCName = section.getString(one + ".MCName"); + String Name = section.getString(one + ".Name"); + ListOfColors.add(new NameList(id, meta, Name, MCName)); + } + Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfPotionNames.size() + " custom potion names!"); } synchronized void load() { @@ -1672,6 +1692,85 @@ public class NameTranslatorManager { c.get("ColorList.14.Name", "&cRed"); c.get("ColorList.15.MCName", "black"); c.get("ColorList.15.Name", "&0Black"); + + // Potion name list + c.get("PotionNamesList.0.MCName", "POTION"); + c.get("PotionNamesList.0.Name", "Potion"); + c.get("PotionNamesList.1.MCName", "AWKWARD_POTION"); + c.get("PotionNamesList.1.Name", "Awkward potion"); + c.get("PotionNamesList.2.MCName", "THICK_POTION"); + c.get("PotionNamesList.2.Name", "Thick potion"); + c.get("PotionNamesList.3.MCName", "MUNDANE_POTION"); + c.get("PotionNamesList.3.Name", "Mundane potion"); + c.get("PotionNamesList.4.MCName", "REGENERATION_POTION"); + c.get("PotionNamesList.4.Name", "Regeneration potion"); + c.get("PotionNamesList.5.MCName", "SWIFTNESS_POTION"); + c.get("PotionNamesList.5.Name", "Swiftness potion"); + c.get("PotionNamesList.6.MCName", "FIRE_RESISTANCE_POTION"); + c.get("PotionNamesList.6.Name", "Fire resistance potion"); + c.get("PotionNamesList.7.MCName", "POISON_POTION"); + c.get("PotionNamesList.7.Name", "Poison potion"); + c.get("PotionNamesList.8.MCName", "HEALING_POTION"); + c.get("PotionNamesList.8.Name", "Healing potion"); + c.get("PotionNamesList.9.MCName", "NIGHT_VISION_POTION"); + c.get("PotionNamesList.9.Name", "Night vision potion"); + c.get("PotionNamesList.10.MCName", "WEAKNESS_POTION"); + c.get("PotionNamesList.10.Name", "Weakness potion"); + c.get("PotionNamesList.11.MCName", "STRENGTH_POTION"); + c.get("PotionNamesList.11.Name", "Strength potion"); + c.get("PotionNamesList.12.MCName", "SLOWNESS_POTION"); + c.get("PotionNamesList.12.Name", "Slowness potion"); + c.get("PotionNamesList.13.MCName", "HARMING_POTION"); + c.get("PotionNamesList.13.Name", "Harming potion"); + c.get("PotionNamesList.14.MCName", "WATER_BREATHING_POTION"); + c.get("PotionNamesList.14.Name", "Water breathing potion"); + c.get("PotionNamesList.15.MCName", "INVISIBILITY_POTION"); + c.get("PotionNamesList.15.Name", "Inivisibility potion"); + c.get("PotionNamesList.16.MCName", "REGENERATION_POTION2"); + c.get("PotionNamesList.16.Name", "Regeneration potion 2"); + c.get("PotionNamesList.17.MCName", "SWIFTNESS_POTION2"); + c.get("PotionNamesList.17.Name", "Swiftness potion 2"); + c.get("PotionNamesList.18.MCName", "POISON_POTION2"); + c.get("PotionNamesList.18.Name", "Poison potion 2"); + c.get("PotionNamesList.19.MCName", "HEALING_POTION2"); + c.get("PotionNamesList.19.Name", "Healing potion 2"); + c.get("PotionNamesList.20.MCName", "STRENGTH_POTION2"); + c.get("PotionNamesList.20.Name", "Strength potion 2"); + c.get("PotionNamesList.21.MCName", "LEAPING_POTION2"); + c.get("PotionNamesList.21.Name", "Leaping potion 2"); + c.get("PotionNamesList.22.MCName", "HARMING_POTION2"); + c.get("PotionNamesList.22.Name", "Harming potion 2"); + c.get("PotionNamesList.23.MCName", "REGENERATION_POTION3"); + c.get("PotionNamesList.23.Name", "Regeneration potion 3"); + c.get("PotionNamesList.24.MCName", "SWIFTNESS_POTION3"); + c.get("PotionNamesList.24.Name", "Swiftness potion 3"); + c.get("PotionNamesList.25.MCName", "FIRE_RESISTANCE_POTION3"); + c.get("PotionNamesList.25.Name", "Fire resistance potion 3"); + c.get("PotionNamesList.26.MCName", "POISON_POTION3"); + c.get("PotionNamesList.26.Name", "Poison potion 3"); + c.get("PotionNamesList.27.MCName", "NIGHT_VISION_POTION2"); + c.get("PotionNamesList.27.Name", "Night vision potion 2"); + c.get("PotionNamesList.28.MCName", "WEAKNESS_POTION2"); + c.get("PotionNamesList.28.Name", "Weakness potion 2"); + c.get("PotionNamesList.29.MCName", "STRENGTH_POTION3"); + c.get("PotionNamesList.29.Name", "Strength potion 3"); + c.get("PotionNamesList.30.MCName", "SLOWNESS_POTION2"); + c.get("PotionNamesList.30.Name", "Slowness potion 2"); + c.get("PotionNamesList.31.MCName", "LEAPING_POTION3"); + c.get("PotionNamesList.31.Name", "Leaping potion 3"); + c.get("PotionNamesList.32.MCName", "WATER_BREATHING_POTION2"); + c.get("PotionNamesList.32.Name", "Water breathing potion 2"); + c.get("PotionNamesList.33.MCName", "INVISIBILITY_POTION2"); + c.get("PotionNamesList.33.Name", "Invisibility potion 2"); + c.get("PotionNamesList.34.MCName", "REGENERATION_POTION4"); + c.get("PotionNamesList.34.Name", "Regeneration potion 4"); + c.get("PotionNamesList.35.MCName", "SWIFTNESS_POTION4"); + c.get("PotionNamesList.35.Name", "Swiftness potion 4"); + c.get("PotionNamesList.36.MCName", "POISON_POTION4"); + c.get("PotionNamesList.36.Name", "Poison potion 4"); + c.get("PotionNamesList.37.MCName", "STRENGTH_POTION4"); + c.get("PotionNamesList.37.Name", "Strength potion 4"); + try { c.getW().save(f); } catch (IOException e) { diff --git a/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java b/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java index b921c8dc..9f98ffc1 100644 --- a/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java @@ -169,7 +169,8 @@ public class RestrictedBlockManager { } c.copySetting("blocksTimer"); - Jobs.consoleMsg("&e[Jobs] Loaded " + this.restrictedBlocksTimer.size() + " protected blocks timers!"); + if (restrictedBlocksTimer.size() != 0) + Jobs.consoleMsg("&e[Jobs] Loaded " + this.restrictedBlocksTimer.size() + " protected blocks timers!"); try { writer.save(f); } catch (IOException e) { diff --git a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java index 3c1584df..f7eaa252 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java @@ -236,6 +236,7 @@ public class ScheduleManager { Jobs.getGCManager().BoostSchedule.add(sched); } - Jobs.consoleMsg("&e[Jobs] Loaded " + Jobs.getGCManager().BoostSchedule.size() + " schedulers!"); + if (Jobs.getGCManager().BoostSchedule.size() != 0) + Jobs.consoleMsg("&e[Jobs] Loaded " + Jobs.getGCManager().BoostSchedule.size() + " schedulers!"); } } diff --git a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java index 24864654..47cf8a52 100644 --- a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java @@ -178,6 +178,7 @@ public class TitleManager { this.titles.add(new Title(titleName, titleShortName, titleColor, levelReq, jobName)); } - Jobs.consoleMsg("&e[Jobs] Loaded " + titles.size() + " titles!"); + 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 523d61e0..19d39a29 100644 --- a/src/main/resources/jobConfig.yml +++ b/src/main/resources/jobConfig.yml @@ -230,6 +230,17 @@ Jobs: # if not given, then there is no limit # this can be used for any action until-level: 30 + # payment for drinking a potion + Drink: + POTION: + income: 0.5 + experience: 2.0 + REGENERATION_POTION2: + income: 1.3 + experience: 2.0 + HEALING_POTION: + income: 1.4 + experience: 2.0 # payment for breaking a block with tnt TNTBreak: LOG: @@ -417,16 +428,6 @@ Jobs: REDSTONE: income: 5.0 experience: 3.0 - Drink: - POTION: - income: 0.5 - experience: 2.0 - REGENERATION_POTION2: - income: 1.3 - experience: 2.0 - HEALING_POTION: - income: 1.4 - experience: 2.0 # Explore options. Each number represents players number in exploring that chunk # 1 means that player is first in this chunk, 2 is second and so on, so you can give money not only for first player ho discovers that chunk Explore: