Minestom/src/main/java/net/minestom/server/potion/PotionEffect.java

43 lines
1.2 KiB
Java
Raw Normal View History

2021-07-28 14:29:28 +02:00
package net.minestom.server.potion;
import net.minestom.server.registry.ProtocolObject;
import net.minestom.server.registry.Registry;
import net.minestom.server.utils.NamespaceID;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
2021-10-22 01:55:55 +02:00
public sealed interface PotionEffect extends ProtocolObject, PotionEffects permits PotionEffectImpl {
2021-07-28 14:29:28 +02:00
@Contract(pure = true)
@NotNull Registry.PotionEffectEntry registry();
@Override
default @NotNull NamespaceID namespace() {
return registry().namespace();
}
@Override
default int id() {
return registry().id();
}
static @NotNull Collection<@NotNull PotionEffect> values() {
return PotionEffectImpl.values();
2021-07-28 14:29:28 +02:00
}
static @Nullable PotionEffect fromNamespaceId(@NotNull String namespaceID) {
2021-07-30 15:09:18 +02:00
return PotionEffectImpl.getSafe(namespaceID);
2021-07-28 14:29:28 +02:00
}
static @Nullable PotionEffect fromNamespaceId(@NotNull NamespaceID namespaceID) {
return fromNamespaceId(namespaceID.asString());
}
static @Nullable PotionEffect fromId(int id) {
return PotionEffectImpl.getId(id);
2021-07-28 14:29:28 +02:00
}
}