Plugin API

From Mineserver Wiki

Revision as of 19:15, 29 December 2010 by Fador (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Mineserver uses a C-plugin API which is described in this page.


Creating a plugin

You will need to include plugin_api.h to your project.

...write some more stuff here...

Example plugin structure:

 #include "plugin_api.h"
 #define PLUGIN_VERSION 1.0
 mineserver_pointer_struct* mineserver;
 PLUGIN_API_EXPORT void (plugin_name)_init(mineserver_pointer_struct* mineserver_temp)
   mineserver = mineserver_temp;
   if (mineserver->plugin.getPluginVersion("(plugin_name)") > 0)
     mineserver->screen.log("(plugin_name) is already loaded v." +dtos(mineserver->plugin.getPluginVersion("(plugin_name)")));
   mineserver->screen.log("Loaded \"(plugin_name)\"!");
   mineserver->plugin.setPluginVersion("(plugin_name)", PLUGIN_VERSION);
   mineserver->callback.add_hook("ChatPre", (void *)chatPreFunction);
 PLUGIN_API_EXPORT void (plugin_name)_shutdown(void)
   if (mineserver->plugin.getPluginVersion("(plugin_name)") <= 0)
     mineserver->screen.log("(plugin_name) is not loaded!");

Available functions



Function Parameters Return value
sendmsgTo (std::string user,std::string msg) bool, telling it the user was found
This function is used to send msg to single user
sendmsg (std::string message) bool, telling it the user was found
This function is used to send msg to single user


Function Parameters Return value
log (std::string message) none
Prints message to server window


Function Parameters Return value
createPickupSpawn (int x, int y, int z, int type, int count, int health, std::string user) none
Spawns an item at (x,y,z) with type,count and health specified. If "user" is set, he will not be able to pick up the item right away to make it possible to throw stuff away.
setTime (std::string timeValue) bool
Sets server time to timeValue, which can be a string of value 0-24000
getSpawn (int* x, int* y, int* z) void
Gets server spawn position