tutorial:persistent_states
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:persistent_states [2022/12/22 02:54] – Fixed bug in code, and added imports jmanc3 | tutorial:persistent_states [2023/04/10 11:42] – Removed more markDirty() calls lunathelemon | ||
---|---|---|---|
Line 114: | Line 114: | ||
ServerState:: | ServerState:: | ||
" | " | ||
- | + | | |
- | serverState.markDirty(); | + | |
- | | + | |
return serverState; | return serverState; | ||
} | } | ||
Line 122: | Line 120: | ||
</ | </ | ||
- | One thing to note is the line '' | + | In order to signal that the server should save the state of the object at the next write cycle you must call '' |
+ | Failing to do this will mean the server may not save the nbt data to disk so it cannot be guaranteed that when the nbt data is retrieved again after the server has restarted it will be the same. | ||
<code java> | <code java> | ||
ServerState serverState = ServerState.getServerState(server); | ServerState serverState = ServerState.getServerState(server); | ||
System.out.println(" | System.out.println(" | ||
+ | serverState.markDirty(); | ||
</ | </ | ||
Line 238: | Line 238: | ||
ServerState:: | ServerState:: | ||
" | " | ||
- | + | | |
- | serverState.markDirty(); | + | |
return serverState; | return serverState; | ||
} | } | ||
Line 404: | Line 402: | ||
ServerState:: | ServerState:: | ||
" | " | ||
- | |||
- | serverState.markDirty(); | ||
return serverState; | return serverState; |
tutorial/persistent_states.txt · Last modified: 2024/04/25 14:06 by mayaqq