crwdns129653:0crwdne129653:0

crwdns129655:0crwdne129655:0

  • crwdns129657:0:javadoc:crwdnd129657:0:javadoc:crwdne129657:0

  • crwdns129659:0:doc:crwdnd129659:0:javadoc:crwdne129659:0

  • crwdns129661:0:javadoc:crwdne129661:0

crwdns129663:0crwdne129663:0

crwdns129665:0crwdne129665:0

crwdns129667:0crwdne129667:0

  • crwdns129669:0crwdne129669:0

  • crwdns129671:0crwdne129671:0

  • crwdns129673:0:javadoc:crwdne129673:0

crwdns129675:0:javadoc:crwdne129675:0

Tip

crwdns129677:0crwdne129677:0

crwdns129679:0crwdne129679:0

crwdns129681:0:javadoc:crwdne129681:0

  • crwdns129683:0crwdne129683:0

  • crwdns129685:0crwdne129685:0

Tip

crwdns129687:0:ref:crwdne129687:0

crwdns129689:0crwdne129689: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());
}

crwdns129691:0:javadoc:crwdnd129691:0:javadoc:crwdne129691:0

crwdns129693:0crwdne129693:0

crwdns129695:0crwdne129695:0

crwdns129697:0crwdne129697:0

crwdns129699:0crwdne129699:0

crwdns129701:0:javadoc:crwdne129701:0

crwdns129703:0crwdne129703:0

crwdns129705:0crwdne129705:0

crwdns129707:0crwdne129707: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));
    }
}

crwdns129709:0crwdne129709:0

crwdns129711:0crwdne129711:0

  • crwdns129713:0crwdne129713:0

  • crwdns129715:0:javadoc:crwdne129715:0

crwdns129717:0crwdne129717:0

crwdns129719:0:ref:crwdne129719:0

crwdns129721:0crwdne129721:0

Note

crwdns129723:0crwdne129723:0

crwdns129725:0crwdne129725:0

crwdns129727:0:javadoc:crwdne129727:0

crwdns129729:0crwdne129729:0

crwdns129731:0crwdne129731:0