use of com.elmakers.mine.bukkit.api.wand.Wand 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.wand.Wand in project MagicPlugin by elBukkit.
the class CastingCost method has.
@Override
public boolean has(Spell spell) {
CastContext context = spell.getCurrentCast();
Mage mage = context.getMage();
Wand wand = context.getWand();
return has(mage, wand, spell);
}
use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.
the class CastingCost method use.
@Override
public void use(Spell spell) {
CastContext context = spell.getCurrentCast();
Mage mage = context.getMage();
Wand wand = context.getWand();
deduct(mage, wand, spell);
}
use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.
the class MagicTabExecutor method giveWand.
public boolean giveWand(CommandSender sender, Player player, String wandKey, boolean quiet, boolean giveItem, boolean giveValue, boolean showWorth) {
Mage mage = controller.getMage(player);
Wand currentWand = mage.getActiveWand();
if (currentWand != null) {
currentWand.closeInventory();
}
Wand wand = api.createWand(wandKey);
if (wand != null) {
if (giveItem) {
ItemStack item = wand.getItem();
if (item == null) {
if (!quiet) {
if (wandKey == null) {
wandKey = "(default)";
}
sender.sendMessage(api.getMessages().getParameterized("wand.unknown_template", "$name", wandKey));
if (sender != player) {
sender.sendMessage("Wand " + wand.getName() + " has an invalid icon");
}
}
return true;
} else {
api.giveItemToPlayer(player, wand.getItem());
if (sender != player && !quiet) {
sender.sendMessage("Gave wand " + wand.getName() + " to " + player.getName());
}
}
}
if (showWorth) {
showWorth(sender, wand.getItem());
}
} else {
if (!quiet) {
if (wandKey == null) {
wandKey = "(default)";
}
sender.sendMessage(api.getMessages().getParameterized("wand.unknown_template", "$name", wandKey));
}
return false;
}
return true;
}
use of com.elmakers.mine.bukkit.api.wand.Wand 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!");
}
}
Aggregations