@Override public String get(String key) { return get(key, key); }
private String getRomanString(float amount) { String roman = ""; boolean negative = false; if (amount < 0) { amount = -amount; negative = true; } if (amount > 1) { roman = get("wand.enchantment_level_max"); } else if (amount > 0.8f) { roman = get("wand.enchantment_level_5"); } else if (amount > 0.6f) { roman = get("wand.enchantment_level_4"); } else if (amount > 0.4f) { roman = get("wand.enchantment_level_3"); } else if (amount > 0.2f) { roman = get("wand.enchantment_level_2"); } else { roman = get("wand.enchantment_level_1"); } if (negative) { roman = "-" + roman; } return roman; } }
@Override public String getParameterized(String key, String paramName, String paramValue) { return get(key, key).replace(paramName, paramValue); }
@Override public String getPercentageString(String templateName, float amount) { String templateString = get(templateName, ""); return templateString.replace("$amount", Integer.toString((int)(amount * 100))); }
@Override public String getPropertyString(String templateName, float amount, float max, String propertyTemplateName) { String templateString = get(templateName, ""); String propertyTemplateString = get(propertyTemplateName, ""); return formatPropertyString(templateString, amount, max, propertyTemplateString); }
@Override public String getParameterized(String key, String paramName1, String paramValue1, String paramName2, String paramValue2) { return get(key, key).replace(paramName1, paramValue1).replace(paramName2, paramValue2); }
@Override public String getLevelString(String templateName, float amount, float max) { String templateString = get(templateName, ""); return formatLevelString(templateString, amount, max); }
@Override public String formatList(String basePath, Collection<String> nodes, String nameKey) { StringBuilder buffer = new StringBuilder(); for (String node : nodes) { if (buffer.length() != 0) { buffer.append(", "); } String path = node; if (basePath != null) { path = basePath + "." + path; } if (nameKey != null) { path = path + "." + nameKey; } node = get(path, node); buffer.append(node); } return buffer.toString(); }
@Override public boolean promptResourcePack(final Player player) { if (resourcePack == null || resourcePackHash == null) { return false; } if (resourcePackPrompt) { String message = messages.get("resource_pack.prompt"); if (message != null && !message.isEmpty()) { player.sendMessage(message); } return false; } return sendResourcePack(player); }
@Override public String describeCurrency(double amount) { VaultController vault = VaultController.getInstance(); if (vault == null) return Integer.toString((int)amount); String formatted = vault.format(amount); if (!VaultController.hasEconomy()) { formatted = get("costs.currency_amount").replace("$amount", formatted); } return formatted; }
@Override public @Nullable String checkRequirements(@Nonnull CastContext context, @Nullable Collection<Requirement> requirements) { if (requirements == null) return null; for (Requirement requirement : requirements) { String type = requirement.getType(); RequirementsProcessor processor = requirementProcessors.get(type); if (processor != null) { if (!processor.checkRequirement(context, requirement)) { String message = processor.getRequirementDescription(context, requirement); if (message == null || message.isEmpty()) { message = messages.get("requirements.unknown"); } return message; } } } return null; }
@Override public String getCurrency() { VaultController vault = VaultController.getInstance(); if (VaultController.hasEconomy()) { return vault.getCurrency(); } return get("costs.currency_singular"); }
@Override public boolean sendResourcePack(final Player player) { if (resourcePack == null || resourcePackHash == null) { return false; } String message = messages.get("resource_pack.sending"); if (message != null && !message.isEmpty()) { player.sendMessage(message); } // Give them 2 seconds to read the message Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { CompatibilityUtils.setResourcePack(player, resourcePack, resourcePackHash); } }, resourcePackDelay * 20 / 1000); return true; }
@Override public String getCurrencyPlural() { VaultController vault = VaultController.getInstance(); if (VaultController.hasEconomy()) { return vault.getCurrencyPlural(); } return get("costs.currency"); }
meta.setDisplayName(template.getString("name")); } else { String name = messages.get("wands." + key + ".name"); if (name != null && !name.isEmpty()) { meta.setDisplayName(name); lore.add(template.getString("description")); } else { String description = messages.get("wands." + key + ".description"); if (description != null && !description.isEmpty()) { lore.add(description);
ItemStack bookItem = new ItemStack(Material.WRITTEN_BOOK, count); BookMeta book = (BookMeta)bookItem.getItemMeta(); book.setAuthor(messages.get("books.default.author")); String title = null; if (category != null) { title = messages.get("books.default.title").replace("$category", category.getName()); } else { title = messages.get("books.all.title"); title = messages.get("books.default.title").replace("$category", category.getName()); String description = "" + ChatColor.BOLD + ChatColor.BLUE + title + "\n\n"; description += "" + ChatColor.RESET + ChatColor.DARK_BLUE + category.getDescription(); spellCooldownDescription = messages.get("cooldown.description").replace("$time", spellCooldownDescription); lines.add("" + ChatColor.DARK_PURPLE + spellCooldownDescription); spellMageCooldownDescription = messages.get("cooldown.mage_description").replace("$time", spellMageCooldownDescription); lines.add("" + ChatColor.RED + spellMageCooldownDescription); for (CastingCost cost : costs) { if (!cost.isEmpty(reducer)) { lines.add(ChatColor.DARK_PURPLE + messages.get("wand.costs_description").replace("$description", cost.getFullDescription(messages, reducer))); for (CastingCost cost : activeCosts) { if (!cost.isEmpty(reducer)) { lines.add(ChatColor.DARK_PURPLE + messages.get("wand.active_costs_description").replace("$description", cost.getFullDescription(messages, reducer))); WandUpgradePath checkPath = WandUpgradePath.getPath(pathKey); if (!checkPath.isHidden() && (checkPath.hasSpell(spell.getKey()) || checkPath.hasExtraSpell(spell.getKey()))) {
itemStack = getURLSkull(skillPointIcon); ItemMeta meta = itemStack.getItemMeta(); meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', messages.get("sp.name")).replace("$amount", spAmount)); String spDescription = messages.get("sp.description"); if (spDescription.length() > 0) String name = messages.get("currency." + costKey + ".name", costKey); String itemName = messages.get("currency." + costKey + ".item_name", messages.get("currency.item_name")); itemName = itemName.replace("$type", name); itemName = itemName.replace("$amount", costAmount); String spDescription = messages.get("currency." + costKey + ".description", messages.get("currency.description")); if (spDescription.length() > 0)