package com.elmakers.mine.bukkit.plugins.magic.spells;

import org.bukkit.block.Block;

import com.elmakers.mine.bukkit.blocks.BlockList;
import com.elmakers.mine.bukkit.blocks.MaterialBrush;
import com.elmakers.mine.bukkit.plugins.magic.BrushSpell;
import com.elmakers.mine.bukkit.plugins.magic.SpellResult;
import com.elmakers.mine.bukkit.utilities.Target;
import com.elmakers.mine.bukkit.utilities.borrowed.ConfigurationNode;

public class PlaceSpell extends BrushSpell 
{
	@Override
	public SpellResult onCast(ConfigurationNode parameters) 
	{
		Target target = getTarget();
		if (!target.isBlock()) return SpellResult.NO_TARGET;
		Block attachBlock = getLastBlock();

		MaterialBrush buildWith = getMaterialBrush();
		buildWith.setTarget(attachBlock.getLocation());

		if (!hasBuildPermission(attachBlock)) {
			return SpellResult.INSUFFICIENT_PERMISSION;
		}
		BlockList placedBlocks = new BlockList();
		placedBlocks.add(attachBlock);
		buildWith.modify(attachBlock);

		registerForUndo(placedBlocks);
		controller.updateBlock(attachBlock);

		return SpellResult.CAST;
	}
}

@@ -550,22 +550,29 @@
 %09Target 
-target
+attachToBlock
  = getTa
@@ -590,14 +590,21 @@
 f (!
-target
+attachToBlock
 .isB
@@ -649,22 +649,21 @@
 %09%09Block 
-attach
+place
 Block = 
@@ -751,24 +751,104 @@
 arget(attach
+ToBlock.getLocation(), placeBlock.getLocation());%0A%09%09buildWith.setTarget(attachTo
 Block.getLoc
@@ -884,22 +884,21 @@
 mission(
-attach
+place
 Block)) 
@@ -1013,22 +1013,21 @@
 cks.add(
-attach
+place
 Block);%0A
@@ -1045,22 +1045,21 @@
 .modify(
-attach
+place
 Block);%0A
@@ -1117,22 +1117,21 @@
 teBlock(
-attach
+place
 Block);%0A

Fix Place spell with copy