use of com.elmakers.mine.bukkit.api.spell.SpellTemplate in project MagicPlugin by elBukkit.
the class WandCommandExecutor method onWandAdd.
public boolean onWandAdd(CommandSender sender, Player player, String[] parameters) {
if (parameters.length < 1) {
sender.sendMessage("Usage: /wand add <spell|material> [material:data]");
return true;
}
Wand wand = checkWand(sender, player);
if (wand == null) {
return true;
}
Mage mage = controller.getMage(player);
String spellName = parameters[0];
if (spellName.equals("material") || spellName.equals("brush")) {
if (parameters.length < 2) {
sender.sendMessage("Use: /wand add brush <material:data>");
return true;
}
String materialKey = parameters[1];
if (!MaterialBrush.isValidMaterial(materialKey, false)) {
sender.sendMessage(materialKey + " is not a valid brush");
return true;
}
if (wand.addBrush(materialKey)) {
wand.setActiveBrush(materialKey);
if (sender != player) {
sender.sendMessage("Added brush '" + materialKey + "' to " + player.getName() + "'s wand");
}
} else {
wand.setActiveBrush(materialKey);
mage.sendMessage("Brush activated: " + materialKey);
if (sender != player) {
sender.sendMessage(player.getName() + "'s wand already has brush " + materialKey);
}
}
wand.saveState();
return true;
}
Spell spell = mage.getSpell(spellName);
if (spell == null) {
sender.sendMessage("Spell '" + spellName + "' unknown, Use /spells for spell list");
return true;
}
SpellTemplate currentSpell = wand.getBaseSpell(spellName);
if (wand.addSpell(spellName)) {
wand.setActiveSpell(spellName);
if (currentSpell != null) {
String levelDescription = spell.getLevelDescription();
if (levelDescription == null || levelDescription.isEmpty()) {
levelDescription = spell.getName();
}
if (sender != player) {
sender.sendMessage(api.getMessages().get("wand.player_spell_upgraded").replace("$player", player.getName()).replace("$name", currentSpell.getName()).replace("$level", levelDescription));
}
} else {
if (sender != player) {
sender.sendMessage("Added '" + spell.getName() + "' to " + player.getName() + "'s wand");
}
}
} else {
wand.setActiveSpell(spellName);
mage.sendMessage(spell.getName() + " activated");
if (sender != player) {
sender.sendMessage(player.getName() + "'s wand already has " + spell.getName());
}
}
wand.saveState();
return true;
}
use of com.elmakers.mine.bukkit.api.spell.SpellTemplate in project MagicPlugin by elBukkit.
the class MagicTabExecutor method showWorth.
protected void showWorth(CommandSender sender, ItemStack item) {
if (api.isWand(item) || (api.isUpgrade(item))) {
Wand wand = api.getWand(item);
if (wand == null) {
sender.sendMessage("I'm not sure what that's worth, sorry!");
return;
}
sender.sendMessage(ChatColor.AQUA + "WIP: Wand " + ChatColor.GOLD + wand.getName() + ChatColor.AQUA + " is worth " + ChatColor.GREEN + wand.getWorth());
} else if (api.isSpell(item)) {
SpellTemplate template = api.getSpellTemplate(api.getSpell(item));
if (template == null) {
sender.sendMessage("I'm not sure what that's worth, sorry!");
return;
}
sender.sendMessage(ChatColor.AQUA + "Spell " + ChatColor.GOLD + template.getName() + ChatColor.AQUA + " is worth " + ChatColor.GREEN + template.getWorth());
} else if (api.isBrush(item)) {
String materialBrush = api.getBrush(item);
if (materialBrush == null) {
sender.sendMessage("I'm not sure what that's worth, sorry!");
return;
}
// TODO: Config-driven!
int brushWorth = 500;
sender.sendMessage(ChatColor.AQUA + "WIP: Brush " + ChatColor.GOLD + materialBrush + ChatColor.AQUA + " is worth " + ChatColor.GREEN + brushWorth);
} else {
sender.sendMessage("I'm not sure what that's worth, sorry!");
}
}
use of com.elmakers.mine.bukkit.api.spell.SpellTemplate in project MagicPlugin by elBukkit.
the class SpellsCommandExecutor method listSpellsByCategory.
public void listSpellsByCategory(CommandSender sender, String category) {
List<SpellTemplate> categorySpells = new ArrayList<>();
Collection<SpellTemplate> spellVariants = api.getSpellTemplates(sender.hasPermission("Magic.bypass_hidden"));
Player player = sender instanceof Player ? (Player) sender : null;
for (SpellTemplate spell : spellVariants) {
SpellCategory spellCategory = spell.getCategory();
if (spellCategory != null && spellCategory.getKey().equalsIgnoreCase(category) && (player == null || spell.hasCastPermission(player))) {
categorySpells.add(spell);
}
}
if (categorySpells.size() == 0) {
String message = api.getMessages().get("general.no_spells_in_category");
message = message.replace("$category", category);
sender.sendMessage(message);
return;
}
sender.sendMessage(category + ":");
Collections.sort(categorySpells);
for (SpellTemplate spell : categorySpells) {
String name = spell.getName();
String description = spell.getDescription();
if (!name.equals(spell.getKey())) {
description = name + " : " + description;
}
sender.sendMessage(ChatColor.AQUA + spell.getKey() + ChatColor.BLUE + " [" + spell.getIcon().getName() + "] : " + ChatColor.YELLOW + description);
}
}
Aggregations