Skip to content

Commit

Permalink
registry: Pass specific catalog type from event (#3152)
Browse files Browse the repository at this point in the history
This allows registering implementations of types, not just
instances of concrete types
  • Loading branch information
zml2008 committed Sep 3, 2020
1 parent 0a60c31 commit 5eb67a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public TypeToken<C> getGenericType() {
public C register(C catalog) throws DuplicateRegistrationException {
Preconditions.checkNotNull(catalog);

return ((SpongeCatalogRegistry) Sponge.getRegistry().getCatalogRegistry()).registerCatalog(catalog);
return ((SpongeCatalogRegistry) Sponge.getRegistry().getCatalogRegistry()).registerCatalog(this.token, catalog);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,10 @@ private <T extends CatalogType, U> SpongeCatalogRegistry registerMappedRegistry(
return registry;
}

public <C extends CatalogType> C registerCatalog(final C catalogType) {
public <C extends CatalogType> C registerCatalog(final TypeToken<C> catalog, final C catalogType) {
Objects.requireNonNull(catalogType);

final Registry<C> registry = (Registry<C>) this.registriesByType.get(catalogType.getClass());
final Registry<C> registry = (Registry<C>) this.registriesByType.get(catalog.getRawType());
if (registry == null) {
throw new UnknownTypeException(String.format("Catalog '%s' with id '%s' has no registry registered!", catalogType.getClass(), catalogType.getKey()));
}
Expand Down

0 comments on commit 5eb67a9

Please sign in to comment.