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 <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <cstdlib>
#include <iostream>
#define MINESERVER_C_API
#include "../src/plugin_api.h"
#include "../src/logtype.h"
#define PLUGIN_VERSION 1.0
double pluginVersion = PLUGIN_VERSION;
#define PLUGIN_NAME "pressurplate"
const char* pluginName = PLUGIN_NAME;
const char* logSource = "plugin.screen";
mineserver_pointer_struct* mineserver;
PLUGIN_API_EXPORT void CALLCONVERSION pressurplate_init(mineserver_pointer_struct* mineserver_temp)
{
mineserver = mineserver_temp;
if (mineserver->plugin.getPluginVersion(pluginName) > 0)
{
mineserver->logger.log(LogType::LOG_INFO, logSource, "The " PLUGIN_NAME " plugin is already loaded");
return;
}
mineserver->logger.log(LogType::LOG_INFO, logSource, "Loaded " PLUGIN_NAME);
mineserver->plugin.setPluginVersion(pluginName, pluginVersion);
}
PLUGIN_API_EXPORT void CALLCONVERSION pressurplate_shutdown(void)
{
if (mineserver->plugin.getPluginVersion(pluginName) <= 0)
{
mineserver->logger.log(LogType::LOG_INFO, logSource, PLUGIN_NAME " is not loaded!");
return;
}
mineserver->logger.log(LogType::LOG_INFO, logSource, PLUGIN_NAME " has been unloaded!");
}
Available functions
Mineserver
Chat
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
sendmsgTo
|
user
|
const char*
|
Username in null Terminated char array
|
msg
|
const char*
|
Message in null terminated char array
|
Return value
|
bool, telling it the user was found
|
Sends a message to specified user
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
sendmsg
|
msg
|
const char*
|
Message in null terminated char array
|
Return value
|
bool, telling it the user was found
|
Sends a message to all players, except they are in DND mode
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
sendUserList
|
user
|
const char*
|
User in null terminated char array
|
Return value
|
bool, telling it the user was found
|
Sends the playerlist to user
|
Screen
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
log
|
msg
|
const char*
|
Message in null terminated char array
|
Return value
|
void
|
Prints message to server window
|
Map
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
createPickupSpawn
|
x
|
int
|
x-coordinate
|
y
|
int
|
y-coordinate
|
z
|
int
|
z-coordinate
|
conut
|
int
|
How many to spawn(1-64)
|
health
|
int
|
item health. 0 is max health, max value depends on the item
|
user
|
const char*
|
Username
|
Return value
|
void
|
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.
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setTime
|
timeValue
|
int
|
value between 0 and 2400
|
Return value
|
bool
|
Sets server time to timeValue
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getSpawn
|
x
|
int*
|
x-coordinate
|
y
|
int*
|
y-coordinate
|
z
|
int*
|
z-coordinate
|
Return value
|
void
|
Gets server spawn position
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getBlock
|
x
|
int
|
x-coordinate
|
y
|
int
|
y-coordinate
|
z
|
int
|
z-coordinate
|
type
|
unsigned char*
|
block type
|
meta
|
unsigned char*
|
block metadata
|
Return value
|
bool
|
Get block type and metadata (absolute block coordinates) in first world (id 0)
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getBlockW
|
x
|
int
|
x-coordinate
|
y
|
int
|
y-coordinate
|
z
|
int
|
z-coordinate
|
w
|
int
|
World ID
|
type
|
unsigned char*
|
block type
|
meta
|
unsigned char*
|
block metadata
|
Return value
|
bool
|
Gets block type and metadata (absolute block coordinates)
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setBlock
|
x
|
int
|
x-coordinate
|
y
|
int
|
y-coordinate
|
z
|
int
|
z-coordinate
|
type
|
unsigned char
|
block type
|
meta
|
unsigned char
|
block metadata
|
Return value
|
bool
|
Set block type and metadata (absolute block coordinates)
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setBlockW
|
x
|
int
|
x-coordinate
|
y
|
int
|
y-coordinate
|
z
|
int
|
z-coordinate
|
w
|
int
|
World ID
|
type
|
unsigned char*
|
block type
|
meta
|
unsigned char*
|
block metadata
|
Return value
|
bool
|
Sets block type and metadata (absolute block coordinates)
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setSpawn
|
x
|
int
|
x-coordinate
|
y
|
int
|
y-coordinate
|
z
|
int
|
z-coordinate
|
Return value
|
bool
|
Set spawn to x, y, z (absolute coordinates)
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
saveWholeMap
|
|
void
|
|
Return value
|
void
|
Saves the whole map to disk
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getMapData_block
|
x
|
int
|
x-coordinate
|
z
|
int
|
z-coordinate
|
Return value
|
unsigned char*
|
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getMapData_meta
|
x
|
int
|
x-coordinate
|
z
|
int
|
z-coordinate
|
Return value
|
unsigned char*
|
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getMapData_skylight
|
x
|
int
|
x-coordinate
|
z
|
int
|
z-coordinate
|
Return value
|
unsigned char*
|
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getMapData_blocklight
|
x
|
int
|
x-coordinate
|
z
|
int
|
z-coordinate
|
Return value
|
unsigned char*
|
|
User Functions
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
toggleDND
|
user
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, indicates if user was found
|
Toggles the DND (Do not Disturb)-Mode of a user
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getPosition
|
user
|
const char*
|
Username in null terminated char array
|
x
|
double*
|
x-coordinate
|
y
|
double*
|
y-coordinate
|
z
|
double*
|
z-coordinate
|
yaw
|
float*
|
yaw-Value
|
pitch
|
float*
|
pitch-Value
|
*stance
|
double
|
stance-Value
|
Return value
|
bool, true if user has been found
|
Finds a player and stores its info in the referenced variables
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getPosition
|
user
|
const char*
|
Username in null terminated char array
|
x
|
double*
|
x-coordinate
|
y
|
double*
|
y-coordinate
|
z
|
double*
|
z-coordinate
|
w
|
int*
|
World ID
|
yaw
|
float*
|
yaw-Value
|
pitch
|
float*
|
pitch-Value
|
*stance
|
double
|
stance-Value
|
Return value
|
bool, true if user has been found
|
Finds a player and stores its info in the referenced variables
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
teleport
|
user
|
const char*
|
Username in null terminated char array
|
x
|
double*
|
x-coordinate
|
y
|
double*
|
y-coordinate
|
z
|
double*
|
z-coordinate
|
Return value
|
bool, true if user was found
|
Teleports a user to x,y,z
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
teleport
|
user
|
const char*
|
Username in null terminated char array
|
x
|
double*
|
x-coordinate
|
y
|
double*
|
y-coordinate
|
z
|
double*
|
z-coordinate
|
map
|
int
|
Map ID
|
Return value
|
bool, true if user was found
|
Teleports a user to x,y,z on map
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setHealth
|
user
|
const char*
|
Username in null terminated char array
|
userHealth
|
int
|
Health of user. Must not be greater than 20.
|
Return value
|
bool, true if user is not null
|
Sets the health of a user.
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getHealth
|
user
|
const char*
|
Username in null terminated char array
|
Return value
|
int, player's health
|
Gets the health of a user
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
no paramters
|
|
|
int, number of players online
|
Return value
|
Gets the number of players online
|
{{{6}}}
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
getItemInHand
|
user
|
const char*
|
Username in null terminated char array
|
*type
|
int
|
Type of item
|
*meta
|
int
|
Health of item
|
*quant
|
int
|
quantity of item
|
Return value
|
bool, true if user was found
|
Gets the item in the hand of user
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setItemInHand
|
user
|
const char*
|
Username in null terminated char array
|
type
|
int
|
Type of item
|
meta
|
int
|
Health of item
|
quant
|
int
|
quantity of item, must not be greater than 64
|
Return value
|
bool, true if user was found
|
Sets the item in the hand of user
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
addItem
|
user
|
const char*
|
Username in null terminated char array
|
type
|
int
|
Type of item
|
meta
|
int
|
Health of item
|
quant
|
int
|
quantity of item, must not be greater than 64
|
Return value
|
bool, true if user was found
|
Adds the item to the user's inventory
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
hasItem
|
user
|
const char*
|
Username in null terminated char array
|
type
|
int
|
Type of item
|
meta
|
int
|
Health of item
|
quant
|
int
|
quantity of item, must not be greater than 64
|
Return value
|
bool, true if the item is in Users inventory. Chests are unchecked.
|
Checks if item is in user's inventory
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
delItem
|
user
|
const char*
|
Username in null terminated char array
|
type
|
int
|
Type of item
|
meta
|
int
|
Health of item
|
quant
|
int
|
quantity of item, must not be greater than 64
|
Return value
|
bool, true if user was found
|
Delets the item quantity times from the user's inventory. Chests are untouched.
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
kick
|
user
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user is found
|
Kicks user with standard reason "You have been kicked"
|
Config wrapper functions
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
has
|
name
|
const char*
|
name of the config string
|
Return value
|
bool, true if config string was found
|
Checks if the config string name exists in the configuration file
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
iData
|
name
|
const char*
|
name of the config string
|
Return value
|
int
|
Gets integer data from configuration string name
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
lData
|
name
|
const char*
|
name of the config string
|
Return value
|
int64_t
|
Gets long (int64_t) data from configuration string name
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
fData
|
name
|
const char*
|
name of the config string
|
Return value
|
float
|
Gets float data from configuration string name
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
dData
|
name
|
const char*
|
name of the config string
|
Return value
|
double
|
Gets double data from configuration string name
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
sData
|
name
|
const char*
|
name of the config string
|
Return value
|
const char*
|
Gets string (char*) data from configuration string name
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
bData
|
name
|
const char*
|
name of the config string
|
Return value
|
bool
|
Gets bool data from configuration string name
|
Mobs
Permissions
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setAdmin
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user was found
|
Makes user to a server administrator, providing him with full permissions.
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setOp
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user was found
|
Makes user to a server Operator
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setMember
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user was found
|
Makes user to a regular member
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
setGuest
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user was found
|
Makes user to a guest
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
isAdmin
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user is admin
|
Checks, if user is a server administrator
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
isOp
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user is operator
|
Checks, if user is a server Operator
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
isMember
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user is member
|
Checks, if user is a regular member
|
Function
|
Parameter name
|
Parameter type
|
Parameter info
|
Guest
|
name
|
const char*
|
Username in null terminated char array
|
Return value
|
bool, true if user is guest
|
Checks, if user is a guest
|
Available callbacks
Name
|
Parameter name
|
Parameter type
|
Parameter info
|
Timer200
|
no params
|
|
|
Return value
|
bool, isn't used
|
200ms timer callback
|
Name
|
Parameter name
|
Parameter type
|
Parameter info
|
Timer1000
|
no params
|
|
|
Return value
|
bool, isn't used
|
1000ms (1s) timer callback
|
Name
|
Parameter name
|
Parameter type
|
Parameter info
|
Timer10000
|
no params
|
|
|
Return value
|
bool, isn't used
|
10s timer callback
|
Name
|
Parameter name
|
Parameter type
|
Parameter info
|
PlayerChatPre
|
user
|
const char*
|
Username in null terminated char array
|
timestamp
|
size_t
|
time of the message
|
msg
|
const char*
|
Message in null terminated char array
|
Return value
|
bool
|
called on chat message processing, returning false will terminate the callback.
|
Name
|
Parameter name
|
Parameter type
|
Parameter info
|
PlayerChatCommand
|
user
|
const char*
|
Username in null terminated char array
|
command
|
const char*
|
command
|
argc
|
int
|
argument count
|
arguments
|
const char**
|
list of arguments
|
Return value
|
bool
|
called when chat command is used
|
Name
|
Parameter name
|
Parameter type
|
Parameter info
|
BlockPlacePre
|
user
|
const char*
|
Username in char array
|
x
|
int32_t
|
x-coord
|
y
|
int8_t
|
y-coord
|
z
|
int32_t
|
z-coord
|
block
|
int16_t
|
block type
|
direction
|
int8_t
|
placement direction
|
Return value
|
bool
|
called on block placement, returning false will prevent block placement and terminate callback.
|
Name
|
Parameter name
|
Parameter type
|
Parameter info
|
BlockBreakPre
|
user
|
const char*
|
Username in char array
|
x
|
int
|
x-coord
|
y
|
int
|
y-coord
|
z
|
int
|
z-coord
|
Return value
|
bool
|
called on block break, returning false will prevent block breaking and terminate callback.
|
ToDo:
setHook("PlayerLoginPre", new Hook2<bool,const char*,char***>);
setHook("PlayerLoginPost", new Hook1<bool,const char*>);
setHook("PlayerNickPost", new Hook2<bool,const char*,const char*>);
setHook("PlayerKickPost", new Hook2<bool,const char*,const char*>);
setHook("PlayerQuitPost", new Hook1<bool,const char*>);
setHook("PlayerChatPost", new Hook3<bool,const char*,time_t,const char*>);
setHook("PlayerArmSwing", new Hook1<bool,const char*>);
setHook("PlayerDamagePre", new Hook3<bool,const char*,const char*,int>);
setHook("PlayerDamagePost", new Hook3<bool,const char*,const char*,int>);
setHook("PlayerDisconnect", new Hook3<bool,const char*,uint32,uint16>);
setHook("PlayerDiggingStarted", new Hook4<bool,const char*,sint32,sint8,sint32>);
setHook("PlayerDigging", new Hook4<bool,const char*,sint32,sint8,sint32>);
setHook("PlayerDiggingStopped", new Hook4<bool,const char*,sint32,sint8,sint32>);
setHook("BlockBreakPre", new Hook4<bool,const char*,sint32,sint8,sint32>);
setHook("BlockBreakPost", new Hook4<bool,const char*,sint32,sint8,sint32>);
setHook("BlockNeighbourBreak", new Hook7<bool,const char*,sint32,sint8,sint32,sint32,sint8,sint32>);
setHook("BlockPlacePre", new Hook5<bool,const char*,sint32,sint8,sint32,sint16>);
setHook("BlockPlacePost", new Hook5<bool,const char*,sint32,sint8,sint32,sint16>);
setHook("BlockNeighbourPlace", new Hook7<bool,const char*,sint32,sint8,sint32,sint32,sint8,sint32>);
setHook("BlockReplacePost", new Hook6<bool,const char*,sint32,sint8,sint32,sint16,sint16>);
setHook("BlockNeighbourReplace", new Hook9<bool,const char*,sint32,sint8,sint32,sint32,sint8,sint32,sint16,sint16>);