use of com.elmakers.mine.bukkit.batch.RegenerateBatch in project MagicPlugin by elBukkit.
the class RegenerateSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Block targetBlock = getTargetBlock();
if (targetBlock == null) {
return SpellResult.NO_TARGET;
}
if (!hasBuildPermission(targetBlock) || !hasBreakPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
if (targetLocation2 != null) {
this.targetBlock = targetLocation2.getBlock();
}
TargetType targetType = getTargetType();
if (this.targetBlock != null || targetType == TargetType.BLOCK) {
Block secondBlock = targetType == TargetType.BLOCK ? targetBlock : this.targetBlock;
RegenerateBatch batch = new RegenerateBatch(this, secondBlock.getLocation(), targetBlock.getLocation());
int maxDimension = parameters.getInt("max_dimension", DEFAULT_MAX_DIMENSION);
maxDimension = (int) (mage.getConstructionMultiplier() * maxDimension);
if (!batch.checkDimension(maxDimension)) {
return SpellResult.FAIL;
}
batch.setExpand(parameters.getBoolean("expand", false));
boolean success = mage.addBatch(batch);
deactivate();
return success ? SpellResult.CAST : SpellResult.FAIL;
} else {
this.targetBlock = targetBlock;
activate();
return SpellResult.TARGET_SELECTED;
}
}
Aggregations