crwdns118753:0crwdne118753:0

crwdns118755:0crwdne118755:0

  • crwdns118757:0:javadoc:crwdnd118757:0:javadoc:crwdne118757:0

  • crwdns118759:0:doc:crwdnd118759:0:javadoc:crwdne118759:0

  • crwdns118761:0:javadoc:crwdne118761:0

crwdns118763:0crwdne118763:0

crwdns118765:0crwdne118765:0

crwdns118767:0crwdne118767:0

  • crwdns118769:0crwdne118769:0

  • crwdns118771:0crwdne118771:0

  • crwdns118773:0:javadoc:crwdne118773:0

crwdns118775:0:javadoc:crwdne118775:0

Tip

crwdns118777:0crwdne118777:0

crwdns118779:0crwdne118779:0

crwdns118781:0:javadoc:crwdne118781:0

  • crwdns118783:0crwdne118783:0

  • crwdns118785:0crwdne118785:0

Tip

crwdns118787:0:ref:crwdne118787:0

crwdns118789:0crwdne118789: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;

private String name = "Spongie";

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

crwdns118791:0:javadoc:crwdnd118791:0:javadoc:crwdne118791:0

crwdns118793:0crwdne118793:0

crwdns118795:0crwdne118795:0

crwdns118797:0crwdne118797:0

crwdns118799:0:javadoc:crwdne118799:0

crwdns118801:0crwdne118801:0

crwdns118803:0crwdne118803:0

crwdns118805:0crwdne118805:0

import org.spongepowered.api.data.persistence.DataContentUpdater
import 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));
    }
}

crwdns118807:0crwdne118807:0

crwdns118809:0crwdne118809:0

  • crwdns118811:0crwdne118811:0

  • crwdns118813:0:javadoc:crwdne118813:0

crwdns118815:0crwdne118815:0

crwdns118817:0:ref:crwdne118817:0

crwdns118819:0crwdne118819:0

Note

crwdns118821:0crwdne118821:0

crwdns118823:0crwdne118823:0

crwdns118825:0:javadoc:crwdne118825:0

crwdns118827:0crwdne118827:0

crwdns118829:0crwdne118829:0