Search in sources :

Example 1 with PreciousStonesManager

use of com.elmakers.mine.bukkit.protection.PreciousStonesManager in project MagicPlugin by elBukkit.

the class CreateFieldAction method perform.

@Override
public SpellResult perform(CastContext context) {
    SpellResult result = super.perform(context);
    if (!result.isSuccess() || fieldType != context.getTargetBlock().getType()) {
        return result;
    }
    MageController apiController = context.getController();
    if (!(apiController instanceof MagicController)) {
        return SpellResult.FAIL;
    }
    MagicController controller = (MagicController) apiController;
    PreciousStonesManager preciousStones = controller.getPreciousStones();
    context.getMage().sendDebugMessage(ChatColor.GRAY + "Placing field", 7);
    if (!preciousStones.createField(context.getTargetLocation(), context.getMage().getPlayer())) {
        context.getMage().sendDebugMessage(ChatColor.RED + "Could not place field", 2);
        return SpellResult.NO_TARGET;
    }
    if (!rent.isEmpty() && !rentPeriod.isEmpty()) {
        if (!preciousStones.rentField(context.getTargetLocation().getBlock().getRelative(BlockFace.UP).getLocation(), context.getMage().getPlayer(), rent, rentPeriod, rentSignDirection)) {
            context.getMage().sendDebugMessage(ChatColor.RED + "Could not rent field", 2);
        }
    }
    return SpellResult.CAST;
}
Also used : MageController(com.elmakers.mine.bukkit.api.magic.MageController) MagicController(com.elmakers.mine.bukkit.magic.MagicController) PreciousStonesManager(com.elmakers.mine.bukkit.protection.PreciousStonesManager) SpellResult(com.elmakers.mine.bukkit.api.spell.SpellResult)

Aggregations

MageController (com.elmakers.mine.bukkit.api.magic.MageController)1 SpellResult (com.elmakers.mine.bukkit.api.spell.SpellResult)1 MagicController (com.elmakers.mine.bukkit.magic.MagicController)1 PreciousStonesManager (com.elmakers.mine.bukkit.protection.PreciousStonesManager)1