package com.censoredsoftware.demigods.ability.passive;

import java.util.List;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

import com.censoredsoftware.demigods.Demigods;
import com.censoredsoftware.demigods.ability.Ability;
import com.censoredsoftware.demigods.deity.Deity;
import com.google.common.collect.Lists;

public class Swim implements Ability
{
	private final static String name = "Swim", command = null;
	private final static int cost = 0, delay = 0, repeat = 20;
	private final static Devotion.Type type = Devotion.Type.PASSIVE;
	private final static List<String> details = Lists.newArrayList("Crouch while in water to swim very fast.");
	private String deity, permission;

	public Swim(final String deity, String permission)
	{
		this.deity = deity;
		this.permission = permission;
	}

	@Override
	public String getDeity()
	{
		return deity;
	}

	@Override
	public String getName()
	{
		return name;
	}

	@Override
	public String getCommand()
	{
		return command;
	}

	@Override
	public String getPermission()
	{
		return permission;
	}

	@Override
	public int getCost()
	{
		return cost;
	}

	@Override
	public int getDelay()
	{
		return delay;
	}

	@Override
	public int getRepeat()
	{
		return repeat;
	}

	@Override
	public List<String> getDetails()
	{
		return details;
	}

	@Override
	public Devotion.Type getType()
	{
		return type;
	}

	@Override
	public Material getWeapon()
	{
		return null;
	}

	@Override
	public boolean hasWeapon()
	{
		return getWeapon() != null;
	}

	@Override
	public Listener getListener()
	{
		return new Listener()
		{
			@EventHandler(priority = EventPriority.HIGHEST)
			private void onPlayerMoveEvent(PlayerMoveEvent event)
			{
				if(Demigods.isDisabledWorld(event.getPlayer().getWorld())) return;

				Player player = event.getPlayer();

				if(!Deity.Util.canUseDeitySilent(player, deity)) return;

				Material playerLocationMaterial = player.getLocation().getBlock().getType();
				if(!playerLocationMaterial.equals(Material.STATIONARY_WATER) && !playerLocationMaterial.equals(Material.WATER))
				{
					Vector victor = player.getLocation().getDirection().normalize().multiply(0.1D);
					player.setVelocity(new Vector(victor.getX(), victor.getY(), victor.getZ()));
					return;
				}

				if(player.isSneaking())
				{
					Vector victor = player.getLocation().getDirection().normalize().multiply(1.3D);
					player.setVelocity(new Vector(victor.getX(), victor.getY(), victor.getZ()));
				}
			}
		};
	}

	@Override
	public BukkitRunnable getRunnable()
	{
		return null;
	}
}

@@ -293,16 +293,98 @@
 eEvent;%0A
+import org.bukkit.potion.PotionEffect;%0Aimport org.bukkit.potion.PotionEffectType;%0A
 import o
@@ -2394,88 +2394,145 @@
 %09%09%09%09
-Vector victor = player.getLocation().getDirection().normalize().multiply(0.1D
+if(!player.hasPotionEffect(PotionEffectType.SLOW))%0A%09%09%09%09%09%7B%0A%09%09%09%09%09%09PotionEffect potion = new PotionEffect(PotionEffectType.SLOW, 6000, 3
 );%0A
+%09
 %09%09%09%09
@@ -2543,77 +2543,39 @@
 yer.
-setVelocity(new Vector(victor.getX(), victor.getY(), victor.getZ()));
+addPotionEffect(potion);%0A%09%09%09%09%09%7D
 %0A%09%09%09

Switch to a potion.