Compare commits

...

3 Commits

Author SHA1 Message Date
mrbesen d2b861eb7f
System.loadLibrary() used, improved logging 2020-02-21 10:33:00 +01:00
mrbesen d844699afc
improved messages 2020-02-21 10:29:26 +01:00
mrbesen 86ec4be6fc
changed ln 2020-02-21 10:28:22 +01:00
7 changed files with 9 additions and 17 deletions

View File

@ -5,7 +5,7 @@
#define DEBUG 1
#ifdef DEBUG
#if DEBUG == 1
#define DEB(A) std::cout << A << std::endl
#else
#define DEB(A) ;

View File

@ -13,15 +13,13 @@ if [ "$?" -ne "0" ]; then
echo "Error"
exit 1
fi
sudo make install
# sudo make install # or create a link to this lib once with: sudo ln -s $(realpath target/libplugin.so) /usr/lib
#build and install all testplugins
make installplugins
#prepare server
mkdir -p testserver/plugins/CppPlugins
cp target/Cppplugin-0.1-SNAPSHOT-final.jar testserver/plugins/
cp target/libplugin.so testserver/plugins/CppPlugins
#start server
cd testserver

View File

@ -76,7 +76,7 @@ void load(JNIEnv* env, long data) {
if(((!CPPPLUGINCLASS) + (!EVENTCLASS) + (!MAPCLASS) + (!LISTENERCLASS) //wenn eins == nullptr ist -> wird zu 1 -> endergebniss != 0 -> fehler
+ (!EVENTDATAF) + (!EVENTNAMEF) + (!PLUGINIDF)
+ (!MAPGET) + (!MAPPUT) + (!MAPCLEAR) + (!LISTENERCONTR) + (!LISTENERSMALLCONTR)) == 0) {
+ (!MAPGET) + (!MAPPUT) + (!MAPCLEAR) + (!LISTENERCONTR) + (!LISTENERSMALLCONTR)) != 0) {
DEB("Error loading a information: ");
DEB("find classes: " << (!!CPPPLUGINCLASS) << (!!EVENTCLASS) << (!!MAPCLASS) << (!!LISTENERCLASS));

View File

@ -44,7 +44,7 @@ public class CppLoader implements PluginLoader {
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException {
log.info("try to load: " + file.getName());
log.info("Loading " + file.getName());
return new CppPlugin(file, this);
}

View File

@ -54,12 +54,8 @@ public class CppPlugin implements Plugin {
}
protected boolean init() {
File folder = CppPlugins.getInstance().getDataFolder();
folder.mkdirs();
String path = folder.getAbsolutePath() + "/libplugin.so";
getLogger().info("load library from: " + path);
try {
System.load(path);
System.loadLibrary("plugin"); //loads libplugin.so from System.getProperty("java.library.path")
return init_();
} catch(UnsatisfiedLinkError e) {
e.printStackTrace();

View File

@ -15,7 +15,7 @@ public:
};
void EventsPlugin::onLoad() {
std::cout << "Events::onload();" << std::endl;
std::cout << "Events::onLoad();" << std::endl;
}
void EventsPlugin::onEnable() {
@ -27,7 +27,6 @@ void EventsPlugin::onDisable() {
}
CppPlugin* init() {
std::cout << "init im plugin!" << std::endl;
return new EventsPlugin();
}

View File

@ -15,19 +15,18 @@ public:
};
void SimplePlugin::onLoad() {
std::cout << "onload();" << std::endl;
std::cout << "SimplePLugin::onLoad();" << std::endl;
}
void SimplePlugin::onEnable() {
std::cout << "onEnable();" << std::endl;
std::cout << "SimplePLugin::onEnable();" << std::endl;
}
void SimplePlugin::onDisable() {
std::cout << "onDisable();" << std::endl;
std::cout << "SimplePLugin::onDisable();" << std::endl;
}
CppPlugin* init() {
std::cout << "init im plugin!" << std::endl;
return new SimplePlugin();
}