/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Justin W. Flory
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.justinwflory.withershot;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;

import java.util.ArrayList;
import java.util.List;

public class BowListener implements Listener, CommandExecutor {
    public List<String> enabledPlayers = new ArrayList<String>();
    Main plugin;

    public BowListener(Main plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        Player p = (Player) sender;

        if (!(sender instanceof Player)) {
            sender.sendMessage("This command can only be run by a player.");
            return true;
        }

        if (cmd.getName().equalsIgnoreCase("withershot") && p.hasPermission("withershot.fire")) {
            if (args.length != 1) {
                p.sendMessage(ChatColor.RED + "You must either enable or disable WitherShot!");
                return false;
            } else if (args[0].equalsIgnoreCase("enable")) {
                enabledPlayers.add(p.getName());
                p.sendMessage(ChatColor.GREEN + "You are now the master of the wither bow!");
            } else if (args[0].equalsIgnoreCase("disable")) {
                enabledPlayers.remove(p.getName());
                p.sendMessage(ChatColor.GREEN + "You have become a normal archer again.");
            }
            return true;
        } else {
            p.sendMessage("You do not have permission to use that command.");
        }
        return true;
    }

    @EventHandler
    public void onShoot(EntityShootBowEvent e) {
        if (e.getEntity() instanceof Player) {
            Player p = (Player) e.getEntity();

            if (enabledPlayers.contains(p.getName())) {
                e.setCancelled(true);
                p.launchProjectile(WitherSkull.class).setVelocity(e.getProjectile().getVelocity().multiply(0.4));
            }
        }
    }
}
@@ -1141,16 +1141,17 @@
 RE.%0A */%0A
+%0A
 package 
@@ -1912,45 +1912,8 @@
 ) %7B%0A
-        Player p = (Player) sender;%0A%0A
     
@@ -2060,24 +2060,61 @@
 %0A        %7D%0A%0A
+        Player p = (Player) sender;%0A%0A
         if (
@@ -2161,46 +2161,8 @@
 ot%22)
- && p.hasPermission(%22withershot.fire%22)
 ) %7B%0A
@@ -2337,32 +2337,90 @@
       %7D else if 
+(p.hasPermission(%22withershot.fire%22)) %7B%0A                if 
 (args%5B0%5D.equalsI
@@ -2450,32 +2450,36 @@
                 
+    
 enabledPlayers.a
@@ -2487,32 +2487,36 @@
 d(p.getName());%0A
+    
                 
@@ -2597,32 +2597,36 @@
 %22);%0A            
+    
 %7D else if (args%5B
@@ -2667,32 +2667,36 @@
                 
+   
+ 
 enabledPlayers.r
@@ -2707,32 +2707,36 @@
 e(p.getName());%0A
+    
                 
@@ -2814,32 +2814,36 @@
 %22);%0A            
+    
 %7D%0A            re
@@ -2836,35 +2836,265 @@
             
-return true
+%7D else if (cmd.getName().equalsIgnoreCase(%22reset%22) && p.hasPermission(%22withershot.clear%22)) %7B%0A                enabledPlayers.clear();%0A                p.sendMessage(ChatColor.GREEN + %22The power of the wither has been extinguished... for now.%22)
 ;%0A        %7D 
@@ -3087,24 +3087,28 @@
 %22);%0A        
+ 
+   
 %7D else %7B%0A   
@@ -3104,16 +3104,20 @@
  else %7B%0A
+    
         
@@ -3182,24 +3182,159 @@
 command.%22);%0A
+            %7D%0A        %7D else %7B%0A            p.sendMessage(ChatColor.RED + %22You entered an invalid command!%22);%0A            return false;%0A
         %7D%0A  

Add /withershot reset, to clear all players with effects