This adds a new system to store data within a GUI or Scene. The previous system is now deprecated.
Data is now managed using the Storage class, which employs ValueHolders to represent individual data objects.
Code Examples
Storage storage = gui.getStorage();
// register data with default value
storage.register("player-name", String.class, "Steve");
// register data without default value
storage.register("player-age", PlayerData.class);
storage.register("player-data", Double.class);
// unregister data
storage.unregister("player-age");
// get data
String playerName = storage.get("player-name").asString();
PlayerData playerData = storage.get("player-data").as(PlayerData.class);
// the get method returns an empty dummy holder if the id is not registered
storage.get("non-existent-id").isRegistered(); // false
// mapping, ...
storage.get("player-data")
.holding(PlayerData.class)
.map(String.class, PlayerData::getGuild().getName()) // mapped dummy holder
.ifPresent(System.out::println);
Description
This adds a new system to store data within a
GUI
orScene
. The previous system is now deprecated. Data is now managed using theStorage
class, which employsValueHolders
to represent individual data objects.Code Examples