🟠Many files

This type of saving file creates a file with the name of the Id field's value

Every Many files model annotated as ManyFiles annotation. A primary section is not required.

Every Many files model must extend ManyFilesModel class.

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

Method init must be called in constructor

Example of Many files model:

@ManyFiles(primarySection = "user", parentDirectory = "arenas")
@SerializableAs("UserCoins") //This is alias for Bukkit serialization (optional)
public class UserCoins extends ManyFilesModel {

    @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