Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add short-hand registry getters #2372

Merged
merged 3 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -74,6 +75,10 @@ public final class AdvancementTypes {
private AdvancementTypes() {
}

public static Registry<AdvancementType> registry() {
return Sponge.game().registry(RegistryTypes.ADVANCEMENT_TYPE);
}

private static DefaultedRegistryReference<AdvancementType> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.ADVANCEMENT_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -134,6 +135,10 @@ public final class Triggers {
private Triggers() {
}

public static Registry<Trigger<?>> registry() {
return Sponge.game().registry(RegistryTypes.TRIGGER);
}

private static DefaultedRegistryReference<Trigger<?>> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.TRIGGER, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -73,6 +74,10 @@ public class ResolveOperations {
private ResolveOperations() {
}

public static Registry<ResolveOperation> registry() {
return Sponge.game().registry(RegistryTypes.RESOLVE_OPERATION);
}

private static DefaultedRegistryReference<ResolveOperation> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.RESOLVE_OPERATION, location).asDefaultedReference(Sponge::game);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/spongepowered/api/block/BlockTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -1570,6 +1571,10 @@ public final class BlockTypes {
private BlockTypes() {
}

public static Registry<BlockType> registry() {
return Sponge.game().registry(RegistryTypes.BLOCK_TYPE);
}

private static DefaultedRegistryReference<BlockType> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.BLOCK_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -110,6 +111,10 @@ public final class BlockEntityTypes {
private BlockEntityTypes() {
}

public static Registry<BlockEntityType> registry() {
return Sponge.game().registry(RegistryTypes.BLOCK_ENTITY_TYPE);
}

private static DefaultedRegistryReference<BlockEntityType> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.BLOCK_ENTITY_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -83,6 +84,10 @@ public final class Operations {
private Operations() {
}

public static Registry<Operation> registry() {
return Sponge.game().registry(RegistryTypes.OPERATION);
}

private static DefaultedRegistryReference<Operation> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.OPERATION, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.parameter.managed.ValueParser;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -92,6 +93,10 @@ public final class ClientCompletionTypes {
private ClientCompletionTypes() {
}

public static Registry<ClientCompletionType> registry() {
return Sponge.game().registry(RegistryTypes.CLIENT_COMPLETION_TYPE);
}

private static DefaultedRegistryReference<ClientCompletionType> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.CLIENT_COMPLETION_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryTypes;

Expand Down Expand Up @@ -86,6 +87,10 @@ public final class Operators {
private Operators() {
}

public static Registry<Operator> registry() {
return Sponge.game().registry(RegistryTypes.OPERATOR);
}

private static <T extends Operator> DefaultedRegistryReference<T> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.OPERATOR, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.command.parameter.managed.ValueParameter;
import org.spongepowered.api.command.parameter.managed.operator.Operator;
import org.spongepowered.api.command.parameter.managed.operator.Operators;
import org.spongepowered.api.data.persistence.DataContainer;
Expand All @@ -39,6 +40,7 @@
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.profile.GameProfile;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -473,6 +475,10 @@ public final class ResourceKeyedValueParameters {
private ResourceKeyedValueParameters() {
}

public static Registry<ValueParameter<?>> registry() {
return Sponge.game().registry(RegistryTypes.REGISTRY_KEYED_VALUE_PARAMETER);
}

private static <T> DefaultedRegistryReference<ResourceKeyedValueParameter<T>> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.REGISTRY_KEYED_VALUE_PARAMETER, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.item.recipe.Recipe;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryTypes;
import org.spongepowered.api.world.biome.Biome;
Expand Down Expand Up @@ -88,6 +89,10 @@ public final class CommandCompletionProviders {
private CommandCompletionProviders() {
}

public static Registry<CommandCompletionProvider> registry() {
return Sponge.game().registry(RegistryTypes.COMMAND_COMPLETION_PROVIDER);
}

private static DefaultedRegistryReference<CommandCompletionProvider> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.COMMAND_COMPLETION_PROVIDER, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -138,6 +139,10 @@ public final class CommandTreeNodeTypes {
private CommandTreeNodeTypes() {
}

public static Registry<CommandTreeNodeType<?>> registry() {
return Sponge.game().registry(RegistryTypes.COMMAND_TREE_NODE_TYPE);
}

private static <T extends CommandTreeNode<T>> DefaultedRegistryReference<CommandTreeNodeType<T>> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.COMMAND_TREE_NODE_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.spongepowered.api.Sponge;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -72,6 +73,10 @@ public final class SelectorSortAlgorithms {
private SelectorSortAlgorithms() {
}

public static Registry<SelectorSortAlgorithm> registry() {
return Sponge.game().registry(RegistryTypes.SELECTOR_SORT_ALGORITHM);
}

private static DefaultedRegistryReference<SelectorSortAlgorithm> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.SELECTOR_SORT_ALGORITHM, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -85,6 +86,10 @@ public final class SelectorTypes {
private SelectorTypes() {
}

public static Registry<SelectorType> registry() {
return Sponge.game().registry(RegistryTypes.SELECTOR_TYPE);
}

private static DefaultedRegistryReference<SelectorType> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.SELECTOR_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -56,6 +57,10 @@ public final class DataFormats {
private DataFormats() {
}

public static Registry<DataFormat> registry() {
return Sponge.game().registry(RegistryTypes.DATA_FORMAT);
}

private static DefaultedRegistryReference<StringDataFormat> stringKey(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.DATA_FORMAT, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -59,6 +60,10 @@ public final class ArmorMaterials {
private ArmorMaterials() {
}

public static Registry<ArmorMaterial> registry() {
return Sponge.game().registry(RegistryTypes.ARMOR_MATERIAL);
}

private static DefaultedRegistryReference<ArmorMaterial> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.ARMOR_MATERIAL, location).asDefaultedReference(Sponge::game);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/spongepowered/api/data/type/ArtTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -96,6 +97,10 @@ public final class ArtTypes {
private ArtTypes() {
}

public static Registry<ArtType> registry() {
return Sponge.game().registry(RegistryTypes.ART_TYPE);
}

private static DefaultedRegistryReference<ArtType> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.ART_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -56,6 +57,10 @@ public final class AttachmentSurfaces {
private AttachmentSurfaces() {
}

public static Registry<AttachmentSurface> registry() {
return Sponge.game().registry(RegistryTypes.ATTACHMENT_SURFACE);
}

private static DefaultedRegistryReference<AttachmentSurface> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.ATTACHMENT_SURFACE, location).asDefaultedReference(Sponge::game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -130,6 +131,10 @@ public final class BannerPatternShapes {
private BannerPatternShapes() {
}

public static Registry<BannerPatternShape> registry() {
return Sponge.game().registry(RegistryTypes.BANNER_PATTERN_SHAPE);
}

private static DefaultedRegistryReference<BannerPatternShape> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.BANNER_PATTERN_SHAPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/spongepowered/api/data/type/BoatTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -62,6 +63,10 @@ public final class BoatTypes {
private BoatTypes() {
}

public static Registry<BoatType> registry() {
return Sponge.game().registry(RegistryTypes.BOAT_TYPE);
}

private static DefaultedRegistryReference<BoatType> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.BOAT_TYPE, location).asDefaultedReference(Sponge::game);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/spongepowered/api/data/type/BodyParts.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.registry.DefaultedRegistryReference;
import org.spongepowered.api.registry.Registry;
import org.spongepowered.api.registry.RegistryKey;
import org.spongepowered.api.registry.RegistryScope;
import org.spongepowered.api.registry.RegistryScopes;
Expand Down Expand Up @@ -62,6 +63,10 @@ public final class BodyParts {
private BodyParts() {
}

public static Registry<BodyPart> registry() {
return Sponge.game().registry(RegistryTypes.BODY_PART);
}

private static DefaultedRegistryReference<BodyPart> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.BODY_PART, location).asDefaultedReference(Sponge::game);
}
Expand Down
Loading