use serde::{Serialize, Deserialize};

use super::repository::RepositorySource;

/// Represents a Minecraft plugin with detailed information
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Plugin {
    pub name: String,
    pub version: String,
    pub latest_version: Option<String>,
    pub description: Option<String>,
    pub authors: Vec<String>,
    pub website: Option<String>,
    pub has_update: bool,
    pub api_version: Option<String>,
    pub main_class: Option<String>,
    pub depend: Option<Vec<String>>,
    pub soft_depend: Option<Vec<String>>,
    pub load_before: Option<Vec<String>>,
    pub commands: Option<serde_json::Value>,
    pub permissions: Option<serde_json::Value>,
    pub file_path: String,
    pub file_hash: String,
    pub changelog: Option<String>, // Changelog for the latest version
    // Fields for persistence
    pub repository_source: Option<RepositorySource>,
    pub repository_id: Option<String>,
    pub repository_url: Option<String>, // URL to the plugin page on the repository
}

/// Raw metadata extracted from a plugin.yml file
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PluginMeta {
    pub name: String,
    pub version: String,
    pub description: Option<String>,
    pub authors: Vec<String>,
    pub website: Option<String>,
    pub api_version: Option<String>,
    pub main_class: Option<String>,
    pub depend: Option<Vec<String>>,
    pub soft_depend: Option<Vec<String>>,
    pub load_before: Option<Vec<String>>,
    pub commands: Option<serde_json::Value>,
    pub permissions: Option<serde_json::Value>,
    pub file_path: String,
    pub file_size: u64,
    pub file_hash: String,
}