/*
 * Copyright 2015 CrystalCraftMC
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.crystalcraftmc.pvpstorm;

import me.confuser.barapi.BarAPI;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;

import java.io.IOException;
import java.util.Collection;

public class PvPStorm extends JavaPlugin {
    public void onEnable() {
        getLogger().info(ChatColor.AQUA + "PvPStorm has been initialized!");

        try {
            MetricsLite metrics = new MetricsLite(this);
            metrics.start();
        } catch (IOException e) {
            // Failed to submit the stats :-(
        }

        GameStartListener gameStart = new GameStartListener(this);
        GameEndListener gameEnd = new GameEndListener(this);
        getServer().getPluginManager().registerEvents(gameStart, this);
        getServer().getPluginManager().registerEvents(gameEnd, this);
    }

    public void onDisable() { getLogger().info(ChatColor.RED + "PvPStorm has been stopped by the server."); }

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (cmd.getName().equalsIgnoreCase("storm")) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("This command can only be run by a player.");
                return false;
            } else if (args.length < 1) {
                return false;
            } else if (args.length >= 1) {
                Player p = (Player) sender;
                World world = p.getWorld();

                if (args[0].equalsIgnoreCase("start")) {
                    Bukkit.broadcastMessage(ChatColor.DARK_RED + getConfig().getString("start-message"));
                    if (getServer().getPluginManager().getPlugin("BarAPI") != null) setBar(ChatColor.DARK_RED + getConfig().getString("start-message"));
                    world.setStorm(true);
                    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                        @Override
                        public void run() {
                            Bukkit.broadcastMessage(ChatColor.DARK_RED + "The PvP Storm is now hitting the Arena!");
                            if (getServer().getPluginManager().getPlugin("BarAPI") != null) setBar(ChatColor.DARK_RED + "The PvP Storm is now hitting the Arena!");
                        }
                    }, 12000L); // 12000L == 10 minutes, 60L == 3 seconds, 20L == 1 second (it's the # of ticks)
                    // TODO Alert the listener to begin counting who hits the Stormer, in order to give prizes at end
                    return true;
                } else if (args[0].equalsIgnoreCase("stop")) {
                    Bukkit.broadcastMessage(ChatColor.AQUA + getConfig().getString("end-message"));
                    world.setStorm(false);
                    // TODO Alert listener to stop counting and give out awards
                    return true;
                } else if (args[0].equalsIgnoreCase("power")) {
                    if (args.length < 2) {
                        sender.sendMessage(ChatColor.YELLOW + "The available Storm powers are:\n" +
                                ChatColor.RED + "/storm power flare\n" +
                                ChatColor.GRAY + "/storm power vanish\n" +
                                ChatColor.AQUA + "/storm power timewarp");
                        return true;
                    } else if (args[1].equalsIgnoreCase("flare")) { //TODO Add a cooldown of 30 seconds
                        Collection<? extends Player> players = Bukkit.getOnlinePlayers();
                        Location senderLoc = p.getLocation();
                        Location nearbyLoc;

                        Bukkit.broadcastMessage(p.getDisplayName() + ChatColor.YELLOW + " used " + ChatColor.GOLD + " FLARE " + ChatColor.YELLOW + " ability!");
                        for (Player nearbyPlayer : players) {
                            if (nearbyPlayer.getLocation().distanceSquared(senderLoc) <= 25) {
                                nearbyLoc = nearbyPlayer.getLocation();

                                if (nearbyPlayer.getHealth() <= 2.0 && nearbyPlayer != p) nearbyPlayer.setHealth(0.0D);
                                else if (nearbyPlayer != p) nearbyPlayer.setHealth(nearbyPlayer.getHealth() - 2.0);
                                nearbyPlayer.playSound(nearbyLoc, Sound.SUCCESSFUL_HIT, 1, 1);
                            }
                            p.playSound(senderLoc, Sound.EXPLODE, 1, 1);
                        }
                        if (p.getHealth() > 3.0) p.setHealth(p.getHealth() - 3.0);
                        else if (p.getHealth() <= 1.0) {
                            p.setHealth(0.0D);
                            Bukkit.broadcastMessage(p.getDisplayName() + ChatColor.RED + " commit suicide with their own powers!");
                        }
                        else p.setHealth(1.0);
                        return true;
                    } else if (args[1].equalsIgnoreCase("vanish")) { //TODO Add a cooldown of 3 minutes
                        Bukkit.broadcastMessage(p.getDisplayName() + ChatColor.YELLOW + " used " + ChatColor.GRAY + " VANISH " + ChatColor.YELLOW + " ability!");
                        p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 3600, 0, false, false));
                        if (p.getHealth() > 5.0) p.setHealth(p.getHealth() - 5.0);
                        else if (p.getHealth() <= 1.0) {
                            p.setHealth(0.0D);
                            Bukkit.broadcastMessage(p.getDisplayName() + ChatColor.RED + " commit suicide with their own powers!");
                        } else p.setHealth(1.0);
                        return true;
                    } else if (args[1].equalsIgnoreCase("timewarp")) { //TODO Add a cooldown of 15 seconds
                        Vector direction = p.getLocation().getDirection();

                        Bukkit.broadcastMessage(p.getDisplayName() + ChatColor.YELLOW + " used " + ChatColor.RED + " TIMEWARP " + ChatColor.YELLOW + " ability!");
                        p.setVelocity(new Vector(direction.getX() * -2.5, 1.2, direction.getZ() * -2.5));
                        p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 300, 0));
                        return true;
                    }
                } else {
                    return false;
                }
            }
        }
        return false;
    }

    private void setBar(String message) {
        for(Player p : Bukkit.getOnlinePlayers()){
            if(BarAPI.hasBar(p)){
                BarAPI.removeBar(p);
            }
            BarAPI.setMessage(p, message);
        }
    }
}
@@ -2858,42 +2858,8 @@
 ) %7B%0A
-                        @Override%0A
     

Remove unnecessary @Override annotation