Skip to content

Commit 96baed5

Browse files
author
Daniel Naylor
committed
Make duration in PotionEffect use Ticks
1 parent 9672fd7 commit 96baed5

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/main/java/org/spongepowered/api/effect/potion/PotionEffect.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.spongepowered.api.data.persistence.DataSerializable;
3131
import org.spongepowered.api.entity.Entity;
3232
import org.spongepowered.api.util.CopyableBuilder;
33+
import org.spongepowered.api.util.Ticks;
3334

3435
import java.util.function.Supplier;
3536

@@ -62,7 +63,7 @@ static Builder builder() {
6263
* @return The potion effect
6364
* @throws IllegalArgumentException If the amplifier is negative or the duration is not positive
6465
*/
65-
static PotionEffect of(PotionEffectType type, int amplifier, int duration) throws IllegalArgumentException {
66+
static PotionEffect of(final PotionEffectType type, final int amplifier, final Ticks duration) throws IllegalArgumentException {
6667
return PotionEffect.builder().potionType(type).amplifier(amplifier).duration(duration).build();
6768
}
6869

@@ -77,7 +78,7 @@ static PotionEffect of(PotionEffectType type, int amplifier, int duration) throw
7778
* @return The potion effect
7879
* @throws IllegalArgumentException If the amplifier is negative or the duration is not positive
7980
*/
80-
static PotionEffect of(Supplier<? extends PotionEffectType> type, int amplifier, int duration) throws IllegalArgumentException {
81+
static PotionEffect of(final Supplier<? extends PotionEffectType> type, final int amplifier, final Ticks duration) throws IllegalArgumentException {
8182
return PotionEffect.builder().potionType(type).amplifier(amplifier).duration(duration).build();
8283
}
8384

@@ -94,12 +95,17 @@ static PotionEffect of(Supplier<? extends PotionEffectType> type, int amplifier,
9495
*
9596
* @return The duration in ticks.
9697
*/
97-
int duration();
98+
Ticks duration();
9899

99100
/**
100101
* Gets the amplifier at which this potion effect
101102
* will apply effects.
102103
*
104+
* <p>A potion amplifier dictates the potion level <strong>as a zero based
105+
* index</strong>. An amplifier of zero will produce a potion effect of
106+
* level 1 (e.g. Strength I), while an amplifier of four will produce a
107+
* potion effect corresponding to a potion of level 4 (e.g. Strength V).</p>
108+
*
103109
* @return The amplifier as a zero-indexed integer.
104110
*/
105111
int amplifier();
@@ -148,7 +154,7 @@ interface Builder extends org.spongepowered.api.util.Builder<PotionEffect, Build
148154
* @param potionEffectType The type of item
149155
* @return This builder, for chaining
150156
*/
151-
default Builder potionType(Supplier<? extends PotionEffectType> potionEffectType) {
157+
default Builder potionType(final Supplier<? extends PotionEffectType> potionEffectType) {
152158
return this.potionType(potionEffectType.get());
153159
}
154160

@@ -161,12 +167,14 @@ default Builder potionType(Supplier<? extends PotionEffectType> potionEffectType
161167
* @return This builder, for chaining
162168
* @throws IllegalArgumentException If the duration is less than or equal to zero
163169
*/
164-
Builder duration(int duration) throws IllegalArgumentException;
170+
Builder duration(Ticks duration) throws IllegalArgumentException;
165171

166172
/**
167173
* Sets the amplifier power of the potion effect.
168174
*
169-
* <p>Amplifiers must be greater than or equal to zero.</p>
175+
* <p>Amplifiers must be greater than or equal to zero. See
176+
* {@link #amplifier()} for an explanation of what the amplifier means.
177+
* </p>
170178
*
171179
* @param amplifier The amplifier power
172180
* @return This builder, for chaining

0 commit comments

Comments
 (0)