	public void onPlayerMove(PlayerMoveEvent event)
	{
		Player player = event.getPlayer();
		Vector vector = player.getVelocity();
		Block blockTo = event.getTo().getBlock();
		Region regionTo = RegionManager.getRegion(event.getTo());
		Region regionFrom = RegionManager.getRegion(event.getFrom());
		PortalManager.checkPlayerMove(player, regionFrom, regionTo);
		if (blockTo.getType() == Material.SUGAR_CANE_BLOCK && regionTo.getBoolean(RegionSetting.ENABLE_GRILLS))
		{
			for (Grill grill: GrillManager.grills)
			{
				if (grill.getInside().contains(blockTo))
				{
					GrillManager.emancipate(player);
				}
			}
		}
		if (player.isInsideVehicle()) return;
		if (!Permission.teleport(player)) return;
		double addX = 0.0;
		double addY = 0.0;
		double addZ = 0.0;
		if (Math.abs(vector.getX()) > 1)
		{
			addX += 3.0;
			addY += 2.0;
			addZ += 2.0;
		}
		if (Math.abs(vector.getZ()) > 1)
		{
			addX += 2.0;
			addY += 2.0;
			addZ += 3.0;
		}
		if (Math.abs(vector.getY()) > 1)
		{
			addX += 2.0;
			addY += 3.0;
			addZ += 2.0;
		}
		Portal portal = null;
		for (Portal p : PortalManager.portals)
		{
			for (Block b : p.getInside())
			{
				if (offsetequals(b.getLocation().getX(), blockTo.getX(),addX) && offsetequals(b.getLocation().getZ(), blockTo.getZ(), addZ) && offsetequals(b.getLocation().getY(), blockTo.getY(),addY))
				{
					portal = p;
					break;
				}
			}	 
		}
		if (portal != null)
		{
			if (!portal.isOpen() || portal.isDisabled()) return;
			User owner = portal.getOwner();
			Location teleport;
			Portal destination;
			if (portal.isOrange())
				destination = owner.getBluePortal();
			else
				destination = owner.getOrangePortal();
			teleport = destination.getTeleportLocation().clone();
			float yaw = 0;
			float pitch = 0;
			Double momentum = 0.0;
			switch(portal.getTeleportFace())
	        {
	        	case NORTH:
	        	case SOUTH:
	        		momentum = vector.getX();
	        		break;
	        	case EAST:
	        	case WEST:
	        		momentum = vector.getZ();
	        		break;
	        	case UP:
	        	case DOWN:
	        		momentum = vector.getY();
	        		break;
	        }
			momentum = Math.abs(momentum);
			momentum = momentum * regionTo.getDouble(RegionSetting.VELOCITY_MULTIPLIER);
			Vector outvector = player.getVelocity().zero();
			switch(destination.getTeleportFace())
	        {
	        	case NORTH:
	        		yaw = 270;
	        		outvector = outvector.setX(momentum);
	        		break;
	        	case EAST:
	        		yaw = 0;
	        		outvector = outvector.setZ(momentum);
	        		break;
	        	case SOUTH:
	        		yaw = 90;
	        		outvector = outvector.setX(-momentum);
	        		break;
	        	case WEST:
	        		yaw = 180;
	        		outvector = outvector.setZ(-momentum);
	        		break;
	        	case UP:
	        		pitch = 90;
	        		outvector = outvector.setY(momentum);
	        		break;
	        	case DOWN:
	        		pitch = -90;
	        		outvector = outvector.setY(-momentum);
	        		break;
	        }
			player.setFallDistance(0);	
			player.setVelocity(player.getVelocity().zero());
			teleport.setPitch(pitch);
			teleport.setYaw(yaw);
			event.setTo(teleport);
			player.teleport(teleport);
			player.setVelocity(outvector);
			destination.setDisabled(true);
			plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new EnablePortal(destination), 10L);
		}
	}

	public void onPlayerMove(PlayerMoveEvent event)
	{
		Player player = event.getPlayer();
		Vector vector = player.getVelocity();
		Block blockTo = event.getTo().getBlock();
		Region regionTo = RegionManager.getRegion(event.getTo());
		Region regionFrom = RegionManager.getRegion(event.getFrom());
		PortalManager.checkPlayerMove(player, regionFrom, regionTo);
		if (blockTo.getType() == Material.SUGAR_CANE_BLOCK && regionTo.getBoolean(RegionSetting.ENABLE_GRILLS))
		{
			for (Grill grill: GrillManager.grills)
			{
				if (grill.getInside().contains(blockTo))
				{
					GrillManager.emancipate(player);
				}
			}
		}
		if (player.isInsideVehicle()) return;
		if (!Permission.teleport(player)) return;
		double addX = 0.0;
		double addY = 0.0;
		double addZ = 0.0;
		if (Math.abs(vector.getX()) > 1)
		{
			addX += 3.0;
			addY += 2.0;
			addZ += 2.0;
		}
		if (Math.abs(vector.getZ()) > 1)
		{
			addX += 2.0;
			addY += 2.0;
			addZ += 3.0;
		}
		if (Math.abs(vector.getY()) > 1)
		{
			addX += 2.0;
			addY += 3.0;
			addZ += 2.0;
		}
		Portal portal = null;
		for (Portal p : PortalManager.portals)
		{
			for (Block b : p.getInside())
			{
				if (offsetequals(b.getLocation().getX(), blockTo.getX(),addX) && offsetequals(b.getLocation().getZ(), blockTo.getZ(), addZ) && offsetequals(b.getLocation().getY(), blockTo.getY(),addY))
				{
					portal = p;
					break;
				}
			}	 
		}
		if (portal != null)
		{
			if (!portal.isOpen() || portal.isDisabled()) return;
			if (Math.abs(vector.getY()) > 1 && !portal.isVertical()) return;
			User owner = portal.getOwner();
			Location teleport;
			Portal destination;
			if (portal.isOrange())
				destination = owner.getBluePortal();
			else
				destination = owner.getOrangePortal();
			teleport = destination.getTeleportLocation().clone();
			float yaw = 0;
			float pitch = 0;
			Double momentum = 0.0;
			switch(portal.getTeleportFace())
	        {
	        	case NORTH:
	        	case SOUTH:
	        		momentum = vector.getX();
	        		break;
	        	case EAST:
	        	case WEST:
	        		momentum = vector.getZ();
	        		break;
	        	case UP:
	        	case DOWN:
	        		momentum = vector.getY();
	        		break;
	        }
			momentum = Math.abs(momentum);
			momentum = momentum * regionTo.getDouble(RegionSetting.VELOCITY_MULTIPLIER);
			Vector outvector = player.getVelocity().zero();
			switch(destination.getTeleportFace())
	        {
	        	case NORTH:
	        		yaw = 270;
	        		outvector = outvector.setX(momentum);
	        		break;
	        	case EAST:
	        		yaw = 0;
	        		outvector = outvector.setZ(momentum);
	        		break;
	        	case SOUTH:
	        		yaw = 90;
	        		outvector = outvector.setX(-momentum);
	        		break;
	        	case WEST:
	        		yaw = 180;
	        		outvector = outvector.setZ(-momentum);
	        		break;
	        	case UP:
	        		pitch = 90;
	        		outvector = outvector.setY(momentum);
	        		break;
	        	case DOWN:
	        		pitch = -90;
	        		outvector = outvector.setY(-momentum);
	        		break;
	        }
			player.setFallDistance(0);	
			player.setVelocity(player.getVelocity().zero());
			teleport.setPitch(pitch);
			teleport.setYaw(yaw);
			event.setTo(teleport);
			player.teleport(teleport);
			player.setVelocity(outvector);
			destination.setDisabled(true);
			plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new EnablePortal(destination), 10L);
		}
	}
