Suspicious Effect Entry API
Exposes a new suspicious effect entry type that properly represents storable effects in the context of suspicious effects as they only define the potion effect type and duration. This differentiates them from the existing PotionEffect API found in bukkit and hence clarifies that storable values in the parts of the API in which it replaces PotionEffect. Co-authored-by: Yannick Lamprecht <yannicklamprecht@live.de>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package io.papermc.paper.potion;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Represents a {@link PotionEffectType} paired with a duration.
|
||||
*/
|
||||
@NullMarked
|
||||
public sealed interface SuspiciousEffectEntry permits SuspiciousEffectEntryImpl {
|
||||
|
||||
/**
|
||||
* Gets the effect type.
|
||||
*
|
||||
* @return effect type
|
||||
*/
|
||||
PotionEffectType effect();
|
||||
|
||||
/**
|
||||
* Gets the duration for this effect instance.
|
||||
*
|
||||
* @return duration (in ticks) or {@link PotionEffect#INFINITE_DURATION}
|
||||
*/
|
||||
int duration();
|
||||
|
||||
/**
|
||||
* Creates a new instance of SuspiciousEffectEntry.
|
||||
*
|
||||
* @param effectType effect type
|
||||
* @param duration duration (in ticks) or {@link PotionEffect#INFINITE_DURATION}
|
||||
* @return new instance of an entry
|
||||
*/
|
||||
@Contract(value = "_, _ -> new", pure = true)
|
||||
static SuspiciousEffectEntry create(final PotionEffectType effectType, final int duration) {
|
||||
return new SuspiciousEffectEntryImpl(effectType, duration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package io.papermc.paper.potion;
|
||||
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@NullMarked
|
||||
record SuspiciousEffectEntryImpl(PotionEffectType effect, int duration) implements SuspiciousEffectEntry {
|
||||
}
|
||||
Reference in New Issue
Block a user