You need to call `Entity#setPortalCooldown` twice: once when the entity is within the portal with a cooldown, and once when the entity is teleported by the portal. The first check prevents the entity from being teleported back if they haven't left the portal for a certain period of time. The second is for actually telling the entity that is has been teleported, and that it should verify the first check. You've currently only got the first check in place, which won't do anything on its own. You need to also set the cooldown after the entity has been teleported.