use of com.elmakers.mine.bukkit.api.magic.Messages in project MagicPlugin by elBukkit.
the class Wand method getLore.
@SuppressWarnings("unchecked")
protected List<String> getLore() {
Object customLore = getProperty("lore");
if (customLore != null && customLore instanceof Collection) {
return getCustomLore((Collection<String>) customLore);
}
List<String> lore = new ArrayList<>();
int spellCount = getSpells().size();
int materialCount = getBrushes().size();
String pathName = getPathName();
if (description.length() > 0) {
if (randomizeOnActivate) {
String randomDescription = getMessage("randomized_lore");
String randomTemplate = controller.getMessages().get(getMessageKey("randomized_description"), "");
if (randomDescription.length() > 0 && !randomTemplate.isEmpty()) {
InventoryUtils.wrapText(randomTemplate.replace("$description", randomDescription), lore);
return lore;
}
}
if (description.contains("$") && !description.contains("$path")) {
String newDescription = controller.getMessages().escape(description);
if (!newDescription.equals(description)) {
this.description = newDescription;
setProperty("description", description);
}
}
String descriptionTemplate = controller.getMessages().get(getMessageKey("description_lore"), "");
if (description.contains("$path") && !descriptionTemplate.isEmpty()) {
String description = ChatColor.translateAlternateColorCodes('&', this.description);
description = description.replace("$path", pathName == null ? "Unknown" : pathName);
InventoryUtils.wrapText(descriptionTemplate.replace("$description", description), lore);
} else if (description.contains("$")) {
String randomDescription = getMessage("randomized_lore");
String randomTemplate = controller.getMessages().get(getMessageKey("randomized_description"), "");
if (randomDescription.length() > 0 && !randomTemplate.isEmpty()) {
randomDescription = ChatColor.translateAlternateColorCodes('&', randomDescription);
InventoryUtils.wrapText(randomTemplate.replace("$description", randomDescription), lore);
return lore;
}
} else if (!descriptionTemplate.isEmpty()) {
String description = ChatColor.translateAlternateColorCodes('&', this.description);
InventoryUtils.wrapText(descriptionTemplate.replace("$description", description), lore);
}
}
String pathTemplate = getMessage("path_lore", "");
if (pathName != null && !pathTemplate.isEmpty()) {
lore.add(pathTemplate.replace("$path", pathName));
}
if (!isUpgrade) {
addOwnerDescription(lore);
}
SpellTemplate spell = controller.getSpellTemplate(getActiveSpellKey());
Messages messages = controller.getMessages();
// This is here specifically for a wand that only has
// one spell now, but may get more later. Since you
// can't open the inventory in this state, you can not
// otherwise see the spell lore.
boolean isSingleSpell = spell != null && spellCount == 1 && !hasInventory && !isUpgrade;
if (isSingleSpell) {
addSpellLore(messages, spell, lore, getActiveMage(), this);
}
if (materialCount == 1 && activeBrush != null && activeBrush.length() > 0) {
lore.add(getBrushDisplayName(messages, MaterialBrush.parseMaterialKey(activeBrush)));
}
if (spellCount > 0) {
if (isUpgrade) {
ConfigurationUtils.addIfNotEmpty(getMessage("upgrade_spell_count").replace("$count", Integer.toString(spellCount)), lore);
} else if (spellCount > 1) {
ConfigurationUtils.addIfNotEmpty(getMessage("spell_count").replace("$count", Integer.toString(spellCount)), lore);
}
}
if (materialCount > 0) {
if (isUpgrade) {
ConfigurationUtils.addIfNotEmpty(getMessage("upgrade_material_count").replace("$count", Integer.toString(materialCount)), lore);
} else if (materialCount > 1) {
ConfigurationUtils.addIfNotEmpty(getMessage("material_count").replace("$count", Integer.toString(materialCount)), lore);
}
}
addUseLore(lore);
addPropertyLore(lore, isSingleSpell);
if (isUpgrade) {
ConfigurationUtils.addIfNotEmpty(getMessage("upgrade_item_description"), lore);
}
return lore;
}
use of com.elmakers.mine.bukkit.api.magic.Messages in project MagicPlugin by elBukkit.
the class Wand method getActiveWandName.
private String getActiveWandName(SpellTemplate spell, com.elmakers.mine.bukkit.api.block.MaterialBrush brush) {
// Build wand name
int remaining = getRemainingUses();
String wandColorPrefix = (hasUses && remaining <= 1) ? "single_use_prefix" : isModifiable() ? (bound ? "bound_prefix" : "unbound_prefix") : (path != null && path.length() > 0 ? "has_path_prefix" : "unmodifiable_prefix");
String name = ChatColor.translateAlternateColorCodes('&', getMessage(wandColorPrefix)) + getDisplayName();
if (randomizeOnActivate)
return name;
Set<String> spells = getSpells();
// Add active spell to description
Messages messages = controller.getMessages();
boolean showSpell = isModifiable() && hasSpellProgression();
showSpell = !quickCast && (spells.size() > 1 || showSpell) && getMode() != WandMode.SKILLS;
if (spell != null && showSpell) {
name = getSpellDisplayName(messages, spell, brush) + " (" + name + ChatColor.WHITE + ")";
}
if (remaining > 1) {
String message = getMessage("uses_remaining_brief");
name = name + ChatColor.DARK_RED + " (" + message.replace("$count", Integer.toString(remaining)) + ChatColor.DARK_RED + ")";
}
return name;
}
use of com.elmakers.mine.bukkit.api.magic.Messages in project MagicPlugin by elBukkit.
the class BaseShopAction method getItemCost.
protected String getItemCost(CastContext context, ShopItem shopItem) {
String amountString = "?";
MageController controller = context.getController();
Messages messages = controller.getMessages();
double worth = shopItem.getWorth();
if (isXP) {
worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthXP());
amountString = Integer.toString((int) worth);
amountString = messages.get("costs.xp_amount").replace("$amount", amountString);
} else if (isItems) {
worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthItemAmount());
amountString = formatItemAmount(controller, worth);
} else if (isSkillPoints) {
worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthSkillPoints());
amountString = Integer.toString((int) Math.ceil(worth));
amountString = messages.get("costs.sp_amount").replace("$amount", amountString);
} else {
worth = Math.ceil(costScale * worth * controller.getWorthBase());
amountString = VaultController.getInstance().format(worth);
}
return amountString;
}
use of com.elmakers.mine.bukkit.api.magic.Messages in project MagicPlugin by elBukkit.
the class BaseShopAction method getBalanceDescription.
protected String getBalanceDescription(CastContext context) {
Mage mage = context.getMage();
MageController controller = context.getController();
Messages messages = controller.getMessages();
String description = "";
if (isXP) {
String xpAmount = Integer.toString(mage.getExperience());
description = messages.get("costs.xp_amount").replace("$amount", xpAmount);
} else if (isItems) {
int itemAmount = getItemAmount(controller, mage);
description = formatItemAmount(controller, itemAmount);
} else if (isSkillPoints) {
String spAmount = Integer.toString(mage.getSkillPoints());
description = messages.get("costs.sp_amount").replace("$amount", spAmount);
} else {
double balance = VaultController.getInstance().getBalance(mage.getPlayer());
description = VaultController.getInstance().format(balance);
}
return description;
}
use of com.elmakers.mine.bukkit.api.magic.Messages in project MagicPlugin by elBukkit.
the class ChangeWorldAction method setTargetWorldName.
protected void setTargetWorldName(CastContext context, String worldName) {
Messages messages = context.getController().getMessages();
targetWorldMessage = messages.get("worlds." + worldName + ".name", worldName);
}
Aggregations