mirror of
https://github.com/DanielLMcGuire/LCE-SDK.git
synced 2026-05-21 17:24:30 +00:00
52 lines
897 B
C++
52 lines
897 B
C++
#pragma once
|
|
#include "Minecraft.h"
|
|
#include <functional>
|
|
#include <filesystem>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
#if defined(_WIN32)
|
|
#include <windows.h>
|
|
#include <direct.h>
|
|
#else
|
|
#include <dirent.h>
|
|
#include <unistd.h>
|
|
#include <dlfcn.h>
|
|
#endif
|
|
|
|
#include "../include/lce.h"
|
|
|
|
typedef void (*ModEntry)(const Minecraft *minecraft);
|
|
|
|
struct Plugin
|
|
{
|
|
#if defined(_WIN32)
|
|
HMODULE handle;
|
|
#else
|
|
void *handle;
|
|
#endif
|
|
std::string path;
|
|
ModEntry init;
|
|
};
|
|
|
|
class Modloader
|
|
{
|
|
public:
|
|
explicit Modloader(const std::string &pluginFolder, Minecraft *minecraft);
|
|
|
|
~Modloader();
|
|
|
|
bool addPlugin(const std::string &pluginPath);
|
|
|
|
private:
|
|
bool loadPlugin(const std::string &library, Minecraft *minecraft);
|
|
|
|
std::vector<std::string> scanPlugins(const std::string &folder);
|
|
|
|
void unloadAll();
|
|
|
|
std::vector<Plugin> plugins_;
|
|
std::string pluginFolder_;
|
|
Minecraft *m_instance;
|
|
};
|