package io.github.secondflight.ProgressBar;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;

public class MainPlugin extends JavaPlugin implements Listener {
	public final Logger logger = Logger.getLogger("Minecraft");
	public static MainPlugin plugin;
	
	@Override
	public void onDisable() {
		PluginDescriptionFile pdfFile = this.getDescription();
		this.logger.info(pdfFile.getName() + " has been disabled.");
	}
	
	@Override
	public void onEnable() {
		plugin = this;
		
		PluginDescriptionFile pdfFile = this.getDescription();
		this.logger.info(pdfFile.getName() + " has been Enabled.");
		
		getServer().getPluginManager().registerEvents(this, this);
	
	}
	
	
	// Commands
	public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
	{
		if (sender instanceof Player) {
			Player player = (Player) sender;
			if (commandLabel.equalsIgnoreCase("progressbar") || commandLabel.equalsIgnoreCase("pb")) {
				
				if (args.length == 0) {
					// Command usage message
					
					player.sendMessage("-------------------------------------------");
					player.sendMessage("Usage:");
					player.sendMessage("");
					player.sendMessage("/pb new");
					player.sendMessage("    -- creates a new progress bar");
					player.sendMessage("-------------------------------------------");
					
				}
			}
		} else {
			// this is displayed if the command is called from the console
			logger.warning("You must be a player to use this command.");
		}
		
		
		return false;
		
	}
}

@@ -83,20 +83,68 @@
 va.util.
-List
+HashMap;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0Aimport
@@ -167,24 +167,52 @@
 ng.Logger;%0A%0A
+import org.bukkit.Location;%0A
 import org.b
@@ -332,24 +332,109 @@
 t.event.
-Listener
+EventHandler;%0Aimport org.bukkit.event.Listener;%0Aimport org.bukkit.event.block.BlockPlaceEvent
 ;%0Aimport
@@ -680,16 +680,355 @@
 ugin;%0A%09%0A
+%09public static Map%3CPlayer, Location%3E locationMap1 = new HashMap%3CPlayer, Location%3E();%0A%09public static Map%3CPlayer, Location%3E locationMap2 = new HashMap%3CPlayer, Location%3E();%0A%09public static Map%3CPlayer, Integer%3E depthMap = new HashMap%3CPlayer, Integer%3E();%0A%09public static Map%3CPlayer, Boolean%3E selectionIsActive = new HashMap%3CPlayer, Boolean%3E();%0A%09%0A
 %09@Overri
@@ -1429,16 +1429,293 @@
 %0A%09%0A%09%7D%0A%09%0A
+%09@EventHandler%0A%09public void onBlockPlace (BlockPlaceEvent event) %7B%0A%09%09if (!(selectionIsActive.get(event.getPlayer()) == null)) %7B%0A%09%09%09event.setCancelled(true);%0A%09%09%09if (locationMap1.get(event.getPlayer()) == null && (locationMap2.get(event.getPlayer()) == null)) %7B%0A%09%09%09%09%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A
 %09%0A%09// Co
@@ -2222,16 +2222,31 @@
 %22/pb new
+ (name) (depth)
 %22);%0A%09%09%09%09
@@ -2273,17 +2273,17 @@
 %22    -- 
-c
+C
 reates a
@@ -2299,16 +2299,17 @@
 ress bar
+.
 %22);%0A%09%09%09%09
@@ -2376,25 +2376,343 @@
 ----%22);%0A%09%09%09%09
-%09
+%0A%09%09%09%09%7D else if (args.length == 1 && args%5B0%5D.equalsIgnoreCase(%22new%22)) %7B%0A%09%09%09%09%09player.sendMessage(%22You must include a name. Type /pb for info.%22);%0A%09%09%09%09%7D else if (args.length == 2 && args%5B0%5D.equalsIgnoreCase(%22new%22)) %7B%0A%09%09%09%09%09player.sendMessage(%22Place a block where you want the upper left corner of your progress bar to be.%22);
 %0A%09%09%09%09%7D%0A%09%09%09%7D%0A

set up a command for creating a progress bar