55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#include "plugin.h"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <map>
|
|
|
|
using namespace Plugin;
|
|
|
|
extern "C" {
|
|
|
|
class EventsPlugin : public CppPlugin {
|
|
public:
|
|
virtual void onLoad(JNIEnv*);
|
|
virtual void onEnable(JNIEnv*);
|
|
virtual void onDisable(JNIEnv*);
|
|
virtual std::map<std::string, eventfptr> getEvents();
|
|
};
|
|
|
|
void EventsPlugin::onLoad(JNIEnv*) {
|
|
log("Events::onLoad();");
|
|
}
|
|
|
|
void EventsPlugin::onEnable(JNIEnv*) {
|
|
log("Events::onEnable();");
|
|
}
|
|
|
|
void EventsPlugin::onDisable(JNIEnv*) {
|
|
log("Events::onDisable();");
|
|
}
|
|
|
|
CppPlugin* init() {
|
|
return new EventsPlugin();
|
|
}
|
|
|
|
void eventJoin(JNIEnv* env, CppPlugin* pl, Event* e) {
|
|
jstring msg = (jstring) e->getData(env, "joinMessage");
|
|
std::string jmsg(env->GetStringUTFChars(msg, 0));
|
|
pl->log("join " + e->getName() + " old join message: " + jmsg);
|
|
jstring newmsg = env->NewStringUTF((std::string("Ein ") + Plugin::DARK_BLUE + "Spieler " + Plugin::DARK_GREEN + "ist dem Spiel beigetreten!").c_str());
|
|
e->setData("joinMessage", newmsg);
|
|
}
|
|
|
|
void eventQuit(JNIEnv* env, CppPlugin* pl, Event* e) {
|
|
pl->log("quit " + e->getName());
|
|
}
|
|
|
|
std::map<std::string, eventfptr> EventsPlugin::getEvents() {
|
|
log("EventsPlugin::getEvents");
|
|
std::map<std::string, eventfptr> out;
|
|
out.insert({"PlayerJoinEvent", eventJoin});
|
|
out.insert({"PlayerQuitEvent", eventQuit});
|
|
return out;
|
|
}
|
|
|
|
}//extern "C"
|