From b55ad6930c38657e5c5e65cbbc3b76c7ae0122f5 Mon Sep 17 00:00:00 2001 From: HappyPikachu Date: Thu, 1 Feb 2018 02:00:57 -0500 Subject: [PATCH] (UNSTABLE) Lang corrections, reduce duplicate strings - part 4 --- .../me/blackvein/quests/EventFactory.java | 2 +- src/main/java/me/blackvein/quests/Quest.java | 32 ++++-- .../java/me/blackvein/quests/Quester.java | 57 +++++------ src/main/java/me/blackvein/quests/Quests.java | 56 +++++------ .../quests/prompts/CreateStagePrompt.java | 29 +++--- .../quests/prompts/ItemStackPrompt.java | 2 +- .../quests/prompts/RequirementsPrompt.java | 6 +- .../quests/prompts/RewardsPrompt.java | 2 +- .../me/blackvein/quests/util/ItemUtil.java | 7 +- .../java/me/blackvein/quests/util/Lang.java | 58 ++++++----- src/main/resources/strings.yml | 98 +++++++++---------- 11 files changed, 185 insertions(+), 164 deletions(-) diff --git a/src/main/java/me/blackvein/quests/EventFactory.java b/src/main/java/me/blackvein/quests/EventFactory.java index a7e19d4bd..63f749afb 100644 --- a/src/main/java/me/blackvein/quests/EventFactory.java +++ b/src/main/java/me/blackvein/quests/EventFactory.java @@ -2192,7 +2192,7 @@ public class EventFactory implements ConversationAbandonedListener { @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - String[] commands = input.split(","); + String[] commands = input.split(Lang.get("charSemi")); LinkedList cmdList = new LinkedList(); cmdList.addAll(Arrays.asList(commands)); context.setSessionData(CK.E_COMMANDS, cmdList); diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java index 293f4cade..9fcdc7dc6 100644 --- a/src/main/java/me/blackvein/quests/Quest.java +++ b/src/main/java/me/blackvein/quests/Quest.java @@ -17,10 +17,12 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -249,7 +251,8 @@ public class Quest { return false; } } else { - plugin.getLogger().warning("Quester \"" + player.getName() + "\" attempted to take Quest \"" + name + "\", but the Custom Requirement \"" + s + "\" could not be found. Does it still exist?"); + plugin.getLogger().warning("Quester \"" + player.getName() + "\" attempted to take Quest \"" + name + "\", but the Custom Requirement \"" + s + + "\" could not be found. Does it still exist?"); } } if (quester.questPoints < questPointsReq) { @@ -375,25 +378,40 @@ public class Quest { none = null; } for (ItemStack i : itemRewards) { + String text = "error"; if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount()); + text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount(); } else { - player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); + text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " " + Lang.get("with") + + ChatColor.DARK_PURPLE; + for (Entry e : i.getEnchantments().entrySet()) { + text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue(); + } + text += ChatColor.GRAY + " x " + i.getAmount(); } } else if (i.getDurability() != 0) { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount(); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " " + Lang.get("with"); + for (Entry e : i.getEnchantments().entrySet()) { + text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue(); + } + text += ChatColor.GRAY + " x " + i.getAmount(); } } else { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount()); + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount(); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " " + Lang.get("with"); + for (Entry e : i.getEnchantments().entrySet()) { + text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue(); + } + text += ChatColor.GRAY + " x " + i.getAmount(); } } + player.sendMessage(text); none = null; } for (ItemStack i : phatLootItems) { diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 019eede47..1dd21913e 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -1481,7 +1481,13 @@ public class Quester { } return prettyString; } - + + /** + * Gets player-friendly name from type. 'ENDER_DRAGON' becomes 'Ender Dragon' + * + * @param type any mob type, ideally + * @return cleaned-up string + */ public static String prettyMobString(EntityType type) { String baseString = type.toString(); String[] substrings = baseString.split("_"); @@ -1499,21 +1505,26 @@ public class Quester { } return prettyString; } - - public static String prettyString(String s) { - String[] substrings = s.split("_"); - String prettyString = ""; - int size = 1; - for (String sb : substrings) { - prettyString = prettyString.concat(Quester.getCapitalized(sb)); - if (size < substrings.length) { - prettyString = prettyString.concat(" "); - } - size++; - } - return prettyString; + + public static String prettyColorString(DyeColor color) { + return Lang.get("COLOR_" + color.name()); } + public static String prettyEnchantmentString(Enchantment e) { + String prettyString = enchantmentString(e); + prettyString = capitalsToSpaces(prettyString); + return prettyString; + } + + public static String enchantmentString(Enchantment e) { + try { + return (Lang.get("ENCHANTMENT_" + e.getName())); + } catch (NullPointerException ne) { + Bukkit.getLogger().warning(e.getName() + " was not found in Lang.yml, please ask the developer to " + "update the file or simply add an entry for the enchantment"); + return e.getName().toLowerCase().replaceAll("_", " "); + } + } + public static String capitalsToSpaces(String s) { int max = s.length(); for (int i = 1; i < max; i++) { @@ -1536,24 +1547,6 @@ public class Quester { return s; } - public static String prettyEnchantmentString(Enchantment e) { - String prettyString = enchantmentString(e); - prettyString = capitalsToSpaces(prettyString); - return prettyString; - } - - public static String enchantmentString(Enchantment e) { - if (Lang.get("ENCHANTMENT_" + e.getName()).equals("NULL")) { - Bukkit.getLogger().warning(e.getName() + " was not found in Lang.yml, please ask the developer to " + "update the file or simply add an entry for the enchantment"); - return e.getName().toLowerCase().replaceAll("_", " "); - } - return (Lang.get("ENCHANTMENT_" + e.getName())); - } - - public static String prettyColorString(DyeColor color) { - return Lang.get("COLOR_" + color.name()); - } - public void saveData() { FileConfiguration data = getBaseData(); try { diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 3b16ed0ef..5a57f9d53 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -2812,7 +2812,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener stageFailed("enchantments: in Stage " + s2 + " of Quest " + quest.name + " is not a list of enchantment names!"); } if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".enchantment-item-names")) { - if (Quests.checkList(config.getList("quests." + questName + ".stages.ordered." + s2 + ".enchantment-item-names"), Integer.class)) { + if (Quests.checkList(config.getList("quests." + questName + ".stages.ordered." + s2 + ".enchantment-item-names"), String.class)) { for (String item : config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".enchantment-item-names")) { if (Material.matchMaterial(item) != null) { itemsToEnchant.add(Material.matchMaterial(item)); @@ -2821,7 +2821,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } } } else { - stageFailed("enchantment-item-names: in Stage " + s2 + " of Quest " + quest.name + " is not a list of numbers!"); + stageFailed("enchantment-item-names: in Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); } } else { stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing enchantment-item-names:"); @@ -3847,60 +3847,60 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } public static Enchantment getEnchantment(String enchant) { - String ench = Lang.getKey(enchant); + String ench = Lang.getKey(enchant.replaceAll(" ", "")); ench = ench.replace("ENCHANTMENT_", ""); Enchantment e = Enchantment.getByName(ench); - return e != null ? e : getEnchantmentLegacy(ench); + return e != null ? e : getEnchantmentLegacy(ench.replaceAll(" ", "")); } public static Enchantment getEnchantmentLegacy(String enchant) { - if (enchant.equalsIgnoreCase("Power")) { + if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_ARROW_DAMAGE"))) { return Enchantment.ARROW_DAMAGE; - } else if (enchant.equalsIgnoreCase("Flame")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_ARROW_FIRE"))) { return Enchantment.ARROW_FIRE; - } else if (enchant.equalsIgnoreCase("Infinity")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_ARROW_INFINITE"))) { return Enchantment.ARROW_INFINITE; - } else if (enchant.equalsIgnoreCase("Punch")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_ARROW_KNOCKBACK"))) { return Enchantment.ARROW_KNOCKBACK; - } else if (enchant.equalsIgnoreCase("Sharpness")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_DAMAGE_ALL"))) { return Enchantment.DAMAGE_ALL; - } else if (enchant.equalsIgnoreCase("BaneOfArthropods")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_DAMAGE_ARTHROPODS"))) { return Enchantment.DAMAGE_ARTHROPODS; - } else if (enchant.equalsIgnoreCase("Smite")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_DAMAGE_UNDEAD"))) { return Enchantment.DAMAGE_UNDEAD; - } else if (enchant.equalsIgnoreCase("Efficiency")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_DIG_SPEED"))) { return Enchantment.DIG_SPEED; - } else if (enchant.equalsIgnoreCase("Unbreaking")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_DURABILITY"))) { return Enchantment.DURABILITY; - } else if (enchant.equalsIgnoreCase("FireAspect")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_FIRE_ASPECT"))) { return Enchantment.FIRE_ASPECT; - } else if (enchant.equalsIgnoreCase("Knockback")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_KNOCKBACK"))) { return Enchantment.KNOCKBACK; - } else if (enchant.equalsIgnoreCase("Fortune")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_LOOT_BONUS_BLOCKS"))) { return Enchantment.LOOT_BONUS_BLOCKS; - } else if (enchant.equalsIgnoreCase("Looting")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_LOOT_BONUS_MOBS"))) { return Enchantment.LOOT_BONUS_MOBS; - } else if (enchant.equalsIgnoreCase("LuckOfTheSea")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_LUCK"))) { return Enchantment.LOOT_BONUS_MOBS; - } else if (enchant.equalsIgnoreCase("Lure")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_LURE"))) { return Enchantment.LOOT_BONUS_MOBS; - } else if (enchant.equalsIgnoreCase("Respiration")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_OXYGEN"))) { return Enchantment.OXYGEN; - } else if (enchant.equalsIgnoreCase("Protection")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_PROTECTION_ENVIRONMENTAL"))) { return Enchantment.PROTECTION_ENVIRONMENTAL; - } else if (enchant.equalsIgnoreCase("BlastProtection")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_PROTECTION_EXPLOSIONS"))) { return Enchantment.PROTECTION_EXPLOSIONS; - } else if (enchant.equalsIgnoreCase("FeatherFalling")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_PROTECTION_FALL"))) { return Enchantment.PROTECTION_FALL; - } else if (enchant.equalsIgnoreCase("FireProtection")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_PROTECTION_FIRE"))) { return Enchantment.PROTECTION_FIRE; - } else if (enchant.equalsIgnoreCase("ProjectileProtection")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_PROTECTION_PROJECTILE"))) { return Enchantment.PROTECTION_PROJECTILE; - } else if (enchant.equalsIgnoreCase("SilkTouch")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_SILK_TOUCH"))) { return Enchantment.SILK_TOUCH; - } else if (enchant.equalsIgnoreCase("Thorns")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_THORNS"))) { return Enchantment.THORNS; - } else if (enchant.equalsIgnoreCase("AquaAffinity")) { + } else if (enchant.equalsIgnoreCase(Lang.get("ENCHANTMENT_WATER_WORKER"))) { return Enchantment.WATER_WORKER; } else { return null; diff --git a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index 98acfcede..69f61064a 100644 --- a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -136,7 +136,7 @@ public class CreateStagePrompt extends FixedSetPrompt { LinkedList names = (LinkedList) context.getSessionData(pref + CK.S_ENCHANT_NAMES); LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS); for (int i = 0; i < enchants.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyItemString(names.get(i)) + ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA + Quester.prettyString(enchants.get(i)) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; + text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyItemString(names.get(i)) + ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA + Quester.prettyEnchantmentString(Quests.getEnchantment(enchants.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; } } if (questFactory.quests.citizens != null) { @@ -188,7 +188,7 @@ public class CreateStagePrompt extends FixedSetPrompt { LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_MOB_AMOUNTS); if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { for (int i = 0; i < mobs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + Quester.prettyString(mobs.get(i)) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; + text += ChatColor.GRAY + " - " + ChatColor.AQUA + Quester.prettyMobString(Quests.getMobType(mobs.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; } } else { LinkedList locs = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); @@ -197,7 +197,7 @@ public class CreateStagePrompt extends FixedSetPrompt { for (int i = 0; i < mobs.size(); i++) { String msg = Lang.get("blocksWithin"); msg = msg.replaceAll("", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY); - text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyString(mobs.get(i)) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW + names.get(i) + " (" + locs.get(i) + ")\n"; + text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyMobString(Quests.getMobType(mobs.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW + names.get(i) + " (" + locs.get(i) + ")\n"; } } } @@ -509,8 +509,7 @@ public class CreateStagePrompt extends FixedSetPrompt { @Override public String getPromptText(ConversationContext context) { String text = ChatColor.YELLOW + Lang.get("stageEditorPasswordPhrasePrompt") + "\n"; - text += ChatColor.ITALIC + "" + ChatColor.GOLD + Lang.get("stageEditorPasswordPhraseHint1") + "\n"; - text += ChatColor.RESET + "" + ChatColor.YELLOW + Lang.get("stageEditorPasswordPhraseHint2"); + text += ChatColor.ITALIC + "" + ChatColor.GOLD + Lang.get("stageEditorPasswordPhraseHint"); return text; } @@ -521,13 +520,13 @@ public class CreateStagePrompt extends FixedSetPrompt { @SuppressWarnings("unchecked") LinkedList> phrases = (LinkedList>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES); LinkedList newPhrases = new LinkedList(); - newPhrases.addAll(Arrays.asList(input.split("\\|"))); + newPhrases.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); phrases.add(newPhrases); context.setSessionData(pref + CK.S_PASSWORD_PHRASES, phrases); } else { LinkedList> phrases = new LinkedList>(); LinkedList newPhrases = new LinkedList(); - newPhrases.addAll(Arrays.asList(input.split("\\|"))); + newPhrases.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); phrases.add(newPhrases); context.setSessionData(pref + CK.S_PASSWORD_PHRASES, phrases); } @@ -1805,8 +1804,12 @@ public class CreateStagePrompt extends FixedSetPrompt { @Override public String getPromptText(ConversationContext context) { String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.DARK_PURPLE + Lang.get("stageEditorEnchantments") + ChatColor.LIGHT_PURPLE + " -\n"; - for (Enchantment e : Enchantment.values()) { - text += ChatColor.GREEN + Quester.prettyEnchantmentString(e) + ", "; + for (int i = 0; i < Enchantment.values().length; i++) { + if (i == Enchantment.values().length - 1) { + text += ChatColor.GREEN + Quester.prettyEnchantmentString(Enchantment.values()[i]) + " "; + } else { + text += ChatColor.GREEN + Quester.prettyEnchantmentString(Enchantment.values()[i]) + ", "; + } } text = text.substring(0, text.length() - 1); return text + "\n" + ChatColor.YELLOW + Lang.get("stageEditorEnchantTypePrompt"); @@ -1815,7 +1818,7 @@ public class CreateStagePrompt extends FixedSetPrompt { @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - String[] args = input.split(","); + String[] args = input.split(Lang.get("charSemi")); LinkedList enchs = new LinkedList(); boolean valid; for (String s : args) { @@ -2082,7 +2085,7 @@ public class CreateStagePrompt extends FixedSetPrompt { @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - String[] args = input.split(";"); + String[] args = input.split(Lang.get("charSemi")); LinkedList messages = new LinkedList(); messages.addAll(Arrays.asList(args)); context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, messages); @@ -2612,7 +2615,7 @@ public class CreateStagePrompt extends FixedSetPrompt { public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { LinkedList locNames = new LinkedList(); - locNames.addAll(Arrays.asList(input.split(","))); + locNames.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, locNames); } return new MobListPrompt(); @@ -2813,7 +2816,7 @@ public class CreateStagePrompt extends FixedSetPrompt { public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { LinkedList locNames = new LinkedList(); - locNames.addAll(Arrays.asList(input.split(","))); + locNames.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, locNames); } return new ReachListPrompt(); diff --git a/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java b/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java index bbc592188..fb4a0d9c8 100644 --- a/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java @@ -417,7 +417,7 @@ public class ItemStackPrompt extends FixedSetPrompt { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { input = Quests.parseString(input); LinkedList lore = new LinkedList(); - lore.addAll(Arrays.asList(input.split(";"))); + lore.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); cc.setSessionData("tempLore", lore); } else if (input.equalsIgnoreCase("clear")) { cc.setSessionData("tempLore", null); diff --git a/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java b/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java index 040477bd4..ee6ce0630 100644 --- a/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/RequirementsPrompt.java @@ -261,16 +261,14 @@ public class RequirementsPrompt extends FixedSetPrompt { text = text.substring(0, (text.length() - 2)); text += "\n"; } - String lang = Lang.get("reqQuestPrompt"); - lang = lang.replaceAll("", ChatColor.RED + "" + ChatColor.BOLD + Lang.get("comma") + ChatColor.RESET + ChatColor.YELLOW); - text += ChatColor.YELLOW + lang; + text += ChatColor.YELLOW + Lang.get("reqQuestPrompt"); return text; } @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - String[] args = input.split(","); + String[] args = input.split(Lang.get("charSemi")); LinkedList questNames = new LinkedList(); for (String s : args) { if (quests.getQuest(s) == null) { diff --git a/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java b/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java index c93c707ea..050f7933e 100644 --- a/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/RewardsPrompt.java @@ -328,7 +328,7 @@ public class RewardsPrompt extends FixedSetPrompt { @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - String[] args = input.split(","); + String[] args = input.split(Lang.get("charSemi")); LinkedList commands = new LinkedList(); for (String s : args) { if (s.startsWith("/")) { diff --git a/src/main/java/me/blackvein/quests/util/ItemUtil.java b/src/main/java/me/blackvein/quests/util/ItemUtil.java index e4b6ccfd4..acb53a563 100644 --- a/src/main/java/me/blackvein/quests/util/ItemUtil.java +++ b/src/main/java/me/blackvein/quests/util/ItemUtil.java @@ -165,10 +165,13 @@ public class ItemUtil { if (is.getDurability() != 0) { text += ChatColor.AQUA + ":" + is.getDurability(); } - text += ChatColor.AQUA + " x " + is.getAmount(); if (is.getEnchantments().isEmpty() == false) { - text += " " + ChatColor.DARK_PURPLE + Lang.get("enchantedItem"); + text += " " + ChatColor.GRAY + Lang.get("with") + ChatColor.DARK_PURPLE; + for (Entry e : is.getEnchantments().entrySet()) { + text += " " + Quester.prettyEnchantmentString(e.getKey()) + ":" + e.getValue(); + } } + text += ChatColor.AQUA + " x " + is.getAmount(); } return text; } diff --git a/src/main/java/me/blackvein/quests/util/Lang.java b/src/main/java/me/blackvein/quests/util/Lang.java index b5848629b..21fe69aeb 100644 --- a/src/main/java/me/blackvein/quests/util/Lang.java +++ b/src/main/java/me/blackvein/quests/util/Lang.java @@ -35,7 +35,6 @@ public class Lang { private static final LangToken tokens = new LangToken(); public static final LinkedHashMap langMap = new LinkedHashMap(); private final Quests plugin; - //public static String orCancelToReturn = "or 'cancel' to return"; public Lang(Quests plugin) { tokens.initTokens(); @@ -107,8 +106,6 @@ public class Lang { + " same folder to stay up-to-date and suppress console warnings."); config_new.options().copyHeader(true); config_new.save(langFile_new); - langMap.putAll(allStrings); - finishLang(); } else { plugin.getLogger().severe("Failed loading lang files for " + iso + " because they were not found. Using default en-US"); iso = "en-US"; @@ -116,32 +113,41 @@ public class Lang { for (String key : config.getKeys(false)) { allStrings.put(key, config.getString(key)); } - langMap.putAll(allStrings); - finishLang(); } - plugin.getLogger().info("Loaded language " + iso + ". Translations via Crowdin"); - } - - private void finishLang() { - langMap.put("strAdd", get("strAdd").replaceAll("", get("cmdAdd"))); - langMap.put("strClear", get("strClear").replaceAll("", get("cmdClear"))); - langMap.put("strCancel", get("strCancel").replaceAll("", get("cmdCancel"))); - langMap.put("strDone", get("strDone").replaceAll("", get("cmdDone"))); - for (String key : langMap.keySet()) { - String value = get(key); - - // then enter 'add' to include it - value.replaceAll("", get("strAdd")); - // or 'clear' to erase all data - value.replaceAll("", get("strClear")); - // or 'cancel' to return - value.replaceAll("", get("strCancel")); - // then enter '' to save - value.replaceAll("", get("strDone")); - - langMap.put(key, value); + String cmdAdd = allStrings.get("cmdAdd"); + String cmdClear = allStrings.get("cmdClear"); + String cmdCancel = allStrings.get("cmdCancel"); + String cmdDone = allStrings.get("cmdDone"); + + String strAdd = allStrings.get("strAdd").replaceAll("", cmdAdd); + String strClear = allStrings.get("strClear").replaceAll("", cmdClear); + String strCancel = allStrings.get("strCancel").replaceAll("", cmdCancel); + String strDone = allStrings.get("strDone").replaceAll("", cmdDone); + String strSpace = allStrings.get("strSpace"); + String strSemicolon = allStrings.get("strSemicolon"); + for (Entry entry : allStrings.entrySet()) { + if (entry.getValue().contains("")) { + allStrings.put(entry.getKey(), entry.getValue().replaceAll("", strAdd)); + } + if (entry.getValue().contains("")) { + allStrings.put(entry.getKey(), entry.getValue().replaceAll("", strClear)); + } + if (entry.getValue().contains("")) { + allStrings.put(entry.getKey(), entry.getValue().replaceAll("", strCancel)); + } + if (entry.getValue().contains("")) { + allStrings.put(entry.getKey(), entry.getValue().replaceAll("", strDone)); + } + if (entry.getValue().contains("")) { + allStrings.put(entry.getKey(), entry.getValue().replaceAll("", strSpace)); + } + if (entry.getValue().contains("")) { + allStrings.put(entry.getKey(), entry.getValue().replaceAll("", strSemicolon)); + } } + langMap.putAll(allStrings); + plugin.getLogger().info("Loaded language " + iso + ". Translations via Crowdin"); } /** diff --git a/src/main/resources/strings.yml b/src/main/resources/strings.yml index eb3500b97..ccbe051de 100644 --- a/src/main/resources/strings.yml +++ b/src/main/resources/strings.yml @@ -105,7 +105,7 @@ questEditorSave: "Finish and save" questEditorNeedAskMessage: "You must set an ask message!" questEditorNeedFinishMessage: "You must set a finish message!" questEditorNeedStages: "Your Quest has no Stages!" -questEditorSaved: "%bold%Quest saved! %reset%(You will need to perform %red% %reset%for it to appear)" +questEditorSaved: "%bold%Quest saved! %reset%(You will need to perform %red% %reset% for it to appear in-game)" questEditorExited: "Are you sure you want to exit without saving?" questEditorDeleted: "Are you sure you want to delete the Quest" questEditorNoPermsCreate: "You do not have permission to create Quests." @@ -191,33 +191,33 @@ stageEditorCustomPrompt: "Enter the name of a custom objective to add, , stageEditorCustomAlreadyAdded: "That custom objective has already been added!" stageEditorCustomCleared: "Custom objectives cleared." stageEditorCustomDataPrompt: "Enter value for :" -stageEditorEnterBlockNames: "Enter block names (or IDs), separating each one by a space, " -stageEditorBreakBlocksPrompt: "Enter break amounts (numbers), separating each one by a space, " -stageEditorDamageBlocksPrompt: "Enter damage amounts (numbers), separating each one by a space, " -stageEditorPlaceBlocksPrompt: "Enter place amounts (numbers), separating each one by a space, " -stageEditorUseBlocksPrompt: "Enter use amounts (numbers), separating each one by a space, " -stageEditorCutBlocksPrompt: "Enter cut amounts (numbers), separating each one by a space, " -stageEditorEnterBlockDurability: "Enter block durability (numbers), separating each one by a space, " +stageEditorEnterBlockNames: "Enter block names (or IDs), , " +stageEditorBreakBlocksPrompt: "Enter break amounts (numbers), , " +stageEditorDamageBlocksPrompt: "Enter damage amounts (numbers), , " +stageEditorPlaceBlocksPrompt: "Enter place amounts (numbers), , " +stageEditorUseBlocksPrompt: "Enter use amounts (numbers), , " +stageEditorCutBlocksPrompt: "Enter cut amounts (numbers), , " +stageEditorEnterBlockDurability: "Enter block durability (numbers), , " stageEditorCatchFishPrompt: "Enter number of fish to catch, or 0 to clear the fish catch objective, or -1 to cancel" stageEditorKillPlayerPrompt: "Enter number of players to kill, or 0 to clear the player kill objective, or -1 to cancel" -stageEditorEnchantTypePrompt: "Enter enchantment names, separating each one by a comma, " -stageEditorEnchantAmountsPrompt: "Enter enchant amounts (numbers), separating each one by a space, " -stageEditorItemNamesPrompt: "Enter item names, separating each one by a space, " -stageEditorNPCPrompt: "Enter NPC IDs, separating each one by a space, " -stageEditorNPCToTalkToPrompt: "Enter NPC IDs, separating each one by a space, , " -stageEditorDeliveryMessagesPrompt: "Enter delivery messages, separating each one by a semi-colon, " -stageEditorKillNPCsPrompt: "Enter kill amounts (numbers), separating each one by a space, " -stageEditorMobsPrompt: "Enter mob names separating each one by a space, " -stageEditorMobAmountsPrompt: "Enter mob amounts separating each one by a space, " +stageEditorEnchantTypePrompt: "Enter enchantment names, , " +stageEditorEnchantAmountsPrompt: "Enter enchant amounts (numbers), , " +stageEditorItemNamesPrompt: "Enter item names, , " +stageEditorNPCPrompt: "Enter NPC IDs, , " +stageEditorNPCToTalkToPrompt: "Enter NPC IDs, , , " +stageEditorDeliveryMessagesPrompt: "Enter delivery messages, , " +stageEditorKillNPCsPrompt: "Enter kill amounts (numbers), , " +stageEditorMobsPrompt: "Enter mob names, , " +stageEditorMobAmountsPrompt: "Enter mob amounts, , " stageEditorMobLocationPrompt: "Right-click on a block to select it, , " -stageEditorMobLocationRadiiPrompt: "Enter kill location radii (number of blocks) separating each one by a space, " -stageEditorMobLocationNamesPrompt: "Enter location names separating each one by a comma, " +stageEditorMobLocationRadiiPrompt: "Enter kill location radii (number of blocks), , " +stageEditorMobLocationNamesPrompt: "Enter location names, , " stageEditorReachLocationPrompt: "Right-click on a block to select it, , " -stageEditorReachLocationRadiiPrompt: "Enter reach location radii (number of blocks) separating each one by a space, " -stageEditorReachLocationNamesPrompt: "Enter location names separating each one by a comma, " -stageEditorTameAmountsPrompt: "Enter tame amounts separating each one by a space, " -stageEditorShearColorsPrompt: "Enter sheep colors separating each one by a space, " -stageEditorShearAmountsPrompt: "Enter shear amounts separating each one by a space, " +stageEditorReachLocationRadiiPrompt: "Enter reach location radii (number of blocks), , " +stageEditorReachLocationNamesPrompt: "Enter location names, , " +stageEditorTameAmountsPrompt: "Enter tame amounts, , " +stageEditorShearColorsPrompt: "Enter sheep colors, , " +stageEditorShearAmountsPrompt: "Enter shear amounts, , " stageEditorEventsPrompt: "Enter an event name, , " stageEditorChatEventsPrompt: "Enter an event name to add, , " stageEditorChatEventsTriggerPrompt: "%yellow%Enter a chat trigger for%aqua% %yellow% " @@ -228,11 +228,10 @@ stageEditorDelayMessagePrompt: "Enter delay message, , " stageEditorScriptPrompt: "Enter script name, , " stageEditorStartMessagePrompt: "Enter start message, , " stageEditorCompleteMessagePrompt: "Enter complete message, , " -stageEditorPasswordDisplayPrompt: "Enter a password display, " +stageEditorPasswordDisplayPrompt: "Enter password display, " stageEditorPasswordDisplayHint: "(This is the text that will be displayed to the player as their objective)" -stageEditorPasswordPhrasePrompt: "Enter a password phrase, " -stageEditorPasswordPhraseHint1: "(This is the text that a player has to say to complete the objective)" -stageEditorPasswordPhraseHint2: "If you want multiple password phrases, separate them by a | (pipe)" +stageEditorPasswordPhrasePrompt: "Enter password phrases, , " +stageEditorPasswordPhraseHint: "(This is the text that a player must enter to complete the objective)" stageEditorObjectiveOverridePrompt: "Enter objective display override, , " stageEditorObjectiveOverrideHint: "(This override will display your own text as the objective)" stageEditorObjectiveOverrideCleared: "Objective display override cleared." @@ -448,9 +447,9 @@ eventEditorSetMobTypesPrompt: "Enter mob name, " eventEditorSetMobAmountsPrompt: "Enter mob amount, " eventEditorSetMobNamePrompt: "Enter the name for this mob, " eventEditorSetMobLocationPrompt: "Right-click on a block to select it, , " -eventEditorSetPotionEffectsPrompt: "Enter potion effect types separating each one by a space, " -eventEditorSetPotionDurationsPrompt: "Enter effect durations (in milliseconds) separating each one by a space, " -eventEditorSetPotionMagnitudesPrompt: "Enter potion effect magnitudes separating each one by a space, " +eventEditorSetPotionEffectsPrompt: "Enter potion effect types, , " +eventEditorSetPotionDurationsPrompt: "Enter effect durations (in milliseconds), , " +eventEditorSetPotionMagnitudesPrompt: "Enter potion effect magnitudes, , " eventEditorSetHungerPrompt: "Enter hunger level, or -1 to clear" eventEditorHungerLevelAtLeastZero: "Hunger level must be at least 0!" eventEditorSetSaturationPrompt: "Enter saturation level, or -1 to clear" @@ -459,7 +458,7 @@ eventEditorSetHealthPrompt: "Enter health level, or -1 to clear" eventEditorHealthLevelAtLeastZero: "Health level must be at least 0!" eventEditorSetTeleportPrompt: "Right-click on a block to teleport the player to, , , " eventEditorCommandsNote: "Note: You may use to refer to the player's name." -eventEditorSetCommandsPrompt: "Enter commands separating each one by a comma, , " +eventEditorSetCommandsPrompt: "Enter commands, , , " reqSetMoney: "Set money requirement" reqSetQuestPoints: "Set Quest Points requirement" reqSetItem: "Set item requirements" @@ -477,12 +476,12 @@ reqHeroesSetSecondary: "Set Secondary Class" reqMoneyPrompt: "Enter amount of , or 0 to clear the money requirement, or -1 to cancel" reqQuestPointsPrompt: "Enter amount of Quest Points, or 0 to clear the Quest Point requirement, or -1 to cancel" reqQuestListTitle: "- Quests Available -" -reqQuestPrompt: "Enter a list of Quest names separating each one by a , , " -reqRemoveItemsPrompt: "Enter a list of true/false values, separating each one by a space, " -reqPermissionsPrompt: "Enter permission requirements separating each one by a space, , " +reqQuestPrompt: "Enter a list of Quest names, , , " +reqRemoveItemsPrompt: "Enter a list of true/false values, , " +reqPermissionsPrompt: "Enter permission requirements, , , " reqCustomPrompt: "Enter the name of a custom requirement to add, , " -reqMcMMOPrompt: "Enter mcMMO skills, separating each one by a space, , " -reqMcMMOAmountsPrompt: "Enter mcMMO skill amounts, separating each one by a space, , " +reqMcMMOPrompt: "Enter mcMMO skills, , , " +reqMcMMOAmountsPrompt: "Enter mcMMO skill amounts, , , " reqHeroesPrimaryPrompt: "Enter a Heroes Primary Class name, , " reqHeroesSecondaryPrompt: "Enter a Heroes Secondary Class name, , " reqFailMessagePrompt: "Enter fail requirements message, " @@ -528,15 +527,15 @@ rewSetHeroesClasses: "Set classes" rewSetHeroesAmounts: "Set experience amounts" rewMoneyPrompt: "Enter amount of , or 0 to clear the money reward, or -1 to cancel" rewExperiencePrompt: "Enter amount of experience, or 0 to clear the experience reward, or -1 to cancel" -rewCommandPrompt: "Enter command rewards separating each one by a , , " +rewCommandPrompt: "Enter command rewards, , , " rewCommandPromptHint: 'Note: You may put to specify the player who completed the Quest. e.g. smite ' -rewPermissionsPrompt: "Enter permission rewards separating each one by a space, , " +rewPermissionsPrompt: "Enter permission rewards, , , " rewQuestPointsPrompt: "Enter amount of Quest Points, or 0 to clear the Quest Point reward, or -1 to cancel" -rewMcMMOPrompt: "Enter mcMMO skills, separating each one by a space, " +rewMcMMOPrompt: "Enter mcMMO skills, , " rewMcMMOPromptHint: "Note: Typing 'All' will give levels to all skills." -rewHeroesClassesPrompt: "Enter Heroes classes separating each one by a space, " -rewHeroesExperiencePrompt: "Enter experience amounts (numbers, decimals are allowed) separating each one by a space, " -rewPhatLootsPrompt: "Enter PhatLoots separating each one by a space, , " +rewHeroesClassesPrompt: "Enter Heroes classes, , " +rewHeroesExperiencePrompt: "Enter experience amounts (numbers, decimals are allowed), , " +rewPhatLootsPrompt: "Enter PhatLoots, , , " rewCustomRewardPrompt: "Enter the name of a custom reward to add, , " rewItemsCleared: "Item rewards cleared." rewNoMcMMOSkills: "No skills set" @@ -567,7 +566,7 @@ itemCreateEnterDurab: "Enter item durability, , " itemCreateEnterEnch: "Enter an enchantment name, , " itemCreateEnterLevel: "Enter a level (number) for " itemCreateEnterDisplay: "Enter item display name, , " -itemCreateEnterLore: "Enter item lore, separating each line by a semi-colon, , " +itemCreateEnterLore: "Enter item lore, , , " itemCreateLoaded: "Item loaded." itemCreateNoItem: "No item in hand!" itemCreateNoName: "You must set a name first!" @@ -644,9 +643,12 @@ cmdCancel: "cancel" strCancel: "or '' to return" cmdDone: "done" strDone: "then enter '' to save" +strSpace: separating each by a space +strSemicolon: separating each by a semicolon +charSemi: ";" acceptQuest: "Accept Quest?" enterAnOption: "Enter an option" -questAccepted: 'Quest accepted: ' +questAccepted: "Quest accepted: " currentQuest: "Current Quests:" noMoreQuest: "No more quests available." break: "Break" @@ -822,7 +824,6 @@ clear: "Clear" edit: "Edit" none: "None" done: "Done" -comma: "comma" finish: "Finish" quit: "Quit" noneSet: "None set" @@ -833,7 +834,7 @@ worlds: "Worlds" mobs: "Mobs" points: "points" invalidOption: "Invalid option!" -npcHint: "Note: You can left or right click on NPC's to get their ID." +npcHint: "Note: You can left or right click on NPCs to get their ID." listDuplicate: "List contains duplicates!" id: "ID" quest: "Quest" @@ -848,11 +849,10 @@ usage: "Usage" redoableEvery: "Redoable every