Check if a player has an infinite potion effect?

Discussion in 'Spigot Plugin Development' started by Xuho, Jun 26, 2018.

  1. How i can check if a player has an infinite potion effect? (The type of the potion does no matter)
  2. I have never really worked with this but have you tried what #getDuration() of the PotionEffects Class returns when the effect is infinite?
  3. An infinite potion effect is when duration > 60-30 minutes (not sure)
  4. Well the best approach would be to test this and then just check if #getDuration() is greater or equal to the 60-30 mins in ticks.
    • Agree Agree x 1
  5. I will try
  6. PotionEffect becomes infinite when its duration goes beyond 1638 seconds (durationInSeconds >= 1639).
    As far as I remember, PotionEffect#getDuration() returns duration in milliseconds so you need to compare it with 1639000.
    - DelfikPro.