package me.jacobcrofts.simplestructureloader.commands;

import java.io.IOException;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.json.simple.parser.ParseException;

import me.jacobcrofts.simplestructureloader.api.StructureAPI;
import me.jacobcrofts.simplestructureloader.util.Selection;

public class CmdPasteStructure implements CommandExecutor {

	@Override
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
		
		if (sender instanceof Player) {			
			Selection selection;
			try {
				selection = new Selection(StructureAPI.readFromFile("plugins/structures/" + args[0] + ".json"));
				StructureAPI.placeStructure(selection, ((Player) sender).getLocation());
			} catch (IOException | ParseException e) {
				e.printStackTrace();
			}
			return true;
		}
		
		return false;
	}

}

@@ -74,24 +74,81 @@
 Exception;%0A%0A
+import org.bukkit.ChatColor;%0Aimport org.bukkit.GameMode;%0A
 import org.b
@@ -665,12 +665,119 @@
 r) %7B
+%0A
 %09%09%09
-%0A
+Player player = (Player) sender;%0A%09%09%09if (player.getGameMode() == GameMode.CREATIVE && player.isOp()) %7B%09%09%09%09%0A%09
 %09%09%09S
@@ -803,14 +803,16 @@
 %0A%09%09%09
+%09
 try %7B%0A
+%09
 %09%09%09%09
@@ -912,16 +912,17 @@
 ));%0A%09%09%09%09
+%09
 Structur
@@ -956,25 +956,14 @@
 on, 
-((P
+p
 layer
-) sender)
 .get
@@ -975,16 +975,17 @@
 ion());%0A
+%09
 %09%09%09%7D cat
@@ -1026,16 +1026,17 @@
 ) %7B%0A%09%09%09%09
+%09
 e.printS
@@ -1055,24 +1055,213 @@
 %0A%09%09%09
-%7D%0A%09%09%09return true
+%09%7D%0A%09%09%09%7D else %7B%0A%09%09%09%09player.sendMessage(ChatColor.RED + %22You do not have permission to execute this command.%22);%0A%09%09%09%7D%0A%09%09%09return true;%0A%09%09%7D else %7B%0A%09%09%09sender.sendMessage(%22Only players may perform this command.%22)
 ;%0A%09%09

Add feature: error handling for paste command