Skip to content

Commit 81ac6f7

Browse files
authored
Fix potion command not supporting infinite durations (#6236)
Minecraft understands infinite durations to be `-1` and only `-1`. Our second -> tick conversion was changing this to `-20` causing a potion command with a `-1` duration to end up as `-20` and only causing the potion to occur for 1 tick. Fixes #5558
1 parent 7bc91f1 commit 81ac6f7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ public void addPotionMeta(final CommandSource sender, final boolean allowShortNa
549549
} else if (split[0].equalsIgnoreCase("duration") || (allowShortName && split[0].equalsIgnoreCase("d"))) {
550550
if (NumberUtil.isInt(split[1])) {
551551
validPotionDuration = true;
552-
duration = Integer.parseInt(split[1]) * 20; //Duration is in ticks by default, converted to seconds
552+
final int parsed = Integer.parseInt(split[1]);
553+
duration = parsed == -1 ? -1 : parsed * 20; //Duration is in ticks by default, converted to seconds
553554
} else {
554555
throw new TranslatableException("invalidPotionMeta", split[1]);
555556
}

0 commit comments

Comments
 (0)