Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Add Custom Data recipe #17

Merged
merged 1 commit into from
Jun 13, 2017

Conversation

ZephireNZ
Copy link
Contributor

  • Simple Data
  • Compound Data
  • DataBuilder
  • DataContentUpdater
  • DataTranslator
  • Keys

Built as a complete example for SpongeDocs#532

Should cover everything that #16 covers and more.

- Simple Data
- Compound Data
- DataBuilder
- DataContentUpdater
- DataTranslator
- Keys
dm.register(FriendsDataImpl.class, ImmutableFriendsDataImpl.class, new FriendsDataBuilder());

// Home
dm.registerBuilder(Home.class, new HomeBuilder());
Copy link
Member

Choose a reason for hiding this comment

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

Should note that Home as a DataSerializable should be registered before any data manipulator that relies on it can be registered. The reasoning is that in SpongePowered/SpongeAPI#1198, the system will need to know of all of the serializable objects and translatable objects before it can generate the appropriate serialization strategies for custom data.

Choose a reason for hiding this comment

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

Is there any error or exception if they arn't? having the check would help developers catch this mistake in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd imagine that there'll be logic along the lines of:

for value in values:
    if value.obj is dataserialiable:
        toContainer
    if value.obj is primitive, map, list
        set directly
    if value.obj has registered translator:
        get translator, translate
    throw RuntimeException of some form

Copy link
Member

Choose a reason for hiding this comment

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

The issue is more about generating he deserialization methods with class generation.

@ZephireNZ
Copy link
Contributor Author

I'll be making another PR for data 2.0 for docs and cookbook so that we
have records for both, so I'll make sure to include that. But right now it
doesn't matter, correct?

On Tue., 8 Nov. 2016, 6:30 am Gabriel Harris-Rouquette, <
notifications@github.com> wrote:

@gabizou commented on this pull request.

In
Plugin/MyHomes/src/main/java/org/spongepowered/cookbook/myhomes/MyHomes.java
#17 (review)
:

+import org.spongepowered.api.text.Text;
+import org.spongepowered.api.text.chat.ChatTypes;
+import org.spongepowered.api.text.format.TextStyles;
+
+@plugin(id = "myhomes")
+public class MyHomes {
+

  • @Listener
  • public void onGameInitialization(GameInitializationEvent event) {
  •    DataManager dm = Sponge.getDataManager();
    
  •    // FriendsData
    
  •    dm.register(FriendsDataImpl.class, ImmutableFriendsDataImpl.class, new FriendsDataBuilder());
    
  •    // Home
    
  •    dm.registerBuilder(Home.class, new HomeBuilder());
    

Should note that Home as a DataSerializable should be registered before
any data manipulator that relies on it can be registered. The reasoning is
that in SpongePowered/SpongeAPI#1198
SpongePowered/SpongeAPI#1198, the system will
need to know of all of the serializable objects and translatable objects
before it can generate the appropriate serialization strategies for custom
data.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#17 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABkX0NCagVGGyxxAy3hmDuZ-IeX22d3Sks5q72ApgaJpZM4KrG0p
.

@ZephireNZ
Copy link
Contributor Author

Hey, could this be merged? At the moment there's a dead link in the Docs as I was expecting for this to be pulled.

Let me know if there's something that needs to be changed.

@Tzky
Copy link

Tzky commented Feb 20, 2017

Bump. See Zephires comment above mine. The link on the docs is (still) broken.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants