Search in sources :

Example 1 with Wand

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

the class WandCommandExecutor method onWandEnchant.

public boolean onWandEnchant(CommandSender sender, Player player, String levelString) {
    Wand wand = checkWand(sender, player);
    if (wand == null) {
        return false;
    }
    Mage mage = controller.getMage(player);
    int xpLevels = 0;
    boolean useXp = levelString.equalsIgnoreCase("xp");
    if (useXp) {
        xpLevels = mage.getLevel();
    } else {
        try {
            xpLevels = Integer.parseInt(levelString);
        } catch (Exception ex) {
            sender.sendMessage("Invalid parameter: " + levelString);
        }
    }
    int levels = wand.enchant(xpLevels);
    if (levels > 0 && useXp) {
        mage.setLevel(Math.max(0, mage.getLevel() - levels));
    }
    wand.saveState();
    if (sender != player) {
        if (levels > 0) {
            sender.sendMessage(api.getMessages().getParameterized("wand.player_upgraded", "$name", player.getName()));
        } else {
            sender.sendMessage(api.getMessages().getParameterized("wand.player_not_upgraded", "$name", player.getName()));
        }
    }
    return true;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) Wand(com.elmakers.mine.bukkit.api.wand.Wand) IOException(java.io.IOException)

Example 2 with Wand

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

the class WandCommandExecutor method onWandCombine.

public boolean onWandCombine(CommandSender sender, Player player, String[] parameters) {
    if (parameters.length < 1) {
        sender.sendMessage("Use: /wand combine <wandname>");
        return false;
    }
    Wand wand = checkWand(sender, player);
    if (wand == null) {
        return true;
    }
    Mage mage = controller.getMage(player);
    String wandName = parameters[0];
    Wand newWand = api.createWand(wandName);
    if (newWand == null) {
        sender.sendMessage(api.getMessages().getParameterized("wand.unknown_template", "$name", wandName));
        return false;
    }
    wand.deactivate();
    boolean result = wand.add(newWand);
    mage.checkWand();
    if (sender != player) {
        if (result) {
            sender.sendMessage(api.getMessages().getParameterized("wand.player_upgraded", "$name", player.getName()));
        } else {
            sender.sendMessage(api.getMessages().getParameterized("wand.player_not_upgraded", "$name", player.getName()));
        }
    }
    return true;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) Wand(com.elmakers.mine.bukkit.api.wand.Wand)

Example 3 with Wand

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

the class WandCommandExecutor method onWandOverride.

public boolean onWandOverride(CommandSender sender, Player player, String[] parameters) {
    Wand wand = checkWand(sender, player, true, true, false);
    if (wand == null) {
        return true;
    }
    if (parameters.length == 0) {
        Map<String, String> overrides = wand.getOverrides();
        if (overrides.size() == 0) {
            sender.sendMessage(ChatColor.DARK_AQUA + "This wand has no overrides");
        } else {
            for (Map.Entry<String, String> override : overrides.entrySet()) {
                sender.sendMessage(ChatColor.AQUA + override.getKey() + ChatColor.WHITE + " = " + ChatColor.DARK_AQUA + override.getValue());
            }
        }
        return true;
    }
    wand = checkWand(sender, player);
    if (wand == null) {
        return true;
    }
    if (parameters.length == 1) {
        wand.removeOverride(parameters[0]);
        wand.saveState();
        sender.sendMessage(ChatColor.DARK_AQUA + "Removed override " + parameters[0]);
        return true;
    }
    String value = "";
    for (int i = 1; i < parameters.length; i++) {
        if (i != 1)
            value = value + " ";
        value = value + parameters[i];
    }
    wand.setOverride(parameters[0], value);
    wand.saveState();
    sender.sendMessage(ChatColor.DARK_AQUA + "Added override " + ChatColor.AQUA + parameters[0] + ChatColor.WHITE + " = " + ChatColor.DARK_AQUA + parameters[1]);
    return true;
}
Also used : Wand(com.elmakers.mine.bukkit.api.wand.Wand) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 4 with Wand

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

the class WandCommandExecutor method onWandLevelSpells.

public boolean onWandLevelSpells(CommandSender sender, Player player, String[] parameters) {
    Integer maxLevel = null;
    if (parameters.length > 0) {
        try {
            maxLevel = Integer.parseInt(parameters[0]);
        } catch (Exception ex) {
            sender.sendMessage("Usage: /wand levelspells <level>");
            return true;
        }
    }
    Wand wand = checkWand(sender, player);
    if (wand == null) {
        return true;
    }
    return onLevelSpells("wand", sender, player, wand, maxLevel);
}
Also used : Wand(com.elmakers.mine.bukkit.api.wand.Wand) IOException(java.io.IOException)

Example 5 with Wand

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

the class WandCommandExecutor method onWandOrganize.

public boolean onWandOrganize(CommandSender sender, Player player) {
    // Allow reorganizing modifiable wands
    Wand wand = checkWand(sender, player, true);
    if (wand == null) {
        return true;
    }
    Mage mage = controller.getMage(player);
    wand.organizeInventory(mage);
    wand.saveState();
    mage.sendMessage(api.getMessages().get("wand.reorganized").replace("$wand", wand.getName()));
    if (sender != player) {
        sender.sendMessage(api.getMessages().getParameterized("wand.player_reorganized", "$name", player.getName()).replace("$wand", wand.getName()));
    }
    return true;
}
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