From a64fc3cb3a094b8449d642964a8db78c309da43c Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Wed, 27 Dec 2023 17:52:01 +0100 Subject: [PATCH] Use `-1` as default potion effect duration. NOTE: It might be worth exploring the idea of allowing -1 as a valid duration value instead. Another option is to actually clean up the whole potion effect parser portion of the code base and inject a default value resolved at load-time by checking the Minecraft version. Minecraft 1.19.4 introduces "true infinite" potion effect durations, and these are represented in the Bukkit API by the sentinel value -1 [1][2], which means all we need to do is change the default duration value. This change makes 1.94.4 _mandatory_, as potion effects with a negative duration result in an error from the Bukkit API in earlier versions, so this little change effectively removes backwards compatibility from the plugin even though the rest of it works fine. Closes #784 --- [1] https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/potion/PotionEffect.java#27 [2] https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/potion/PotionEffect.java#209-211 --- .../java/com/garbagemule/MobArena/util/PotionEffectParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/garbagemule/MobArena/util/PotionEffectParser.java b/src/main/java/com/garbagemule/MobArena/util/PotionEffectParser.java index 8e005525..6922e12f 100644 --- a/src/main/java/com/garbagemule/MobArena/util/PotionEffectParser.java +++ b/src/main/java/com/garbagemule/MobArena/util/PotionEffectParser.java @@ -11,7 +11,7 @@ public class PotionEffectParser { private static final int TICKS_PER_SECOND = 20; private static final int DEFAULT_POTION_AMPLIFIER = 0; - private static final int DEFAULT_POTION_DURATION = Integer.MAX_VALUE; + private static final int DEFAULT_POTION_DURATION = -1; public static List parsePotionEffects(String s) { if (s == null || s.isEmpty())