Speed/Efficiency PersistentDataContainer vs Class in HashMap

Which will be better?


  • Total voters
    3
  • Poll closed .

_Iuri

New member
Jan 16, 2022
18
3
3
The cuestion is simple, what is better?

Supposing we want to store useful data (Location, Homes, Money, Titles) of a player and request it when PlayerMoveEvent is called. Please considerate an high amount of player for each case.

Case A: Create a class what will store the custom player data, create a new instance of the class for each player and store it on a HashMap public variable and get the data from it when we need it (in the PlayerMoveEvent).

Case B: Store each data as individual keys in the PersistentDataContainer of each player and request it when we need it.

Case C: Create a new class from PersistentDataType, store it in the PersistentDataContainer of each player and request it when we need it.

Case D (half & half): Almost the same that A case but we add a reference pointer of the instance class with the data on the player's PersistentDataContainer.
 
Last edited:

electronicboy

Administrator
Staff member
Dec 11, 2021
80
6
17
8
PDC requires that data is transformed between get/set operations, so that's going to have some overheads, fairly trivial for most primative/built in types, however, but, storing data in a POJO at runtime is generally best if you want performance, as for where you persist that data, that's down to needs, PDC for just storing data has some pros in terms of it being stored with the player, but, is not easy to share/process externally, which, if that's a care, once again, depends on needs