36 lines
968 B
C++
36 lines
968 B
C++
#pragma once
|
|
#include <jni.h>
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "event.h"
|
|
|
|
//fwd declr
|
|
class CppPlugin;
|
|
|
|
//function pointer
|
|
typedef void (*eventfptr)(JNIEnv*, CppPlugin*, Event*); //event
|
|
typedef CppPlugin* (*initfptr)(); //init
|
|
// cmdsender cmd label args arglength
|
|
typedef bool (*cmdfptr)(JNIEnv*, CppPlugin*, jobject, jobject, std::string&, std::vector<std::string>&);
|
|
|
|
|
|
class CppPlugin {
|
|
public:
|
|
void* handle;
|
|
std::string name;
|
|
int id;
|
|
virtual void onLoad(JNIEnv*);
|
|
virtual void onEnable(JNIEnv*);
|
|
virtual void onDisable(JNIEnv*);
|
|
virtual std::map<std::string, eventfptr> getEvents();
|
|
virtual ~CppPlugin();
|
|
};
|
|
|
|
bool registerCmd(JNIEnv* env, CppPlugin* plugin, std::string& cname, cmdfptr function);
|
|
inline bool registerCmd(JNIEnv* env, CppPlugin* plugin, const char* cname, cmdfptr function) {
|
|
std::string n(cname);
|
|
return registerCmd( env, plugin, n, function);
|
|
} |