Interface DataSection<P>
- Type Parameters:
P- platform player type (org.bukkit.entity.PlayerorServerPlayer)
public interface DataSection<P>
Extra player data that SepareWorldItems saves and restores per group, next to the built-in
inventory/XP/health... Use it to keep your plugin's or mod's own state separated per world group
(mana, skills, backpacks, currencies...).
public final class ManaSection implements DataSection<ServerPlayer> {
public String id() { return "mymod:mana"; }
public Class<ServerPlayer> playerType() { return ServerPlayer.class; }
public void save(ServerPlayer p, DataNode out) { out.set("value", MyMod.getMana(p)); }
public void load(ServerPlayer p, DataNode in) { MyMod.setMana(p, in.getDouble("value", 0)); }
public void clear(ServerPlayer p) { MyMod.setMana(p, 0); }
}
SepareWorldItems.get().sections().register(new ManaSection());
Methods run on the server thread. Each section gets its own node, stored under
custom.<id> in the player's record, so ids never clash with built-in keys.
Server owners can toggle a section per group with settings.options.saves.<id> in the config.
-
Method Details
-
id
- Returns:
- unique id, namespaced with your plugin/mod id, e.g.
"auraskills:mana". Allowed characters:a-z 0-9 _ - :
-
playerType
-
enabledByDefault
default boolean enabledByDefault()- Returns:
- whether the section is saved when the config has no toggle for it
-
save
-
load
-
clear
Resets the player's state before the destination data is loaded.
-