🟢Single file

Every single file model that is annotated as SingleFile annotation must have fileName and primarySection.

Every single file model must extend SingleFileModel class.

Methods: serialize() and deserialize(Map<String, Object> args) are important to Bukkit serialization system.

Method init must be called in constructor

Example of Single file model:

@SingleFile(fileName = "users_coins.yml", primarySection = "users")
@SerializableAs("UserCoins") //This is alias for Bukkit serialization (optional)
public class UserCoins extends SingleFileModel {

    @IdSection
    private UUID uuid;
    private double coins;

    public UserCoins (String name, double coins) {
        this.name = name;
        this.coins = coins
        init();
    }
    
    @Override
    @NonNull
    public Map<String, Object> serialize() {
        Map<String, Object> data = new LinkedHashMap<>();

        data.put("uuid", uuid);
        data.put("coins", coins);

        return data;
    }

    public static UserCoins deserialize(Map<String, Object> args) {
        return new UserCoins((UUID) args.get("uuid"), 
        (double) args.get("coins"));
    }
}

Last updated