Skip to content

Commit 9672fd7

Browse files
authored
Improve PotionEffect(.Builder) javadocs (#2403)
* Improve PotionEffect(.Builder) javadocs Fixes outright issues in some of the builder javadocs and elaborates on some non-obvious methods * Further javadoc improvements/fixes * Update ambient description & improve consistency
1 parent 3a6fb4b commit 9672fd7

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ static Builder builder() {
5757
* duration in ticks.
5858
*
5959
* @param type The potion type
60-
* @param amplifier The amplifier
60+
* @param amplifier The zero-indexed amplifier
6161
* @param duration The duration in ticks
6262
* @return The potion effect
63+
* @throws IllegalArgumentException If the amplifier is negative or the duration is not positive
6364
*/
64-
static PotionEffect of(PotionEffectType type, int amplifier, int duration) {
65+
static PotionEffect of(PotionEffectType type, int amplifier, int duration) throws IllegalArgumentException {
6566
return PotionEffect.builder().potionType(type).amplifier(amplifier).duration(duration).build();
6667
}
6768

@@ -74,8 +75,9 @@ static PotionEffect of(PotionEffectType type, int amplifier, int duration) {
7475
* @param amplifier The amplifier
7576
* @param duration The duration in ticks
7677
* @return The potion effect
78+
* @throws IllegalArgumentException If the amplifier is negative or the duration is not positive
7779
*/
78-
static PotionEffect of(Supplier<? extends PotionEffectType> type, int amplifier, int duration) {
80+
static PotionEffect of(Supplier<? extends PotionEffectType> type, int amplifier, int duration) throws IllegalArgumentException {
7981
return PotionEffect.builder().potionType(type).amplifier(amplifier).duration(duration).build();
8082
}
8183

@@ -90,22 +92,23 @@ static PotionEffect of(Supplier<? extends PotionEffectType> type, int amplifier,
9092
* Gets the duration in ticks for which this potion effect
9193
* will apply for.
9294
*
93-
* @return The duration.
95+
* @return The duration in ticks.
9496
*/
9597
int duration();
9698

9799
/**
98100
* Gets the amplifier at which this potion effect
99101
* will apply effects.
100102
*
101-
* @return The amplifier.
103+
* @return The amplifier as a zero-indexed integer.
102104
*/
103105
int amplifier();
104106

105107
/**
106-
* Gets if the potion effect is an ambient effect.
108+
* Gets whether or not this potion effect is an ambient effect.
109+
* Ambient potions emit more translucent particles.
107110
*
108-
* @return Gets if ambient.
111+
* @return If the effect should be ambient.
109112
*/
110113
boolean isAmbient();
111114

@@ -152,15 +155,18 @@ default Builder potionType(Supplier<? extends PotionEffectType> potionEffectType
152155
/**
153156
* Sets the duration in ticks of the potion effect.
154157
*
158+
* <p>The duration must be greater than zero ticks.</p>
159+
*
155160
* @param duration The duration in ticks of this effect
156161
* @return This builder, for chaining
162+
* @throws IllegalArgumentException If the duration is less than or equal to zero
157163
*/
158-
Builder duration(int duration);
164+
Builder duration(int duration) throws IllegalArgumentException;
159165

160166
/**
161167
* Sets the amplifier power of the potion effect.
162168
*
163-
* <p>Amplifiers must be above zero.</p>
169+
* <p>Amplifiers must be greater than or equal to zero.</p>
164170
*
165171
* @param amplifier The amplifier power
166172
* @return This builder, for chaining
@@ -169,23 +175,24 @@ default Builder potionType(Supplier<? extends PotionEffectType> potionEffectType
169175
Builder amplifier(int amplifier) throws IllegalArgumentException;
170176

171177
/**
172-
* Sets the potion effect to be ambient or not.
178+
* Sets whether the potion effect is ambient.
179+
* Ambient potions emit more translucent particles.
173180
*
174181
* @param ambient Whether the potion effect is ambient
175182
* @return This builder, for chaining
176183
*/
177184
Builder ambient(boolean ambient);
178185

179186
/**
180-
* Sets the potion effect to show particles when applied or not.
187+
* Sets whether the potion effect should show particles when applied.
181188
*
182189
* @param showParticles Whether the potion effect will show particles
183190
* @return This builder, for chaining
184191
*/
185192
Builder showParticles(boolean showParticles);
186193

187194
/**
188-
* Sets the potion effect to show its icon when applied or not.
195+
* Sets whether the potion effect should show its icon when applied.
189196
*
190197
* @param showIcon Whether the potion effect will show its icon
191198
* @return This builder, for chaining

0 commit comments

Comments
 (0)