Minestom/src/main/java/net/minestom/server/item/EnchantmentImpl.java

33 lines
933 B
Java
Raw Normal View History

2021-07-28 13:27:49 +02:00
package net.minestom.server.item;
import net.minestom.server.registry.Registry;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
2021-12-19 20:17:44 +01:00
record EnchantmentImpl(Registry.EnchantmentEntry registry) implements Enchantment {
private static final Registry.Container<Enchantment> CONTAINER = Registry.createContainer(Registry.Resource.ENCHANTMENTS,
2022-02-04 22:28:05 +01:00
(namespace, properties) -> new EnchantmentImpl(Registry.enchantment(namespace, properties)));
static Enchantment get(@NotNull String namespace) {
2021-07-30 15:29:05 +02:00
return CONTAINER.get(namespace);
}
static Enchantment getSafe(@NotNull String namespace) {
2021-07-30 15:29:05 +02:00
return CONTAINER.getSafe(namespace);
}
static Enchantment getId(int id) {
2021-07-30 15:29:05 +02:00
return CONTAINER.getId(id);
}
static Collection<Enchantment> values() {
2021-07-30 15:29:05 +02:00
return CONTAINER.values();
}
@Override
public String toString() {
return name();
}
2021-07-28 13:27:49 +02:00
}