2021-07-28 13:27:49 +02:00
|
|
|
package net.minestom.server.item;
|
|
|
|
|
|
|
|
import net.minestom.server.registry.Registry;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
2021-07-30 15:08:06 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
|
2021-12-19 20:17:44 +01:00
|
|
|
record EnchantmentImpl(Registry.EnchantmentEntry registry) implements Enchantment {
|
2022-01-14 10:45:44 +01:00
|
|
|
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)));
|
2021-07-30 15:08:06 +02:00
|
|
|
|
|
|
|
static Enchantment get(@NotNull String namespace) {
|
2021-07-30 15:29:05 +02:00
|
|
|
return CONTAINER.get(namespace);
|
2021-07-30 15:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static Enchantment getSafe(@NotNull String namespace) {
|
2021-07-30 15:29:05 +02:00
|
|
|
return CONTAINER.getSafe(namespace);
|
2021-07-30 15:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static Enchantment getId(int id) {
|
2021-07-30 15:29:05 +02:00
|
|
|
return CONTAINER.getId(id);
|
2021-07-30 15:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static Collection<Enchantment> values() {
|
2021-07-30 15:29:05 +02:00
|
|
|
return CONTAINER.values();
|
2021-07-30 15:08:06 +02:00
|
|
|
}
|
|
|
|
|
2021-08-13 21:15:43 +02:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return name();
|
|
|
|
}
|
2021-07-28 13:27:49 +02:00
|
|
|
}
|