Skip to content

Make catalog type builders consistent.#1870

Merged
Zidane merged 2 commits into
SpongePowered:stable-7from
Cybermaxke:consistent-catalog-builders
Sep 28, 2018
Merged

Make catalog type builders consistent.#1870
Zidane merged 2 commits into
SpongePowered:stable-7from
Cybermaxke:consistent-catalog-builders

Conversation

@Cybermaxke
Copy link
Copy Markdown
Contributor

@Cybermaxke Cybermaxke commented Jul 21, 2018

API | Common

Adds a common builder interface for catalog types to ensure consistency.All original build methods are deprecated and will be removed in bleeding.

Already makes FurnaceRecipe a catalog type. For stable, if no id is set, an auto generated one will be used instead.

Please let me know if I missed any catalog type builders. And is it worth to also target stable?

Impl will follow later.

Comment thread src/main/java/org/spongepowered/api/util/CatalogBuilder.java Outdated
Comment thread src/main/java/org/spongepowered/api/util/CatalogBuilder.java
public interface CatalogBuilder<C extends CatalogType, B extends ResettableBuilder<C, B>> extends ResettableBuilder<C, B> {

/**
* Sets the name of the {@link CatalogType}. Defaults to {@link #id(String)}.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not default to the id. Internally you can do it but i would only do it for backwards compatibility.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id passed in here is without the namespace/plugin id, so if you provide my_id with id(String), you would end up with a catalog type having my_plugin_id:my_id as id and my_id as name. If it's really desired to have a readable name, then I will enforce the name.

* @param translation The name translation
* @return This builder for chaining
*/
B name(Translation translation);
Copy link
Copy Markdown
Member

@ST-DDT ST-DDT Jul 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure on the name here. Because on the server the name is something static usually english. However the translation is something dynamic. Maybe rename it to translation and explicitly state that the english content will be used for the name as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some CatalogTypes are Translatable, this would also apply this translation, and the plain version would be used as getName value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats why translation might be an alternative.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translarion extends Text, iirc, why just not Text?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translation doesn't extend Text, but TranslatableText does.

*
* @return The built catalog type
*/
C build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add some throws declarations.
ISE: Mandatory fields not set or no plugin container on the cause stack or run during the wrong game phase.


/**
* Builds the {@link CatalogType} of type {@link C}.
* <p>The last {@link PluginContainer} in the cause stack will be used to
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing empty line before the <p> and missing closing tag.

Copy link
Copy Markdown
Member

@gabizou gabizou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I like the extension and this is backwards compatible! Good changes all around.

…eady a catalog type.

Don't allow duplicate catalog types.

A few documentation related changes.

Strip the plugin id when the old manipulatorId method is used.
@Cybermaxke Cybermaxke force-pushed the consistent-catalog-builders branch from 4792ddb to d40b52e Compare August 27, 2018 20:20
@ryantheleach ryantheleach added the api: 7 (u) version: 1.12 label Aug 29, 2018
@gabizou gabizou self-assigned this Aug 30, 2018
@Zidane Zidane merged commit 4b0b402 into SpongePowered:stable-7 Sep 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants