In short:
if it's a neuter noun then the ending in plural form is -a (1 piwo - 2 piwa)
if it's a masculine or feminine noun:
- and the last consonant is k or g then the ending in plural form is -i (1 wódka - 2 wódki)
- and the last consonant is ń, ni, sz, cz, rz/ż, l, j, c, dz, ś, ć or ź than the ending in plural form is -e (1 tokaj - 2 tokaje)
- and the last consonant is any other letter then the ending in plural form is -y (1 miód - 2 miody)