Minestom/src/main/java/net/minestom/server/sound/SoundEventImpl.java

34 lines
976 B
Java
Raw Normal View History

2021-07-28 14:29:28 +02:00
package net.minestom.server.sound;
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 SoundEventImpl(NamespaceID namespace, int id) implements SoundEvent {
private static final Registry.Container<SoundEvent> CONTAINER = Registry.createStaticContainer(Registry.Resource.SOUNDS,
2022-02-04 22:28:05 +01:00
(namespace, properties) -> new SoundEventImpl(NamespaceID.from(namespace), properties.getInt("id")));
static SoundEvent get(@NotNull String namespace) {
2021-07-30 15:29:05 +02:00
return CONTAINER.get(namespace);
}
static SoundEvent getSafe(@NotNull String namespace) {
2021-07-30 15:29:05 +02:00
return CONTAINER.getSafe(namespace);
}
static SoundEvent getId(int id) {
2021-07-30 15:29:05 +02:00
return CONTAINER.getId(id);
}
static Collection<SoundEvent> values() {
2021-07-30 15:29:05 +02:00
return CONTAINER.values();
}
2021-07-28 14:29:28 +02:00
@Override
public String toString() {
return name();
}
2021-07-28 14:29:28 +02:00
}