#895: Load GameEvent and MusicInstrument from registry

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
Bukkit/Spigot
2023-09-02 12:55:16 +10:00
parent 641a55cbc5
commit 32643feee7
3 changed files with 40 additions and 64 deletions

View File

@@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.function.Predicate;
import org.bukkit.advancement.Advancement;
import org.bukkit.attribute.Attribute;
@@ -116,6 +117,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @see EntityType
*/
Registry<EntityType> ENTITY_TYPE = new SimpleRegistry<>(EntityType.class, (entity) -> entity != EntityType.UNKNOWN);
/**
* Server instruments.
*
* @see MusicInstrument
*/
Registry<MusicInstrument> INSTRUMENT = Objects.requireNonNull(Bukkit.getRegistry(MusicInstrument.class), "No registry present for MusicInstrument. This is a bug.");
/**
* Default server loot tables.
*
@@ -214,21 +221,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*
* @see GameEvent
*/
Registry<GameEvent> GAME_EVENT = new Registry<GameEvent>() {
@NotNull
@Override
public Iterator iterator() {
return GameEvent.values().iterator();
}
@Nullable
@Override
public GameEvent get(@NotNull NamespacedKey key) {
return GameEvent.getByKey(key);
}
};
Registry<GameEvent> GAME_EVENT = Objects.requireNonNull(Bukkit.getRegistry(GameEvent.class), "No registry present for GameEvent. This is a bug.");
/**
* Get the object by its key.
*