crwdns148891:0crwdne148891:0

crwdns148893:0crwdne148893:0

  • crwdns148895:0:javadoc:crwdnd148895:0:javadoc:crwdne148895:0

  • crwdns148897:0:doc:crwdnd148897:0:javadoc:crwdne148897:0

  • crwdns148899:0:javadoc:crwdne148899:0

crwdns148901:0crwdne148901:0

crwdns148903:0crwdne148903:0

crwdns148905:0crwdne148905:0

  • crwdns148907:0crwdne148907:0

  • crwdns148909:0crwdne148909:0

  • crwdns148911:0:javadoc:crwdne148911:0

crwdns148913:0:javadoc:crwdne148913:0

Tip

crwdns148915:0crwdne148915:0

crwdns148917:0crwdne148917:0

crwdns148919:0:javadoc:crwdne148919:0

  • crwdns148921:0crwdne148921:0

  • crwdns148923:0crwdne148923:0

Tip

crwdns148925:0:ref:crwdne148925:0

crwdns148927:0crwdne148927:0

import org.spongepowered.api.data.DataContainer;
import org.spongepowered.api.data.DataQuery;
import org.spongepowered.api.data.Queries;
import org.spongepowered.api.data.MemoryDataContainer;

String name = "Spongie";

@Override
public DataContainer toContainer() {
    return new MemoryDataContainer()
            .set(DataQuery.of("Name"), this.name)
            .set(Queries.CONTENT_VERSION, getContentVersion());
}

crwdns148929:0:javadoc:crwdnd148929:0:javadoc:crwdne148929:0

crwdns148931:0crwdne148931:0

crwdns148933:0crwdne148933:0

crwdns148935:0crwdne148935:0

crwdns148937:0crwdne148937:0

crwdns148939:0:javadoc:crwdne148939:0

crwdns148941:0crwdne148941:0

crwdns148943:0crwdne148943:0

crwdns148945:0crwdne148945:0

org.spongepowered.api.data.persistence.DataContentUpdater
org.spongepowered.api.text.Text

public class NameUpdater implements DataContentUpdater {

    @Override
    public int getInputVersion() {
        return 1;
    }

    @Override
    public int getOutputVersion() {
        return 2;
    }

    @Override
    public DataView update(DataView content) {
        String name = content.getString(DataQuery.of("Name")).get();

        // For example, version 2 uses a text for the name
        return content.set(DataQuery.of("Name"), Text.of(name));
    }
}

crwdns148947:0crwdne148947:0

crwdns148949:0crwdne148949:0

  • crwdns148951:0crwdne148951:0

  • crwdns148953:0:javadoc:crwdne148953:0

crwdns148955:0crwdne148955:0

crwdns148957:0:ref:crwdne148957:0

crwdns148959:0crwdne148959:0

Note

crwdns148961:0crwdne148961:0

crwdns148963:0crwdne148963:0

crwdns148965:0:javadoc:crwdne148965:0

crwdns148967:0crwdne148967:0

crwdns148969:0crwdne148969:0