Search in sources :

Example 46 with Wand

use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.

the class WandCommandExecutor method onWandDestroy.

public boolean onWandDestroy(CommandSender sender, Player player) {
    Wand wand = checkWand(sender, player);
    if (wand == null) {
        return true;
    }
    Mage mage = controller.getMage(player);
    wand.deactivate();
    wand.unenchant();
    player.getInventory().setItemInMainHand(wand.getItem());
    mage.sendMessage(api.getMessages().get("wand.unenchanted"));
    if (sender != player) {
        sender.sendMessage(api.getMessages().getParameterized("wand.player_unenchanted", "$name", player.getName()));
    }
    return true;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) Wand(com.elmakers.mine.bukkit.api.wand.Wand)

Example 47 with Wand

use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.

the class WandCommandExecutor method onWandName.

public boolean onWandName(CommandSender sender, Player player, String[] parameters) {
    if (parameters.length < 1) {
        sender.sendMessage("Use: /wand name <name>");
        return true;
    }
    Wand wand = checkWand(sender, player);
    if (wand == null) {
        return true;
    }
    Mage mage = controller.getMage(player);
    wand.setName(StringUtils.join(parameters, " "));
    wand.saveState();
    mage.sendMessage(api.getMessages().get("wand.renamed"));
    if (sender != player) {
        sender.sendMessage(api.getMessages().getParameterized("wand.player_renamed", "$name", player.getName()));
    }
    return true;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) Wand(com.elmakers.mine.bukkit.api.wand.Wand)

Example 48 with Wand

use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.

the class WandCommandExecutor method onWandDuplicate.

public boolean onWandDuplicate(CommandSender sender, Player player) {
    Wand wand = checkWand(sender, player, false, false);
    if (wand == null) {
        return true;
    }
    Mage mage = controller.getMage(player);
    Wand newWand = wand.duplicate();
    api.giveItemToPlayer(player, newWand.getItem());
    mage.sendMessage(api.getMessages().get("wand.duplicated"));
    if (sender != player) {
        sender.sendMessage(api.getMessages().getParameterized("wand.player_duplicated", "$name", player.getName()));
    }
    return true;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) Wand(com.elmakers.mine.bukkit.api.wand.Wand)

Example 49 with Wand

use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.

the class WandCommandExecutor method onWandRemove.

public boolean onWandRemove(CommandSender sender, Player player, String[] parameters) {
    if (parameters.length < 1) {
        sender.sendMessage("Use: /wand remove <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 remove brush <material:data>");
            return true;
        }
        String materialKey = parameters[1];
        if (wand.removeBrush(materialKey)) {
            mage.sendMessage("Brush '" + materialKey + "' has been removed from your wand");
            if (sender != player) {
                sender.sendMessage("Removed brush '" + materialKey + "' from " + player.getName() + "'s wand");
            }
            wand.saveState();
        } else {
            if (sender != player) {
                sender.sendMessage(player.getName() + "'s wand does not have brush " + materialKey);
            }
        }
        return true;
    }
    if (wand.removeSpell(spellName)) {
        SpellTemplate template = api.getSpellTemplate(spellName);
        if (template != null) {
            spellName = template.getName();
        }
        mage.sendMessage("Spell '" + spellName + "' has been removed from your wand");
        if (sender != player) {
            sender.sendMessage("Removed '" + spellName + "' from " + player.getName() + "'s wand");
        }
        wand.saveState();
    } else {
        if (sender != player) {
            sender.sendMessage(player.getName() + "'s wand does not have " + spellName);
        }
    }
    return true;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) Wand(com.elmakers.mine.bukkit.api.wand.Wand) SpellTemplate(com.elmakers.mine.bukkit.api.spell.SpellTemplate)

Example 50 with Wand

use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.

the class WandCommandExecutor method onWandConfigure.

public boolean onWandConfigure(CommandSender sender, Player player, String[] parameters, boolean safe) {
    Wand wand = checkWand(sender, player);
    if (wand == null) {
        return true;
    }
    boolean result = onConfigure("wand", wand, sender, player, parameters, safe);
    Mage mage = controller.getMage(player);
    wand.deactivate();
    mage.checkWand();
    return result;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) Wand(com.elmakers.mine.bukkit.api.wand.Wand)

Aggregations

Wand (com.elmakers.mine.bukkit.api.wand.Wand)60 Mage (com.elmakers.mine.bukkit.api.magic.Mage)47 ItemStack (org.bukkit.inventory.ItemStack)20 Player (org.bukkit.entity.Player)18 MageController (com.elmakers.mine.bukkit.api.magic.MageController)14 Entity (org.bukkit.entity.Entity)10 SpellTemplate (com.elmakers.mine.bukkit.api.spell.SpellTemplate)7 WandUpgradePath (com.elmakers.mine.bukkit.api.wand.WandUpgradePath)7 ArrayList (java.util.ArrayList)7 CasterProperties (com.elmakers.mine.bukkit.api.magic.CasterProperties)6 MageClass (com.elmakers.mine.bukkit.api.magic.MageClass)5 Inventory (org.bukkit.inventory.Inventory)5 ItemMeta (org.bukkit.inventory.meta.ItemMeta)5 ProgressionPath (com.elmakers.mine.bukkit.api.magic.ProgressionPath)4 Spell (com.elmakers.mine.bukkit.api.spell.Spell)4 MaterialAndData (com.elmakers.mine.bukkit.block.MaterialAndData)4 Nullable (javax.annotation.Nullable)4 Checker (ch.njol.util.Checker)3 IOException (java.io.IOException)3 Block (org.bukkit.block.Block)3