aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod/MetadataHandler.h
blob: 39723b49c19c6d02676c477b5d55ed5cf3ad9af5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: GPL-3.0-only
/*
*  PolyMC - Minecraft Launcher
*  Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, version 3.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include <memory>

#include "modplatform/packwiz/Packwiz.h"

// launcher/minecraft/mod/Mod.h
class Mod;

/* Abstraction file for easily changing the way metadata is stored / handled
 * Needs to be a class because of -Wunused-function and no C++17 [[maybe_unused]]
 * */
class Metadata {
   public:
    using ModStruct = Packwiz::V1::Mod;

    static auto create(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> ModStruct
    {
        return Packwiz::V1::createModFormat(index_dir, mod_pack, mod_version);
    }

    static auto create(QDir& index_dir, Mod& internal_mod, QString mod_slug) -> ModStruct
    {
        return Packwiz::V1::createModFormat(index_dir, internal_mod, mod_slug);
    }

    static void update(QDir& index_dir, ModStruct& mod)
    {
        Packwiz::V1::updateModIndex(index_dir, mod);
    }

    static void remove(QDir& index_dir, QString mod_slug)
    {
        Packwiz::V1::deleteModIndex(index_dir, mod_slug);
    }

    static void remove(QDir& index_dir, QVariant& mod_id)
    {
        Packwiz::V1::deleteModIndex(index_dir, mod_id);
    }

    static auto get(QDir& index_dir, QString mod_slug) -> ModStruct
    {
        return Packwiz::V1::getIndexForMod(index_dir, mod_slug);
    }

    static auto get(QDir& index_dir, QVariant& mod_id) -> ModStruct
    {
        return Packwiz::V1::getIndexForMod(index_dir, mod_id);
    }
};