Plugin API
From Mineserver Wiki
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)")));
return;
}
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!");
return;
}
}
Available functions
Mineserver
Chat
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 |
Screen
Function | Parameters | Return value |
---|---|---|
log | (std::string message) | none |
Prints message to server window |
Map
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 | ||
getBlock | (int x, int y, int z, unsigned char* type,unsigned char* meta) | bool |
Get block type and metadata (absolute block coordinates) | ||
setBlock | (int x, int y, int z, unsigned char type,unsigned char meta) | bool |
Set block type and metadata (absolute block coordinates) |
Available callbacks
Name | Parameters | Return value |
---|---|---|
ChatPre | const std::string& nick, std::string msg | bool |
called on chat message prosessing, returning false will terminate the callback. | ||
BlockPlacePre | const std::string& nick, int x,char y,int z,char block | bool |
called on block placement, returning false will prevent block placement and terminate callback. | ||
BlockBreakPre | (int* x, int* y, int* z) | bool |
called on block break, returning false will prevent block breaking and terminate callback. |