diff --git a/src/main/java/net/minestom/server/potion/Potion.java b/src/main/java/net/minestom/server/potion/Potion.java index d5e5ca161..8edf3a79d 100644 --- a/src/main/java/net/minestom/server/potion/Potion.java +++ b/src/main/java/net/minestom/server/potion/Potion.java @@ -8,8 +8,8 @@ import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.binary.Writeable; import org.jetbrains.annotations.NotNull; -public record Potion(PotionEffect effect, byte amplifier, int duration, byte flags) - implements Writeable { +public record Potion(@NotNull PotionEffect effect, byte amplifier, + int duration, byte flags) implements Writeable { /** * A flag indicating that this Potion is ambient (it came from a beacon). * @@ -18,7 +18,7 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla * @see #flags() */ public static final byte AMBIENT_FLAG = 0x01; - + /** * A flag indicating that this Potion has particles. * @@ -27,7 +27,7 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla * @see #flags() */ public static final byte PARTICLES_FLAG = 0x02; - + /** * A flag indicating that this Potion has an icon. * @@ -36,15 +36,19 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla * @see #flags() */ public static final byte ICON_FLAG = 0x04; - + + public Potion(@NotNull PotionEffect effect, byte amplifier, int duration) { + this(effect, amplifier, duration, (byte) 0); + } + public Potion(BinaryReader reader) { this(PotionEffect.fromId(reader.readVarInt()), reader.readByte(), reader.readVarInt(), reader.readByte()); } - + /** * Returns the flags that this Potion has. - * + * * @see #AMBIENT_FLAG * @see #PARTICLES_FLAG * @see #ICON_FLAG @@ -53,29 +57,32 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla public byte flags() { return flags; } - + /** * Returns whether this Potion is ambient (it came from a beacon) or not. + * * @return true if the Potion is ambient */ public boolean isAmbient() { - return (flags & AMBIENT_FLAG) == AMBIENT_FLAG; + return (flags & AMBIENT_FLAG) == AMBIENT_FLAG; } - + /** * Returns whether this Potion has particles or not. + * * @return true if the Potion has particles */ public boolean hasParticles() { - return (flags & PARTICLES_FLAG) == PARTICLES_FLAG; + return (flags & PARTICLES_FLAG) == PARTICLES_FLAG; } - + /** * Returns whether this Potion has an icon or not. + * * @return true if the Potion has an icon */ public boolean hasIcon() { - return (flags & ICON_FLAG) == ICON_FLAG; + return (flags & ICON_FLAG) == ICON_FLAG; } /**