⚙️
T-MiniGameAPI
WebsiteDiscord
1.4.0
1.4.0
  • 🏠Home
  • 💻Maven and Gradle
  • 📦Minigame setup
  • 🖱️Plugins are using this libarary
  • Basic features
    • 🗺️Configuration
      • 🎯Configurators
      • 🔴Override Configuartors
    • 🖱️Commands
      • 🧔Parent commands
      • 🧒Sub commands
      • 📑Tab completer
      • ®️Command registration
    • 🧑Models
      • 📦File model
        • 🟢Single file
        • 🟠Many files
      • 💡DB model
      • 🧑‍🦱Users
    • 📔Loaders
      • 📗Loader
        • 📂File loader
        • 💾Database loader
    • 💬Library commands
  • Minigame features
    • 🅰️Arena system
      • 🟢Arena
      • 🔵ArenaManager
    • 🎮Game system
      • 🔴Game Manager
      • 🔵Game State
      • 🟡Users in game
      • 🟢Teams
    • ⏰Timers
      • 😀SimpleTimer
      • ✨XpTimer
    • 🪙Coins system
      • 🟢UserCoins
      • 🔵UserCoinsManager
    • ✨Statistics system
      • 🟢Default statistics system
      • 🔵Your own statistics system
    • 💥Cosmetics system
      • 📀Cosmetic
        • 💕ParticleCosmetic
      • ✳️Cosmetics Manager
      • 🧒Users' cosmetics
        • 💿UserCosmeticsManager
        • ✅UserCosmetics
  • Addons
    • 🎁What is addon?
    • 🖍️How to create addon?
    • 📃Addons list
Powered by GitBook
On this page
  1. Basic features
  2. Models
  3. File model

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"));
    }
}
PreviousFile modelNextMany files

Last updated 1 year ago

🧑
📦
🟢