dev.polymodloader.api.data
This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.
| Type | Kind | Description |
|---|---|---|
DataMigration | functional interface | Upgrades saved data written by an older version of a mod. |
DataTree | class | Typed key-value data that Poly Mod Loader saves with the world: block entity data and world storage use it. |
DataMigration
functional interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public interface DataMigration
Upgrades saved data written by an older version of a mod. Called once when data saved with an older version is loaded, before anything reads it; afterwards the data counts as current.
migrate(DataTree, int)
void migrate(DataTree data, int fromVersion)
Since 0.1.0-alpha.4 or earlier
Upgrades data from fromVersion to the current version.
| Parameter | Type | Description |
|---|---|---|
data | DataTree | the saved data, changed in place |
fromVersion | int | the version it was saved with (0 for data saved before versions were used) |
DataTree
class · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier
public final class DataTree
Typed key-value data that Poly Mod Loader saves with the world: block entity data and world storage use it. Values are int, long, double, boolean, String, byte[], or nested trees. Reading a missing key or a key of another type returns the fallback.
Thread: not thread-safe; use it on the thread that owns the world.
create()
public static DataTree create()
Since 0.1.0-alpha.4 or earlier
An empty tree.
Returns DataTree
getInt(String, int)
public int getInt(String key, int fallback)
Since 0.1.0-alpha.4 or earlier
The integer under key, or fallback if there is none.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
fallback | int | — |
Returns int
putInt(String, int)
public DataTree putInt(String key, int value)
Since 0.1.0-alpha.4 or earlier
Stores an integer under key; returns this tree.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
value | int | — |
Returns DataTree
getLong(String, long)
public long getLong(String key, long fallback)
Since 0.1.0-alpha.4 or earlier
The long under key, or fallback if there is none.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
fallback | long | — |
Returns long
putLong(String, long)
public DataTree putLong(String key, long value)
Since 0.1.0-alpha.4 or earlier
Stores a long under key; returns this tree.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
value | long | — |
Returns DataTree
getDouble(String, double)
public double getDouble(String key, double fallback)
Since 0.1.0-alpha.4 or earlier
The double under key, or fallback if there is none.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
fallback | double | — |
Returns double
putDouble(String, double)
public DataTree putDouble(String key, double value)
Since 0.1.0-alpha.4 or earlier
Stores a double under key; returns this tree.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
value | double | — |
Returns DataTree
getBoolean(String, boolean)
public boolean getBoolean(String key, boolean fallback)
Since 0.1.0-alpha.4 or earlier
The boolean under key, or fallback if there is none.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
fallback | boolean | — |
Returns boolean
putBoolean(String, boolean)
public DataTree putBoolean(String key, boolean value)
Since 0.1.0-alpha.4 or earlier
Stores a boolean under key; returns this tree.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
value | boolean | — |
Returns DataTree
getString(String, String)
public String getString(String key, String fallback)
Since 0.1.0-alpha.4 or earlier
The string under key, or fallback if there is none.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
fallback | String | — |
Returns String
putString(String, String)
public DataTree putString(String key, String value)
Since 0.1.0-alpha.4 or earlier
Stores a string under key; returns this tree.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
value | String | — |
Returns DataTree
getBytes(String)
public Optional<byte[]> getBytes(String key)
Since 0.1.0-alpha.4 or earlier
A copy of the stored bytes.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
Returns Optional<byte[]>
putBytes(String, byte[])
public DataTree putBytes(String key, byte[] value)
Since 0.1.0-alpha.4 or earlier
Stores a copy of value under key; returns this tree.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
value | byte[] | — |
Returns DataTree
child(String)
public DataTree child(String key)
Since 0.1.0-alpha.4 or earlier
The child tree under key, creating it (and replacing a non-tree value) if needed.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
Returns DataTree
findChild(String)
public Optional<DataTree> findChild(String key)
Since 0.1.0-alpha.4 or earlier
The child tree under key, without creating it.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
Returns Optional<DataTree>
has(String)
public boolean has(String key)
Since 0.1.0-alpha.4 or earlier
Whether any value is stored under key.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
Returns boolean
remove(String)
public void remove(String key)
Since 0.1.0-alpha.4 or earlier
Removes the value under key, if any.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
keys()
public Set<String> keys()
Since 0.1.0-alpha.4 or earlier
Keys in insertion order.
Returns Set<String>
raw(String)
public Optional<Object> raw(String key)
Since 0.1.0-alpha.4 or earlier
The raw value under key: Integer, Long, Double, Boolean, String, byte[] (shared, do not modify), or DataTree; empty when absent.
| Parameter | Type | Description |
|---|---|---|
key | String | — |
Returns Optional<Object>
clear()
public void clear()
Since 0.1.0-alpha.4 or earlier
Removes every entry.
copy()
public DataTree copy()
Since 0.1.0-alpha.4 or earlier
A deep copy.
Returns DataTree