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

34 lines
983 B
Java
Raw Normal View History

2021-07-28 14:29:28 +02:00
package net.minestom.server.potion;
import net.minestom.server.registry.Registry;
2021-07-28 14:29:28 +02:00
import net.minestom.server.utils.NamespaceID;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
record PotionTypeImpl(NamespaceID namespace, int id) implements PotionType {
private static final Registry.Container<PotionType> CONTAINER = Registry.createStaticContainer(Registry.Resource.POTION_TYPES,
2022-02-04 22:28:05 +01:00
(namespace, properties) -> new PotionTypeImpl(NamespaceID.from(namespace), properties.getInt("id")));
static PotionType get(@NotNull String namespace) {
2021-07-30 15:29:05 +02:00
return CONTAINER.get(namespace);
}
static PotionType getSafe(@NotNull String namespace) {
2021-07-30 15:29:05 +02:00
return CONTAINER.getSafe(namespace);
}
static PotionType getId(int id) {
2021-07-30 15:29:05 +02:00
return CONTAINER.getId(id);
}
static Collection<PotionType> values() {
2021-07-30 15:29:05 +02:00
return CONTAINER.values();
}
@Override
public String toString() {
return name();
}
2021-07-28 14:29:28 +02:00
}