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;
}
Aggregations