Inline registry loading

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-01-17 23:40:46 +01:00
parent 615476fe53
commit eb3c894971
4 changed files with 4 additions and 16 deletions

View File

@ -8,10 +8,7 @@ import java.util.Collection;
record ParticleImpl(NamespaceID namespace, int id) implements Particle {
private static final Registry.Container<Particle> CONTAINER = Registry.createContainer(Registry.Resource.PARTICLES,
(namespace, object) -> {
final int id = ((Number) object.get("id")).intValue();
return new ParticleImpl(NamespaceID.from(namespace), id);
});
(namespace, object) -> new ParticleImpl(NamespaceID.from(namespace), ((Number) object.get("id")).intValue()));
static Particle get(@NotNull String namespace) {
return CONTAINER.get(namespace);

View File

@ -8,10 +8,7 @@ import java.util.Collection;
record PotionTypeImpl(NamespaceID namespace, int id) implements PotionType {
private static final Registry.Container<PotionType> CONTAINER = Registry.createContainer(Registry.Resource.POTION_TYPES,
(namespace, object) -> {
final int id = ((Number) object.get("id")).intValue();
return new PotionTypeImpl(NamespaceID.from(namespace), id);
});
(namespace, object) -> new PotionTypeImpl(NamespaceID.from(namespace), ((Number) object.get("id")).intValue()));
static PotionType get(@NotNull String namespace) {
return CONTAINER.get(namespace);

View File

@ -8,10 +8,7 @@ import java.util.Collection;
record SoundEventImpl(NamespaceID namespace, int id) implements SoundEvent {
private static final Registry.Container<SoundEvent> CONTAINER = Registry.createContainer(Registry.Resource.SOUNDS,
(namespace, object) -> {
final int id = ((Number) object.get("id")).intValue();
return new SoundEventImpl(NamespaceID.from(namespace), id);
});
(namespace, object) -> new SoundEventImpl(NamespaceID.from(namespace), ((Number) object.get("id")).intValue()));
static SoundEvent get(@NotNull String namespace) {
return CONTAINER.get(namespace);

View File

@ -8,10 +8,7 @@ import java.util.Collection;
record StatisticTypeImpl(NamespaceID namespace, int id) implements StatisticType {
private static final Registry.Container<StatisticType> CONTAINER = Registry.createContainer(Registry.Resource.STATISTICS,
(namespace, object) -> {
final int id = ((Number) object.get("id")).intValue();
return new StatisticTypeImpl(NamespaceID.from(namespace), id);
});
(namespace, object) -> new StatisticTypeImpl(NamespaceID.from(namespace), ((Number) object.get("id")).intValue()));
static StatisticType get(@NotNull String namespace) {
return CONTAINER.get(namespace);