package net.twasi.core.graphql.model;

import net.twasi.core.database.models.User;
import net.twasi.core.plugin.PluginConfig;

import java.util.List;

public class PluginDetailsDTO {
    private final String name;
    private final String description;
    private final String author;
    private final String version;
    private final List<String> commands;
    private final List<String> permissions;

    private final boolean isInstalled;

    public PluginDetailsDTO(PluginConfig config, boolean isInstalled) {
        this(config, null, isInstalled);
    }

    public PluginDetailsDTO(PluginConfig config, User user, boolean isInstalled) {
        if (user != null) {
            name = config.getLocalizedName(user);
            description = config.getLocalizedDescription(user);
        } else {
            name = config.getName();
            description = config.getDescription();
        }

        author = config.getAuthor();
        version = config.getVersion();

        commands = config.getCommands();
        permissions = config.getPermissions();

        this.isInstalled = isInstalled;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public String getAuthor() {
        return author;
    }

    public String getVersion() {
        return version;
    }

    public List<String> getCommands() {
        return commands;
    }

    public List<String> getPermissions() {
        return permissions;
    }

    public boolean isInstalled() {
        return isInstalled;
    }
}

@@ -203,24 +203,53 @@
 tring name;%0A
+    private final String id;%0A
     private 
@@ -1130,24 +1130,60 @@
 sInstalled;%0A
+        this.id = config.getName();%0A
     %7D%0A%0A    p
@@ -1575,32 +1575,86 @@
 issions;%0A    %7D%0A%0A
+    public String getId() %7B%0A        return id;%0A    %7D%0A%0A
     public boole

add plugin id to dto