โš™๏ธ
T-MiniGameAPI
WebsiteDiscord
2.0.0
2.0.0
  • ๐Ÿ Home
  • ๐Ÿ’ปMaven and Gradle
  • ๐Ÿ“ฆMinigame setup
  • ๐Ÿ–ฑ๏ธPlugins are using this libarary
  • Basic features
    • ๐Ÿ—บ๏ธConfiguration
      • ๐ŸŽฏConfigurators
      • ๐Ÿ”ดOverride Configuartors
    • ๐Ÿง‘Models
      • ๐Ÿ“ฆFile model
        • ๐ŸŸขSingle file
        • ๐ŸŸ Many files
      • ๐Ÿง‘โ€๐ŸฆฑUsers
    • ๐Ÿ“”Loaders
      • ๐Ÿ“—Loader
        • ๐Ÿ“‚File loader
  • 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
  • Modules
    • ๐Ÿ”ŒWhat is module ?
    • ๐Ÿ—’๏ธModules list
    • Internal Modules
      • Commands Module
        • ๐Ÿง”Parent commands
        • ๐Ÿง’Sub commands
        • ๐Ÿ“‘Tab completer
        • ยฎ๏ธCommand registration
      • SQL Module
        • ๐Ÿ’กDbModel
        • SQLDatabaseDao
        • ๐Ÿ’พDatabase loader
        • SQLDatabaseAdapter
        • SQLDatabaseMigrator
      • MongoDB Module
        • MongoDbConnector
        • ๐Ÿ’กMongoDbModel
        • MongoDbDao
        • ๐Ÿ’พMongoDb loader
    • ๐Ÿ’พHow to create module?
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 implement FileModel interface.

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

Example of Single file model:

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

    @Id
    private UUID uuid;
    private double coins;

    public UserCoins (String name, double coins) {
        this.name = name;
        this.coins = coins
    }
    
    @Override
    public Dao getDao() {
        return new SingleYamlFileDao(this);
    }
    
    @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
๐Ÿง‘
๐Ÿ“ฆ
๐ŸŸข