summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/AllToLua.pkg4
-rw-r--r--src/Bindings/CMakeLists.txt11
-rw-r--r--src/Bindings/DeprecatedBindings.cpp5
-rw-r--r--src/Bindings/LuaChunkStay.cpp3
-rw-r--r--src/Bindings/LuaChunkStay.h1
-rw-r--r--src/Bindings/LuaFunctions.h2
-rw-r--r--src/Bindings/LuaState.cpp86
-rw-r--r--src/Bindings/LuaState.h24
-rw-r--r--src/Bindings/LuaWindow.cpp1
-rw-r--r--src/Bindings/ManualBindings.cpp503
-rw-r--r--src/Bindings/ManualBindings.h18
-rw-r--r--src/Bindings/ManualBindings_RankManager.cpp1090
-rw-r--r--src/Bindings/Plugin.h17
-rw-r--r--src/Bindings/PluginLua.cpp29
-rw-r--r--src/Bindings/PluginLua.h3
-rw-r--r--src/Bindings/PluginManager.cpp71
-rw-r--r--src/Bindings/PluginManager.h10
-rw-r--r--src/Bindings/WebPlugin.cpp3
-rw-r--r--src/Bindings/WebPlugin.h1
-rw-r--r--src/Bindings/gen_LuaState_Call.lua34
20 files changed, 1797 insertions, 119 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 1e5dfd2fe..73de98e22 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -27,6 +27,7 @@ $cfile "WebPlugin.h"
$cfile "LuaWindow.h"
$cfile "../BlockID.h"
+$cfile "../Mobs/MonsterTypes.h"
$cfile "../BlockInfo.h"
$cfile "../StringUtils.h"
$cfile "../Defines.h"
@@ -47,6 +48,7 @@ $cfile "../Inventory.h"
$cfile "../Enchantments.h"
$cfile "../Item.h"
$cfile "../ItemGrid.h"
+$cfile "../BlockEntities/BeaconEntity.h"
$cfile "../BlockEntities/BlockEntity.h"
$cfile "../BlockEntities/BlockEntityWithItems.h"
$cfile "../BlockEntities/ChestEntity.h"
@@ -66,7 +68,6 @@ $cfile "../Root.h"
$cfile "../Cuboid.h"
$cfile "../BoundingBox.h"
$cfile "../Tracer.h"
-$cfile "../Group.h"
$cfile "../BlockArea.h"
$cfile "../Generating/ChunkDesc.h"
$cfile "../CraftingRecipes.h"
@@ -77,6 +78,7 @@ $cfile "../Map.h"
$cfile "../MapManager.h"
$cfile "../Scoreboard.h"
$cfile "../Statistics.h"
+$cfile "../Protocol/MojangAPI.h"
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 2ea2fa8c0..930ee9771 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -11,6 +11,7 @@ SET (SRCS
LuaState.cpp
LuaWindow.cpp
ManualBindings.cpp
+ ManualBindings_RankManager.cpp
Plugin.cpp
PluginLua.cpp
PluginManager.cpp
@@ -45,7 +46,6 @@ set(BINDING_DEPENDENCIES
../Bindings/AllToLua.pkg
../Bindings/gen_LuaState_Call.lua
../Bindings/LuaFunctions.h
- ../Bindings/LuaState_Call.inc
../Bindings/LuaWindow.h
../Bindings/Plugin.h
../Bindings/PluginLua.h
@@ -53,6 +53,7 @@ set(BINDING_DEPENDENCIES
../Bindings/WebPlugin.h
../BiomeDef.h
../BlockArea.h
+ ../BlockEntities/BeaconEntity.h
../BlockEntities/BlockEntity.h
../BlockEntities/BlockEntityWithItems.h
../BlockEntities/ChestEntity.h
@@ -96,7 +97,6 @@ set(BINDING_DEPENDENCIES
../Entities/HangingEntity.h
../Entities/ItemFrame.h
../Generating/ChunkDesc.h
- ../Group.h
../Inventory.h
../Item.h
../ItemGrid.h
@@ -125,8 +125,11 @@ if (NOT MSVC)
DEPENDS ${BINDING_DEPENDENCIES}
)
endif ()
-set_source_files_properties(Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
-set_source_files_properties(Bindings/Bindings.h PROPERTIES GENERATED TRUE)
+set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
+set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
+set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/LuaState_Call.inc PROPERTIES GENERATED TRUE)
+
+set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})
diff --git a/src/Bindings/DeprecatedBindings.cpp b/src/Bindings/DeprecatedBindings.cpp
index 36243bc92..02aa15be4 100644
--- a/src/Bindings/DeprecatedBindings.cpp
+++ b/src/Bindings/DeprecatedBindings.cpp
@@ -5,11 +5,6 @@
#undef TOLUA_TEMPLATE_BIND
#include "tolua++/include/tolua++.h"
-#include "Plugin.h"
-#include "PluginLua.h"
-#include "PluginManager.h"
-#include "LuaWindow.h"
-#include "LuaChunkStay.h"
#include "../BlockInfo.h"
diff --git a/src/Bindings/LuaChunkStay.cpp b/src/Bindings/LuaChunkStay.cpp
index 59b02d8f7..a3d3a8090 100644
--- a/src/Bindings/LuaChunkStay.cpp
+++ b/src/Bindings/LuaChunkStay.cpp
@@ -6,7 +6,6 @@
#include "Globals.h"
#include "LuaChunkStay.h"
#include "PluginLua.h"
-#include "../World.h"
@@ -107,7 +106,7 @@ void cLuaChunkStay::AddChunkCoord(cLuaState & L, int a_Index)
}
} // for itr - m_Chunks[]
- m_Chunks.push_back(cChunkCoords(ChunkX, ZERO_CHUNK_Y, ChunkZ));
+ m_Chunks.push_back(cChunkCoords(ChunkX, ChunkZ));
}
diff --git a/src/Bindings/LuaChunkStay.h b/src/Bindings/LuaChunkStay.h
index 49ab9a0ad..d76b67de9 100644
--- a/src/Bindings/LuaChunkStay.h
+++ b/src/Bindings/LuaChunkStay.h
@@ -18,6 +18,7 @@
// fwd:
class cPluginLua;
+class cChunkMap;
diff --git a/src/Bindings/LuaFunctions.h b/src/Bindings/LuaFunctions.h
index 2ea37d7a4..be1d9aaa9 100644
--- a/src/Bindings/LuaFunctions.h
+++ b/src/Bindings/LuaFunctions.h
@@ -1,6 +1,6 @@
#pragma once
-#include "../MCLogger.h"
+#include "Logger.h"
#include <time.h>
// tolua_begin
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index e123a87c9..85e3f9fc5 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -460,7 +460,43 @@ void cLuaState::Push(const Vector3d & a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3d");
+ tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3<double>");
+ m_NumCurrentFunctionArgs += 1;
+}
+
+
+
+
+
+void cLuaState::Push(const Vector3d * a_Vector)
+{
+ ASSERT(IsValid());
+
+ tolua_pushusertype(m_LuaState, (void *)a_Vector, "Vector3<double>");
+ m_NumCurrentFunctionArgs += 1;
+}
+
+
+
+
+
+void cLuaState::Push(const Vector3i & a_Vector)
+{
+ ASSERT(IsValid());
+
+ tolua_pushusertype(m_LuaState, (void *)&a_Vector, "Vector3<int>");
+ m_NumCurrentFunctionArgs += 1;
+}
+
+
+
+
+
+void cLuaState::Push(const Vector3i * a_Vector)
+{
+ ASSERT(IsValid());
+
+ tolua_pushusertype(m_LuaState, (void *)a_Vector, "Vector3<int>");
m_NumCurrentFunctionArgs += 1;
}
@@ -708,11 +744,11 @@ void cLuaState::Push(TakeDamageInfo * a_TDI)
-void cLuaState::Push(Vector3i * a_Vector)
+void cLuaState::Push(Vector3d * a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Vector, "Vector3i");
+ tolua_pushusertype(m_LuaState, a_Vector, "Vector3<double>");
m_NumCurrentFunctionArgs += 1;
}
@@ -720,11 +756,11 @@ void cLuaState::Push(Vector3i * a_Vector)
-void cLuaState::Push(Vector3d * a_Vector)
+void cLuaState::Push(Vector3i * a_Vector)
{
ASSERT(IsValid());
- tolua_pushusertype(m_LuaState, a_Vector, "Vector3d");
+ tolua_pushusertype(m_LuaState, a_Vector, "Vector3<int>");
m_NumCurrentFunctionArgs += 1;
}
@@ -823,6 +859,42 @@ void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, pBoundingBox & a_ReturnedVal)
+{
+ if (lua_isnil(m_LuaState, a_StackPos))
+ {
+ a_ReturnedVal = NULL;
+ return;
+ }
+ tolua_Error err;
+ if (tolua_isusertype(m_LuaState, a_StackPos, "cBoundingBox", false, &err))
+ {
+ a_ReturnedVal = *((cBoundingBox **)lua_touserdata(m_LuaState, a_StackPos));
+ }
+}
+
+
+
+
+
+void cLuaState::GetStackValue(int a_StackPos, pWorld & a_ReturnedVal)
+{
+ if (lua_isnil(m_LuaState, a_StackPos))
+ {
+ a_ReturnedVal = NULL;
+ return;
+ }
+ tolua_Error err;
+ if (tolua_isusertype(m_LuaState, a_StackPos, "cWorld", false, &err))
+ {
+ a_ReturnedVal = *((cWorld **)lua_touserdata(m_LuaState, a_StackPos));
+ }
+}
+
+
+
+
+
bool cLuaState::CallFunction(int a_NumResults)
{
ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
@@ -1334,10 +1406,8 @@ void cLuaState::LogStack(const char * a_Header)
void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
{
- UNUSED(a_Header); // The param seems unused when compiling for release, so the compiler warns
-
// Format string consisting only of %s is used to appease the compiler
- LOGD("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
+ LOG("%s", (a_Header != NULL) ? a_Header : "Lua C API Stack contents:");
for (int i = lua_gettop(a_LuaState); i > 0; i--)
{
AString Value;
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index afac77ce8..ef87c3efc 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -56,9 +56,12 @@ struct HTTPRequest;
class cWebAdmin;
struct HTTPTemplateRequest;
class cTNTEntity;
-class cCreeper;
class cHopperEntity;
class cBlockEntity;
+class cBoundingBox;
+
+typedef cBoundingBox * pBoundingBox;
+typedef cWorld * pWorld;
@@ -186,6 +189,9 @@ public:
void Push(const HTTPRequest * a_Request);
void Push(const HTTPTemplateRequest * a_Request);
void Push(const Vector3d & a_Vector);
+ void Push(const Vector3d * a_Vector);
+ void Push(const Vector3i & a_Vector);
+ void Push(const Vector3i * a_Vector);
// Push a value onto the stack (keep alpha-sorted):
void Push(bool a_Value);
@@ -227,6 +233,12 @@ public:
/** Retrieve value at a_StackPos, if it is a valid number, converting and clamping it to eWeather.
If not, a_Value is unchanged. */
void GetStackValue(int a_StackPos, eWeather & a_Value);
+
+ /** Retrieve value at a_StackPos, if it is a valid cBoundingBox class. If not, a_Value is unchanged */
+ void GetStackValue(int a_StackPos, pBoundingBox & a_Value);
+
+ /** Retrieve value at a_StackPos, if it is a valid cWorld class. If not, a_Value is unchanged */
+ void GetStackValue(int a_StackPos, pWorld & a_Value);
// Include the cLuaState::Call() overload implementation that is generated by the gen_LuaState_Call.lua script:
@@ -292,7 +304,7 @@ public:
void ToString(int a_StackPos, AString & a_String);
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
- void LogStack(const char * a_Header);
+ void LogStack(const char * a_Header = NULL);
/** Logs all the elements' types on the API stack, with an optional header for the listing. */
static void LogStack(lua_State * a_LuaState, const char * a_Header = NULL);
@@ -325,6 +337,14 @@ protected:
*/
bool PushFunction(int a_FnRef);
+ /** Pushes a function that has been saved as a reference.
+ Returns true if successful. Logs a warning on failure
+ */
+ bool PushFunction(const cRef & a_FnRef)
+ {
+ return PushFunction((int)a_FnRef);
+ }
+
/** Pushes a function that is stored in a referenced table by name
Returns true if successful. Logs a warning on failure
*/
diff --git a/src/Bindings/LuaWindow.cpp b/src/Bindings/LuaWindow.cpp
index 1a2582ab0..c4d03b86b 100644
--- a/src/Bindings/LuaWindow.cpp
+++ b/src/Bindings/LuaWindow.cpp
@@ -6,7 +6,6 @@
#include "LuaWindow.h"
#include "../UI/SlotArea.h"
#include "PluginLua.h"
-#include "../Entities/Player.h"
#include "lua/src/lauxlib.h" // Needed for LUA_REFNIL
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index df9687fc0..f643f06ec 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -5,7 +5,6 @@
#undef TOLUA_TEMPLATE_BIND
#include "tolua++/include/tolua++.h"
#include "polarssl/md5.h"
-#include "Plugin.h"
#include "PluginLua.h"
#include "PluginManager.h"
#include "LuaWindow.h"
@@ -16,6 +15,7 @@
#include "../WebAdmin.h"
#include "../ClientHandle.h"
#include "../BlockArea.h"
+#include "../BlockEntities/BeaconEntity.h"
#include "../BlockEntities/ChestEntity.h"
#include "../BlockEntities/CommandBlockEntity.h"
#include "../BlockEntities/DispenserEntity.h"
@@ -80,6 +80,33 @@ static int lua_do_error(lua_State* L, const char * a_pFormat, ...)
// Lua bound functions with special return types
+static int tolua_Clamp(lua_State * tolua_S)
+{
+ cLuaState LuaState(tolua_S);
+ int NumArgs = lua_gettop(LuaState);
+ if (NumArgs != 3)
+ {
+ return lua_do_error(LuaState, "Error in function call '#funcname#': Requires 3 arguments, got %i", NumArgs);
+ }
+
+ if (!lua_isnumber(LuaState, 1) || !lua_isnumber(LuaState, 2) || !lua_isnumber(LuaState, 3))
+ {
+ return lua_do_error(LuaState, "Error in function call '#funcname#': Expected a number for parameters #1, #2 and #3");
+ }
+
+ lua_Number Number = tolua_tonumber(LuaState, 1, 0);
+ lua_Number Min = tolua_tonumber(LuaState, 2, 0);
+ lua_Number Max = tolua_tonumber(LuaState, 3, 0);
+
+ lua_Number Result = Clamp(Number, Min, Max);
+ LuaState.Push(Result);
+ return 1;
+}
+
+
+
+
+
static int tolua_StringSplit(lua_State * tolua_S)
{
cLuaState LuaState(tolua_S);
@@ -139,7 +166,7 @@ static AString GetLogMessage(lua_State * tolua_S)
static int tolua_LOG(lua_State * tolua_S)
{
// If the param is a cCompositeChat, read the log level from it:
- cMCLogger::eLogLevel LogLevel = cMCLogger::llRegular;
+ cLogger::eLogLevel LogLevel = cLogger::llRegular;
tolua_Error err;
if (tolua_isusertype(tolua_S, 1, "cCompositeChat", false, &err))
{
@@ -147,7 +174,7 @@ static int tolua_LOG(lua_State * tolua_S)
}
// Log the message:
- cMCLogger::GetInstance()->LogSimple(GetLogMessage(tolua_S).c_str(), LogLevel);
+ cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), LogLevel);
return 0;
}
@@ -157,7 +184,7 @@ static int tolua_LOG(lua_State * tolua_S)
static int tolua_LOGINFO(lua_State * tolua_S)
{
- cMCLogger::GetInstance()->LogSimple(GetLogMessage(tolua_S).c_str(), cMCLogger::llInfo);
+ cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llInfo);
return 0;
}
@@ -167,7 +194,7 @@ static int tolua_LOGINFO(lua_State * tolua_S)
static int tolua_LOGWARN(lua_State * tolua_S)
{
- cMCLogger::GetInstance()->LogSimple(GetLogMessage(tolua_S).c_str(), cMCLogger::llWarning);
+ cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llWarning);
return 0;
}
@@ -177,7 +204,7 @@ static int tolua_LOGWARN(lua_State * tolua_S)
static int tolua_LOGERROR(lua_State * tolua_S)
{
- cMCLogger::GetInstance()->LogSimple(GetLogMessage(tolua_S).c_str(), cMCLogger::llError);
+ cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llError);
return 0;
}
@@ -272,11 +299,11 @@ static int tolua_cFile_GetFolderContents(lua_State * tolua_S)
-template<
+template <
class Ty1,
class Ty2,
bool (Ty1::*Func1)(const AString &, cItemCallback<Ty2> &)
- >
+>
static int tolua_DoWith(lua_State* tolua_S)
{
int NumArgs = lua_gettop(tolua_S) - 1; /* This includes 'self' */
@@ -366,7 +393,7 @@ static int tolua_DoWith(lua_State* tolua_S)
-template<
+template <
class Ty1,
class Ty2,
bool (Ty1::*Func1)(int, cItemCallback<Ty2> &)
@@ -456,7 +483,7 @@ static int tolua_DoWithID(lua_State* tolua_S)
-template<
+template <
class Ty1,
class Ty2,
bool (Ty1::*Func1)(int, int, int, cItemCallback<Ty2> &)
@@ -478,7 +505,6 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
int ItemX = ((int)tolua_tonumber(tolua_S, 2, 0));
int ItemY = ((int)tolua_tonumber(tolua_S, 3, 0));
int ItemZ = ((int)tolua_tonumber(tolua_S, 4, 0));
- LOG("x %i y %i z %i", ItemX, ItemY, ItemZ);
if (!lua_isfunction( tolua_S, 5))
{
return lua_do_error(tolua_S, "Error in function call '#funcname#': Expected a function for parameter #4");
@@ -552,7 +578,7 @@ static int tolua_DoWithXYZ(lua_State* tolua_S)
-template<
+template <
class Ty1,
class Ty2,
bool (Ty1::*Func1)(int, int, cItemCallback<Ty2> &)
@@ -648,7 +674,80 @@ static int tolua_ForEachInChunk(lua_State * tolua_S)
-template<
+template <
+ class Ty1,
+ class Ty2,
+ bool (Ty1::*Func1)(const cBoundingBox &, cItemCallback<Ty2> &)
+>
+static int tolua_ForEachInBox(lua_State * tolua_S)
+{
+ // Check params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserType(1, "cWorld") ||
+ !L.CheckParamUserType(2, "cBoundingBox") ||
+ !L.CheckParamFunction(3) ||
+ !L.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ Ty1 * Self = NULL;
+ cBoundingBox * Box = NULL;
+ L.GetStackValues(1, Self, Box);
+ if ((Self == NULL) || (Box == NULL))
+ {
+ LOGWARNING("Invalid world (%p) or boundingbox (%p)", Self, Box);
+ L.LogStackTrace();
+ return 0;
+ }
+
+ // Create a reference for the function:
+ cLuaState::cRef FnRef(L, 3);
+
+ // Callback wrapper for the Lua function:
+ class cLuaCallback : public cItemCallback<Ty2>
+ {
+ public:
+ cLuaCallback(cLuaState & a_LuaState, cLuaState::cRef & a_FuncRef) :
+ m_LuaState(a_LuaState),
+ m_FnRef(a_FuncRef)
+ {}
+
+ private:
+ // cItemCallback<Ty2> overrides:
+ virtual bool Item(Ty2 * a_Item) override
+ {
+ bool res = false;
+ if (!m_LuaState.Call(m_FnRef, a_Item, cLuaState::Return, res))
+ {
+ LOGWARNING("Failed to call Lua callback");
+ m_LuaState.LogStackTrace();
+ return true; // Abort enumeration
+ }
+
+ return res;
+ }
+ cLuaState & m_LuaState;
+ cLuaState::cRef & m_FnRef;
+ } Callback(L, FnRef);
+
+ bool bRetVal = (Self->*Func1)(*Box, Callback);
+
+ FnRef.UnRef();
+
+ /* Push return value on stack */
+ tolua_pushboolean(tolua_S, bRetVal);
+ return 1;
+}
+
+
+
+
+
+template <
class Ty1,
class Ty2,
bool (Ty1::*Func1)(cItemCallback<Ty2> &)
@@ -1775,49 +1874,30 @@ static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
-static int tolua_cPlayer_GetGroups(lua_State * tolua_S)
+static int tolua_cPlayer_GetPermissions(lua_State * tolua_S)
{
- cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
-
- const cPlayer::GroupList & AllGroups = self->GetGroups();
+ // Function signature: cPlayer:GetPermissions() -> {permissions-array}
- lua_createtable(tolua_S, (int)AllGroups.size(), 0);
- int newTable = lua_gettop(tolua_S);
- int index = 1;
- cPlayer::GroupList::const_iterator iter = AllGroups.begin();
- while (iter != AllGroups.end())
+ // Check the params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserType(1, "cPlayer") ||
+ !L.CheckParamEnd (2)
+ )
{
- const cGroup * Group = *iter;
- tolua_pushusertype(tolua_S, (void *)Group, "const cGroup");
- lua_rawseti(tolua_S, newTable, index);
- ++iter;
- ++index;
+ return 0;
}
- return 1;
-}
-
-
-
-
-static int tolua_cPlayer_GetResolvedPermissions(lua_State * tolua_S)
-{
- cPlayer * self = (cPlayer*) tolua_tousertype(tolua_S, 1, NULL);
-
- cPlayer::StringList AllPermissions = self->GetResolvedPermissions();
-
- lua_createtable(tolua_S, (int)AllPermissions.size(), 0);
- int newTable = lua_gettop(tolua_S);
- int index = 1;
- cPlayer::StringList::iterator iter = AllPermissions.begin();
- while (iter != AllPermissions.end())
+ // Get the params:
+ cPlayer * self = (cPlayer *)tolua_tousertype(tolua_S, 1, NULL);
+ if (self == NULL)
{
- std::string & Permission = *iter;
- lua_pushlstring(tolua_S, Permission.c_str(), Permission.length());
- lua_rawseti(tolua_S, newTable, index);
- ++iter;
- ++index;
+ LOGWARNING("%s: invalid self (%p)", __FUNCTION__, self);
+ return 0;
}
+
+ // Push the permissions:
+ L.Push(self->GetPermissions());
return 1;
}
@@ -1874,6 +1954,34 @@ static int tolua_cPlayer_OpenWindow(lua_State * tolua_S)
+static int tolua_cPlayer_PermissionMatches(lua_State * tolua_S)
+{
+ // Function signature: cPlayer:PermissionMatches(PermissionStr, TemplateStr) -> bool
+
+ // Check the params:
+ cLuaState L(tolua_S);
+ if (
+ !L.CheckParamUserTable(1, "cPlayer") ||
+ !L.CheckParamString (2, 3) ||
+ !L.CheckParamEnd (4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString Permission, Template;
+ L.GetStackValues(2, Permission, Template);
+
+ // Push the result of the match:
+ L.Push(cPlayer::PermissionMatches(StringSplit(Permission, "."), StringSplit(Template, ".")));
+ return 1;
+}
+
+
+
+
+
template <
class OBJTYPE,
void (OBJTYPE::*SetCallback)(cPluginLua * a_Plugin, int a_FnRef)
@@ -2100,6 +2208,62 @@ static int tolua_cWebAdmin_GetPlugins(lua_State * tolua_S)
+/** Binding for cWebAdmin::GetHTMLEscapedString.
+Manual code required because ToLua generates an extra return value */
+static int tolua_AllToLua_cWebAdmin_GetHTMLEscapedString(lua_State * tolua_S)
+{
+ // Check the param types:
+ cLuaState S(tolua_S);
+ if (
+ !S.CheckParamUserTable(1, "cWebAdmin") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the parameters:
+ AString Input;
+ S.GetStackValue(2, Input);
+
+ // Convert and return:
+ S.Push(cWebAdmin::GetHTMLEscapedString(Input));
+ return 1;
+}
+
+
+
+
+
+/** Binding for cWebAdmin::GetURLEncodedString.
+Manual code required because ToLua generates an extra return value */
+static int tolua_AllToLua_cWebAdmin_GetURLEncodedString(lua_State * tolua_S)
+{
+ // Check the param types:
+ cLuaState S(tolua_S);
+ if (
+ !S.CheckParamUserTable(1, "cWebAdmin") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the parameters:
+ AString Input;
+ S.GetStackValue(2, Input);
+
+ // Convert and return:
+ S.Push(cWebAdmin::GetURLEncodedString(Input));
+ return 1;
+}
+
+
+
+
+
static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S)
{
cWebPlugin* self = (cWebPlugin*) tolua_tousertype(tolua_S, 1, NULL);
@@ -2156,6 +2320,221 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L)
+static int tolua_cMojangAPI_AddPlayerNameToUUIDMapping(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cMojangAPI") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamString(3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Retrieve the parameters:
+ AString UUID, PlayerName;
+ S.GetStackValue(2, PlayerName);
+ S.GetStackValue(3, UUID);
+
+ // Store in the cache:
+ cRoot::Get()->GetMojangAPI().AddPlayerNameToUUIDMapping(PlayerName, UUID);
+ return 0;
+}
+
+
+
+
+
+static int tolua_cMojangAPI_GetPlayerNameFromUUID(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cMojangAPI") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ AString UUID;
+ S.GetStackValue(2, UUID);
+
+ // If the UseOnlyCached param was given, read it; default to false
+ bool ShouldUseCacheOnly = false;
+ if (lua_gettop(L) == 3)
+ {
+ ShouldUseCacheOnly = (lua_toboolean(L, 3) != 0);
+ lua_pop(L, 1);
+ }
+
+ // Return the PlayerName:
+ AString PlayerName = cRoot::Get()->GetMojangAPI().GetPlayerNameFromUUID(UUID, ShouldUseCacheOnly);
+ S.Push(PlayerName);
+ return 1;
+}
+
+
+
+
+
+static int tolua_cMojangAPI_GetUUIDFromPlayerName(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cMojangAPI") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ AString PlayerName;
+ S.GetStackValue(2, PlayerName);
+
+ // If the UseOnlyCached param was given, read it; default to false
+ bool ShouldUseCacheOnly = false;
+ if (lua_gettop(L) == 3)
+ {
+ ShouldUseCacheOnly = (lua_toboolean(L, 3) != 0);
+ lua_pop(L, 1);
+ }
+
+ // Return the UUID:
+ AString UUID = cRoot::Get()->GetMojangAPI().GetUUIDFromPlayerName(PlayerName, ShouldUseCacheOnly);
+ S.Push(UUID);
+ return 1;
+}
+
+
+
+
+
+static int tolua_cMojangAPI_GetUUIDsFromPlayerNames(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cMojangAPI") ||
+ !S.CheckParamTable(2) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Convert the input table into AStringVector:
+ AStringVector PlayerNames;
+ int NumNames = luaL_getn(L, 2);
+ PlayerNames.reserve(NumNames);
+ for (int i = 1; i <= NumNames; i++)
+ {
+ lua_rawgeti(L, 2, i);
+ AString Name;
+ S.GetStackValue(-1, Name);
+ if (!Name.empty())
+ {
+ PlayerNames.push_back(Name);
+ }
+ lua_pop(L, 1);
+ }
+
+ // If the UseOnlyCached param was given, read it; default to false
+ bool ShouldUseCacheOnly = false;
+ if (lua_gettop(L) == 3)
+ {
+ ShouldUseCacheOnly = (lua_toboolean(L, 3) != 0);
+ lua_pop(L, 1);
+ }
+
+ // Push the output table onto the stack:
+ lua_newtable(L);
+
+ // Get the UUIDs:
+ AStringVector UUIDs = cRoot::Get()->GetMojangAPI().GetUUIDsFromPlayerNames(PlayerNames, ShouldUseCacheOnly);
+ if (UUIDs.size() != PlayerNames.size())
+ {
+ // A hard error has occured while processing the request, no UUIDs were returned. Return an empty table:
+ return 1;
+ }
+
+ // Convert to output table, PlayerName -> UUID:
+ size_t len = UUIDs.size();
+ for (size_t i = 0; i < len; i++)
+ {
+ if (UUIDs[i].empty())
+ {
+ // No UUID was provided for PlayerName[i], skip it in the resulting table
+ continue;
+ }
+ lua_pushlstring(L, UUIDs[i].c_str(), UUIDs[i].length());
+ lua_setfield(L, 3, PlayerNames[i].c_str());
+ }
+ return 1;
+}
+
+
+
+
+
+static int tolua_cMojangAPI_MakeUUIDDashed(lua_State * L)
+{
+ // Function signature: cMojangAPI:MakeUUIDDashed(UUID) -> string
+
+ // Check params:
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cMojangAPI") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString UUID;
+ S.GetStackValue(2, UUID);
+
+ // Push the result:
+ S.Push(cRoot::Get()->GetMojangAPI().MakeUUIDDashed(UUID));
+ return 1;
+}
+
+
+
+
+
+static int tolua_cMojangAPI_MakeUUIDShort(lua_State * L)
+{
+ // Function signature: cMojangAPI:MakeUUIDShort(UUID) -> string
+
+ // Check params:
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cMojangAPI") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString UUID;
+ S.GetStackValue(2, UUID);
+
+ // Push the result:
+ S.Push(cRoot::Get()->GetMojangAPI().MakeUUIDShort(UUID));
+ return 1;
+}
+
+
+
+
+
static int Lua_ItemGrid_GetSlotCoords(lua_State * L)
{
tolua_Error tolua_err;
@@ -2349,7 +2728,7 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
// Get the recipe for the input
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
- const cFurnaceRecipe::Recipe * Recipe = FR->GetRecipeFrom(*Input);
+ const cFurnaceRecipe::cRecipe * Recipe = FR->GetRecipeFrom(*Input);
if (Recipe == NULL)
{
// There is no such furnace recipe for this input, return no value
@@ -2942,6 +3321,7 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)
void ManualBindings::Bind(lua_State * tolua_S)
{
tolua_beginmodule(tolua_S, NULL);
+ tolua_function(tolua_S, "Clamp", tolua_Clamp);
tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim);
tolua_function(tolua_S, "LOG", tolua_LOG);
@@ -2996,6 +3376,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_beginmodule(tolua_S, "cWorld");
tolua_function(tolua_S, "ChunkStay", tolua_cWorld_ChunkStay);
tolua_function(tolua_S, "DoWithBlockEntityAt", tolua_DoWithXYZ<cWorld, cBlockEntity, &cWorld::DoWithBlockEntityAt>);
+ tolua_function(tolua_S, "DoWithBeaconAt", tolua_DoWithXYZ<cWorld, cBeaconEntity, &cWorld::DoWithBeaconAt>);
tolua_function(tolua_S, "DoWithChestAt", tolua_DoWithXYZ<cWorld, cChestEntity, &cWorld::DoWithChestAt>);
tolua_function(tolua_S, "DoWithDispenserAt", tolua_DoWithXYZ<cWorld, cDispenserEntity, &cWorld::DoWithDispenserAt>);
tolua_function(tolua_S, "DoWithDropSpenserAt", tolua_DoWithXYZ<cWorld, cDropSpenserEntity, &cWorld::DoWithDropSpenserAt>);
@@ -3011,6 +3392,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "ForEachBlockEntityInChunk", tolua_ForEachInChunk<cWorld, cBlockEntity, &cWorld::ForEachBlockEntityInChunk>);
tolua_function(tolua_S, "ForEachChestInChunk", tolua_ForEachInChunk<cWorld, cChestEntity, &cWorld::ForEachChestInChunk>);
tolua_function(tolua_S, "ForEachEntity", tolua_ForEach< cWorld, cEntity, &cWorld::ForEachEntity>);
+ tolua_function(tolua_S, "ForEachEntityInBox", tolua_ForEachInBox< cWorld, cEntity, &cWorld::ForEachEntityInBox>);
tolua_function(tolua_S, "ForEachEntityInChunk", tolua_ForEachInChunk<cWorld, cEntity, &cWorld::ForEachEntityInChunk>);
tolua_function(tolua_S, "ForEachFurnaceInChunk", tolua_ForEachInChunk<cWorld, cFurnaceEntity, &cWorld::ForEachFurnaceInChunk>);
tolua_function(tolua_S, "ForEachPlayer", tolua_ForEach< cWorld, cPlayer, &cWorld::ForEachPlayer>);
@@ -3050,9 +3432,9 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cPlayer");
- tolua_function(tolua_S, "GetGroups", tolua_cPlayer_GetGroups);
- tolua_function(tolua_S, "GetResolvedPermissions", tolua_cPlayer_GetResolvedPermissions);
- tolua_function(tolua_S, "OpenWindow", tolua_cPlayer_OpenWindow);
+ tolua_function(tolua_S, "GetPermissions", tolua_cPlayer_GetPermissions);
+ tolua_function(tolua_S, "OpenWindow", tolua_cPlayer_OpenWindow);
+ tolua_function(tolua_S, "PermissionMatches", tolua_cPlayer_PermissionMatches);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cLuaWindow");
@@ -3075,7 +3457,9 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cWebAdmin");
- tolua_function(tolua_S, "GetPlugins", tolua_cWebAdmin_GetPlugins);
+ tolua_function(tolua_S, "GetHTMLEscapedString", tolua_AllToLua_cWebAdmin_GetHTMLEscapedString);
+ tolua_function(tolua_S, "GetPlugins", tolua_cWebAdmin_GetPlugins);
+ tolua_function(tolua_S, "GetURLEncodedString", tolua_AllToLua_cWebAdmin_GetURLEncodedString);
tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cWebPlugin");
@@ -3088,11 +3472,22 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage);
tolua_endmodule(tolua_S);
+ tolua_beginmodule(tolua_S, "cMojangAPI");
+ tolua_function(tolua_S, "AddPlayerNameToUUIDMapping", tolua_cMojangAPI_AddPlayerNameToUUIDMapping);
+ tolua_function(tolua_S, "GetPlayerNameFromUUID", tolua_cMojangAPI_GetPlayerNameFromUUID);
+ tolua_function(tolua_S, "GetUUIDFromPlayerName", tolua_cMojangAPI_GetUUIDFromPlayerName);
+ tolua_function(tolua_S, "GetUUIDsFromPlayerNames", tolua_cMojangAPI_GetUUIDsFromPlayerNames);
+ tolua_function(tolua_S, "MakeUUIDDashed", tolua_cMojangAPI_MakeUUIDDashed);
+ tolua_function(tolua_S, "MakeUUIDShort", tolua_cMojangAPI_MakeUUIDShort);
+ tolua_endmodule(tolua_S);
+
tolua_beginmodule(tolua_S, "cItemGrid");
tolua_function(tolua_S, "GetSlotCoords", Lua_ItemGrid_GetSlotCoords);
tolua_endmodule(tolua_S);
tolua_function(tolua_S, "md5", tolua_md5);
+
+ BindRankManager(tolua_S);
tolua_endmodule(tolua_S);
}
diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h
index 36161c6a2..1b6e65654 100644
--- a/src/Bindings/ManualBindings.h
+++ b/src/Bindings/ManualBindings.h
@@ -1,8 +1,24 @@
#pragma once
struct lua_State;
+
+
+
+
+
+/** Provides namespace for the bindings. */
class ManualBindings
{
public:
- static void Bind( lua_State* tolua_S);
+ /** Binds all the manually implemented functions to tolua_S. */
+ static void Bind(lua_State * tolua_S);
+
+protected:
+ /** Binds the manually implemented cRankManager glue code to tolua_S.
+ Implemented in ManualBindings_RankManager.cpp. */
+ static void BindRankManager(lua_State * tolua_S);
};
+
+
+
+
diff --git a/src/Bindings/ManualBindings_RankManager.cpp b/src/Bindings/ManualBindings_RankManager.cpp
new file mode 100644
index 000000000..3c58a0a92
--- /dev/null
+++ b/src/Bindings/ManualBindings_RankManager.cpp
@@ -0,0 +1,1090 @@
+
+// ManualBindings_RankManager.cpp
+
+// Implements the cRankManager Lua bindings
+
+#include "Globals.h"
+#include "ManualBindings.h"
+#include "../Root.h"
+#include "tolua++/include/tolua++.h"
+#include "LuaState.h"
+
+
+
+
+
+/** Binds cRankManager::AddGroup */
+static int tolua_cRankManager_AddGroup(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:AddGroup(GroupName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Read the params:
+ AString GroupName;
+ S.GetStackValue(2, GroupName);
+
+ // Add the group:
+ cRoot::Get()->GetRankManager().AddGroup(GroupName);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::AddGroupToRank */
+static int tolua_cRankManager_AddGroupToRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:AddGroupToRank(GroupName, RankName) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Read the params:
+ AString GroupName, RankName;
+ S.GetStackValues(2, GroupName, RankName);
+
+ // Add the group to the rank:
+ S.Push(cRoot::Get()->GetRankManager().AddGroupToRank(GroupName, RankName));
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::AddPermissionToGroup */
+static int tolua_cRankManager_AddPermissionToGroup(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:AddPermissionToGroup(Permission, GroupName) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Read the params:
+ AString GroupName, Permission;
+ S.GetStackValues(2, Permission, GroupName);
+
+ // Add the group to the rank:
+ S.Push(cRoot::Get()->GetRankManager().AddPermissionToGroup(Permission, GroupName));
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::AddRank */
+static int tolua_cRankManager_AddRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:AddRank(RankName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 5) ||
+ !S.CheckParamEnd(6)
+ )
+ {
+ return 0;
+ }
+
+ // Read the params:
+ AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
+ S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
+
+ // Add the rank:
+ cRoot::Get()->GetRankManager().AddRank(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::ClearPlayerRanks */
+static int tolua_cRankManager_ClearPlayerRanks(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Remove all players:
+ cRoot::Get()->GetRankManager().ClearPlayerRanks();
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetAllGroups */
+static int tolua_cRankManager_GetAllGroups(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetAllGroups() -> arraytable of GroupNames
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Get the groups:
+ AStringVector Groups = cRoot::Get()->GetRankManager().GetAllGroups();
+
+ // Push the results:
+ S.Push(Groups);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetAllPermissions */
+static int tolua_cRankManager_GetAllPermissions(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetAllPermissions() -> arraytable of Permissions
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Get the permissions:
+ AStringVector Permissions = cRoot::Get()->GetRankManager().GetAllPermissions();
+
+ // Push the results:
+ S.Push(Permissions);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetAllPlayerUUIDs */
+static int tolua_cRankManager_GetAllPlayerUUIDs(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetAllPlayerUUIDs() -> arraytable of Player UUID's
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Get the player uuid's:
+ AStringVector Players = cRoot::Get()->GetRankManager().GetAllPlayerUUIDs();
+
+ // Push the results:
+ S.Push(Players);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetAllRanks */
+static int tolua_cRankManager_GetAllRanks(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetAllRanks() -> arraytable of RankNames
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Get the ranks:
+ AStringVector Ranks = cRoot::Get()->GetRankManager().GetAllRanks();
+
+ // Push the results:
+ S.Push(Ranks);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetDefaultRank */
+static int tolua_cRankManager_GetDefaultRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetDefaultRank() -> string
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Return the rank name:
+ S.Push(cRoot::Get()->GetRankManager().GetDefaultRank());
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetGroupPermissions */
+static int tolua_cRankManager_GetGroupPermissions(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetGroupPermissions(GroupName) -> arraytable of permissions
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString GroupName;
+ S.GetStackValue(2, GroupName);
+
+ // Get the permissions:
+ AStringVector Permissions = cRoot::Get()->GetRankManager().GetGroupPermissions(GroupName);
+
+ // Push the results:
+ S.Push(Permissions);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetPlayerGroups */
+static int tolua_cRankManager_GetPlayerGroups(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetPlayerGroups(PlayerUUID) -> arraytable of GroupNames
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Get the groups:
+ AStringVector Groups = cRoot::Get()->GetRankManager().GetPlayerGroups(PlayerUUID);
+
+ // Push the results:
+ S.Push(Groups);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetPlayerMsgVisuals */
+static int tolua_cRankManager_GetPlayerMsgVisuals(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetPlayerMsgVisuals(PlayerUUID) -> string, string, string
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Get the permissions:
+ AString MsgPrefix, MsgSuffix, MsgNameColorCode;
+ if (!cRoot::Get()->GetRankManager().GetPlayerMsgVisuals(PlayerUUID, MsgPrefix, MsgSuffix, MsgNameColorCode))
+ {
+ return 0;
+ }
+
+ // Push the results:
+ S.Push(MsgPrefix);
+ S.Push(MsgSuffix);
+ S.Push(MsgNameColorCode);
+ return 3;
+}
+
+
+
+
+
+/** Binds cRankManager::GetPlayerPermissions */
+static int tolua_cRankManager_GetPlayerPermissions(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetPlayerPermissions(PlayerUUID) -> arraytable of permissions
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Get the permissions:
+ AStringVector Permissions = cRoot::Get()->GetRankManager().GetPlayerPermissions(PlayerUUID);
+
+ // Push the results:
+ S.Push(Permissions);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetPlayerRankName */
+static int tolua_cRankManager_GetPlayerRankName(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetPlayerRankName(PlayerUUID) -> string
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Get the rank name:
+ AString RankName = cRoot::Get()->GetRankManager().GetPlayerRankName(PlayerUUID);
+
+ // Push the result:
+ S.Push(RankName);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetPlayerName */
+static int tolua_cRankManager_GetPlayerName(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetPlayerName(PlayerUUID) -> string
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Get the player name:
+ AString PlayerName = cRoot::Get()->GetRankManager().GetPlayerName(PlayerUUID);
+
+ // Push the result:
+ S.Push(PlayerName);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetRankGroups */
+static int tolua_cRankManager_GetRankGroups(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetRankGroups(RankName) -> arraytable of groupnames
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString RankName;
+ S.GetStackValue(2, RankName);
+
+ // Get the groups:
+ AStringVector Groups = cRoot::Get()->GetRankManager().GetRankGroups(RankName);
+
+ // Push the results:
+ S.Push(Groups);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetRankPermissions */
+static int tolua_cRankManager_GetRankPermissions(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetRankPermissions(RankName) -> arraytable of permissions
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString RankName;
+ S.GetStackValue(2, RankName);
+
+ // Get the permissions:
+ AStringVector Permissions = cRoot::Get()->GetRankManager().GetRankPermissions(RankName);
+
+ // Push the results:
+ S.Push(Permissions);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::GetRankVisuals */
+static int tolua_cRankManager_GetRankVisuals(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GetRankVisuals(RankName) -> MsgPrefix, MsgSuffix, MsgNameColorCode
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString RankName;
+ S.GetStackValue(2, RankName);
+
+ // Get the visuals:
+ AString MsgPrefix, MsgSuffix, MsgNameColorCode;
+ if (!cRoot::Get()->GetRankManager().GetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode))
+ {
+ // No such rank, return nothing:
+ return 0;
+ }
+
+ // Push the results:
+ S.Push(MsgPrefix);
+ S.Push(MsgSuffix);
+ S.Push(MsgNameColorCode);
+ return 3;
+}
+
+
+
+
+
+/** Binds cRankManager::GroupExists */
+static int tolua_cRankManager_GroupExists(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:GroupExists(GroupName) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString GroupName;
+ S.GetStackValue(2, GroupName);
+
+ // Get the response:
+ bool res = cRoot::Get()->GetRankManager().GroupExists(GroupName);
+
+ // Push the result:
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::IsGroupInRank */
+static int tolua_cRankManager_IsGroupInRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:IsGroupInRank(GroupName, RankName) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString GroupName, RankName;
+ S.GetStackValues(2, GroupName, RankName);
+
+ // Get the response:
+ bool res = cRoot::Get()->GetRankManager().IsGroupInRank(GroupName, RankName);
+
+ // Push the result:
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::IsPermissionInGroup */
+static int tolua_cRankManager_IsPermissionInGroup(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:IsPermissionInGroup(Permission, GroupName) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString GroupName, Permission;
+ S.GetStackValues(2, Permission, GroupName);
+
+ // Get the response:
+ bool res = cRoot::Get()->GetRankManager().IsPermissionInGroup(Permission, GroupName);
+
+ // Push the result:
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::IsPlayerRankSet */
+static int tolua_cRankManager_IsPlayerRankSet(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:IsPlayerRankSet(PlayerUUID) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Get the response:
+ bool res = cRoot::Get()->GetRankManager().IsPlayerRankSet(PlayerUUID);
+
+ // Push the result:
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::RankExists */
+static int tolua_cRankManager_RankExists(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RankExists(RankName) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString RankName;
+ S.GetStackValue(2, RankName);
+
+ // Get the response:
+ bool res = cRoot::Get()->GetRankManager().RankExists(RankName);
+
+ // Push the result:
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::RemoveGroup */
+static int tolua_cRankManager_RemoveGroup(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RemoveGroup(GroupName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString GroupName;
+ S.GetStackValue(2, GroupName);
+
+ // Remove the group:
+ cRoot::Get()->GetRankManager().RemoveGroup(GroupName);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::RemoveGroupFromRank */
+static int tolua_cRankManager_RemoveGroupFromRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RemoveGroupFromRank(GroupName, RankName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString GroupName, RankName;
+ S.GetStackValues(2, GroupName, RankName);
+
+ // Remove the group:
+ cRoot::Get()->GetRankManager().RemoveGroupFromRank(GroupName, RankName);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::RemovePermissionFromGroup */
+static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RemovePermissionFromGroup(Permission, GroupName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString GroupName, Permission;
+ S.GetStackValues(2, Permission, GroupName);
+
+ // Remove the group:
+ cRoot::Get()->GetRankManager().RemovePermissionFromGroup(Permission, GroupName);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::RemovePlayerRank */
+static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RemovePlayerRank(PlayerUUID)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Remove the player's rank:
+ cRoot::Get()->GetRankManager().RemovePlayerRank(PlayerUUID);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::RemoveRank */
+static int tolua_cRankManager_RemoveRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RemoveRank(RankName, [ReplacementRankName])
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ // Param 3 is otpional, defaults to nil -> empty string
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString RankName, ReplacementRankName;
+ S.GetStackValues(2, RankName, ReplacementRankName);
+
+ // Remove the rank:
+ cRoot::Get()->GetRankManager().RemoveRank(RankName, ReplacementRankName);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::RenameGroup */
+static int tolua_cRankManager_RenameGroup(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RenameGroup(OldName, NewName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString OldName, NewName;
+ S.GetStackValues(2, OldName, NewName);
+
+ // Remove the group:
+ bool res = cRoot::Get()->GetRankManager().RenameGroup(OldName, NewName);
+
+ // Push the result:
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::RenameRank */
+static int tolua_cRankManager_RenameRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:RenameRank(OldName, NewName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 3) ||
+ !S.CheckParamEnd(4)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString OldName, NewName;
+ S.GetStackValues(2, OldName, NewName);
+
+ // Remove the rank:
+ bool res = cRoot::Get()->GetRankManager().RenameRank(OldName, NewName);
+
+ // Push the result:
+ S.Push(res);
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::SetDefaultRank */
+static int tolua_cRankManager_SetDefaultRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:SetDefaultRank(RankName) -> bool
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString RankName;
+ S.GetStackValue(2, RankName);
+
+ // Set the rank, return the result:
+ S.Push(cRoot::Get()->GetRankManager().SetDefaultRank(RankName));
+ return 1;
+}
+
+
+
+
+
+/** Binds cRankManager::SetPlayerRank */
+static int tolua_cRankManager_SetPlayerRank(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:SetPlayerRank(PlayerUUID, PlayerName, RankName)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 4) ||
+ !S.CheckParamEnd(5)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID, PlayerName, RankName;
+ S.GetStackValues(2, PlayerUUID, PlayerName, RankName);
+
+ // Set the rank:
+ cRoot::Get()->GetRankManager().SetPlayerRank(PlayerUUID, PlayerName, RankName);
+ return 0;
+}
+
+
+
+
+
+/** Binds cRankManager::SetRankVisuals */
+static int tolua_cRankManager_SetRankVisuals(lua_State * L)
+{
+ // Function signature:
+ // cRankManager:SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2, 5) ||
+ !S.CheckParamEnd(6)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString RankName, MsgPrefix, MsgSuffix, MsgNameColorCode;
+ S.GetStackValues(2, RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
+
+ // Set the visuals:
+ cRoot::Get()->GetRankManager().SetRankVisuals(RankName, MsgPrefix, MsgSuffix, MsgNameColorCode);
+ return 0;
+}
+
+
+
+
+
+void ManualBindings::BindRankManager(lua_State * tolua_S)
+{
+ // Create the cRankManager class in the API:
+ tolua_usertype(tolua_S, "cRankManager");
+ tolua_cclass(tolua_S, "cRankManager", "cRankManager", "", NULL);
+
+ // Fill in the functions (alpha-sorted):
+ tolua_beginmodule(tolua_S, "cRankManager");
+ tolua_function(tolua_S, "AddGroup", tolua_cRankManager_AddGroup);
+ tolua_function(tolua_S, "AddGroupToRank", tolua_cRankManager_AddGroupToRank);
+ tolua_function(tolua_S, "AddPermissionToGroup", tolua_cRankManager_AddPermissionToGroup);
+ tolua_function(tolua_S, "AddRank", tolua_cRankManager_AddRank);
+ tolua_function(tolua_S, "ClearPlayerRanks", tolua_cRankManager_ClearPlayerRanks);
+ tolua_function(tolua_S, "GetAllGroups", tolua_cRankManager_GetAllGroups);
+ tolua_function(tolua_S, "GetAllPermissions", tolua_cRankManager_GetAllPermissions);
+ tolua_function(tolua_S, "GetAllPlayerUUIDs", tolua_cRankManager_GetAllPlayerUUIDs);
+ tolua_function(tolua_S, "GetAllRanks", tolua_cRankManager_GetAllRanks);
+ tolua_function(tolua_S, "GetDefaultRank", tolua_cRankManager_GetDefaultRank);
+ tolua_function(tolua_S, "GetGroupPermissions", tolua_cRankManager_GetGroupPermissions);
+ tolua_function(tolua_S, "GetPlayerGroups", tolua_cRankManager_GetPlayerGroups);
+ tolua_function(tolua_S, "GetPlayerMsgVisuals", tolua_cRankManager_GetPlayerMsgVisuals);
+ tolua_function(tolua_S, "GetPlayerPermissions", tolua_cRankManager_GetPlayerPermissions);
+ tolua_function(tolua_S, "GetPlayerRankName", tolua_cRankManager_GetPlayerRankName);
+ tolua_function(tolua_S, "GetPlayerName", tolua_cRankManager_GetPlayerName);
+ tolua_function(tolua_S, "GetRankGroups", tolua_cRankManager_GetRankGroups);
+ tolua_function(tolua_S, "GetRankPermissions", tolua_cRankManager_GetRankPermissions);
+ tolua_function(tolua_S, "GetRankVisuals", tolua_cRankManager_GetRankVisuals);
+ tolua_function(tolua_S, "GroupExists", tolua_cRankManager_GroupExists);
+ tolua_function(tolua_S, "IsGroupInRank", tolua_cRankManager_IsGroupInRank);
+ tolua_function(tolua_S, "IsPermissionInGroup", tolua_cRankManager_IsPermissionInGroup);
+ tolua_function(tolua_S, "IsPlayerRankSet", tolua_cRankManager_IsPlayerRankSet);
+ tolua_function(tolua_S, "RankExists", tolua_cRankManager_RankExists);
+ tolua_function(tolua_S, "RemoveGroup", tolua_cRankManager_RemoveGroup);
+ tolua_function(tolua_S, "RemoveGroupFromRank", tolua_cRankManager_RemoveGroupFromRank);
+ tolua_function(tolua_S, "RemovePermissionFromGroup", tolua_cRankManager_RemovePermissionFromGroup);
+ tolua_function(tolua_S, "RemovePlayerRank", tolua_cRankManager_RemovePlayerRank);
+ tolua_function(tolua_S, "RemoveRank", tolua_cRankManager_RemoveRank);
+ tolua_function(tolua_S, "RenameGroup", tolua_cRankManager_RenameGroup);
+ tolua_function(tolua_S, "RenameRank", tolua_cRankManager_RenameRank);
+ tolua_function(tolua_S, "SetDefaultRank", tolua_cRankManager_SetDefaultRank);
+ tolua_function(tolua_S, "SetPlayerRank", tolua_cRankManager_SetPlayerRank);
+ tolua_function(tolua_S, "SetRankVisuals", tolua_cRankManager_SetRankVisuals);
+ tolua_endmodule(tolua_S);
+}
+
+
+
+
diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h
index 39d53674b..fb22dd33e 100644
--- a/src/Bindings/Plugin.h
+++ b/src/Bindings/Plugin.h
@@ -1,23 +1,25 @@
#pragma once
-#include "PluginManager.h"
-
+#include "Defines.h"
+class cCommandOutputCallback;
+class cItems;
+class cHopperEntity;
+class cBlockEntityWithItems;
class cClientHandle;
-class cPlayer;
class cPickup;
-class cItem;
+class cPlayer;
+class cProjectileEntity;
class cEntity;
+class cMonster;
class cWorld;
class cChunkDesc;
struct TakeDamageInfo;
-// fwd: cPlayer.h
-class cPlayer;
// fwd: CraftingRecipes.h
class cCraftingGrid;
@@ -73,7 +75,7 @@ public:
virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) = 0;
virtual bool OnPlayerJoined (cPlayer & a_Player) = 0;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0;
- virtual bool OnPlayerMoved (cPlayer & a_Player) = 0;
+ virtual bool OnPlayerMoving (cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition) = 0;
virtual bool OnPlayerPlacedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
virtual bool OnPlayerPlacingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
virtual bool OnPlayerRightClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0;
@@ -91,6 +93,7 @@ public:
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) = 0;
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0;
+ virtual bool OnServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon) = 0;
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0;
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0;
virtual bool OnSpawningEntity (cWorld & a_World, cEntity & a_Entity) = 0;
diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp
index 0f3f25d75..2629eb641 100644
--- a/src/Bindings/PluginLua.cpp
+++ b/src/Bindings/PluginLua.cpp
@@ -12,10 +12,12 @@
#endif
#include "PluginLua.h"
#include "../CommandOutput.h"
+#include "PluginManager.h"
+#include "../Item.h"
extern "C"
{
- #include "lua/src/lualib.h"
+ #include "lua/src/lauxlib.h"
}
#undef TOLUA_TEMPLATE_BIND
@@ -835,14 +837,14 @@ bool cPluginLua::OnPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_Block
-bool cPluginLua::OnPlayerMoved(cPlayer & a_Player)
+bool cPluginLua::OnPlayerMoving(cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition)
{
cCSLock Lock(m_CriticalSection);
bool res = false;
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_MOVING];
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
{
- m_LuaState.Call((int)(**itr), &a_Player, cLuaState::Return, res);
+ m_LuaState.Call((int)(**itr), &a_Player, a_OldPosition, a_NewPosition, cLuaState::Return, res);
if (res)
{
return true;
@@ -1193,6 +1195,26 @@ bool cPluginLua::OnProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity
+bool cPluginLua::OnServerPing(cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon)
+{
+ cCSLock Lock(m_CriticalSection);
+ bool res = false;
+ cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_SERVER_PING];
+ for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
+ {
+ m_LuaState.Call((int)(**itr), &a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon, cLuaState::Return, res, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon);
+ if (res)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginLua::OnSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
{
cCSLock Lock(m_CriticalSection);
@@ -1570,6 +1592,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType)
case cPluginManager::HOOK_PLUGINS_LOADED: return "OnPluginsLoaded";
case cPluginManager::HOOK_POST_CRAFTING: return "OnPostCrafting";
case cPluginManager::HOOK_PRE_CRAFTING: return "OnPreCrafting";
+ case cPluginManager::HOOK_SERVER_PING: return "OnServerPing";
case cPluginManager::HOOK_SPAWNED_ENTITY: return "OnSpawnedEntity";
case cPluginManager::HOOK_SPAWNED_MONSTER: return "OnSpawnedMonster";
case cPluginManager::HOOK_SPAWNING_ENTITY: return "OnSpawningEntity";
diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h
index 2cea644c1..eda65b76c 100644
--- a/src/Bindings/PluginLua.h
+++ b/src/Bindings/PluginLua.h
@@ -98,8 +98,8 @@ public:
virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override;
virtual bool OnPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel) override;
virtual bool OnPlayerJoined (cPlayer & a_Player) override;
- virtual bool OnPlayerMoved (cPlayer & a_Player) override;
virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override;
+ virtual bool OnPlayerMoving (cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition) override;
virtual bool OnPlayerPlacedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual bool OnPlayerPlacingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
virtual bool OnPlayerRightClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
@@ -117,6 +117,7 @@ public:
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos) override;
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override;
+ virtual bool OnServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon) override;
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override;
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override;
virtual bool OnSpawningEntity (cWorld & a_World, cEntity & a_Entity) override;
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 3560b8660..e0faa838a 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -4,12 +4,10 @@
#include "PluginManager.h"
#include "Plugin.h"
#include "PluginLua.h"
-#include "../WebAdmin.h"
#include "../Item.h"
#include "../Root.h"
#include "../Server.h"
#include "../CommandOutput.h"
-#include "../ChatColor.h"
#include "inifile/iniFile.h"
#include "../Entities/Player.h"
@@ -124,44 +122,58 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni)
// Check if the Plugins section exists.
int KeyNum = a_SettingsIni.FindKey("Plugins");
- // If it does, how many plugins are there?
- int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0);
-
if (KeyNum == -1)
{
InsertDefaultPlugins(a_SettingsIni);
+ KeyNum = a_SettingsIni.FindKey("Plugins");
}
- else if (NumPlugins > 0)
+
+ // How many plugins are there?
+ int NumPlugins = a_SettingsIni.GetNumValues(KeyNum);
+
+ for (int i = 0; i < NumPlugins; i++)
{
- for (int i = 0; i < NumPlugins; i++)
+ AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
+ if (ValueName.compare("Plugin") == 0)
{
- AString ValueName = a_SettingsIni.GetValueName(KeyNum, i);
- if (ValueName.compare("Plugin") == 0)
+ AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
+ if (!PluginFile.empty())
{
- AString PluginFile = a_SettingsIni.GetValue(KeyNum, i);
- if (!PluginFile.empty())
+ if (m_Plugins.find(PluginFile) != m_Plugins.end())
{
- if (m_Plugins.find(PluginFile) != m_Plugins.end())
- {
- LoadPlugin(PluginFile);
- }
+ LoadPlugin(PluginFile);
}
}
}
}
+
+ // Remove invalid plugins from the PluginMap.
+ for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();)
+ {
+ if (itr->second == NULL)
+ {
+ PluginMap::iterator thiz = itr;
+ ++thiz;
+ m_Plugins.erase(itr);
+ itr = thiz;
+ continue;
+ }
+ ++itr;
+ }
+
size_t NumLoadedPlugins = GetNumPlugins();
if (NumLoadedPlugins == 0)
{
LOG("-- No Plugins Loaded --");
}
- else if (NumLoadedPlugins > 1)
+ else if (NumLoadedPlugins == 1)
{
- LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
+ LOG("-- Loaded 1 Plugin --");
}
else
{
- LOG("-- Loaded 1 Plugin --");
+ LOG("-- Loaded %i Plugins --", (int)NumLoadedPlugins);
}
CallHookPluginsLoaded();
}
@@ -835,14 +847,14 @@ bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, i
-bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player)
+bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player, const Vector3d a_OldPosition, const Vector3d a_NewPosition)
{
FIND_HOOK(HOOK_PLAYER_MOVING);
VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnPlayerMoved(a_Player))
+ if ((*itr)->OnPlayerMoving(a_Player, a_OldPosition, a_NewPosition))
{
return true;
}
@@ -1175,6 +1187,25 @@ bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectil
+bool cPluginManager::CallHookServerPing(cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon)
+{
+ FIND_HOOK(HOOK_SERVER_PING);
+ VERIFY_HOOK;
+
+ for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
+ {
+ if ((*itr)->OnServerPing(a_ClientHandle, a_ServerDescription, a_OnlinePlayersCount, a_MaxPlayersCount, a_Favicon))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
{
FIND_HOOK(HOOK_SPAWNED_ENTITY);
diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h
index 44a94e316..fff3bc323 100644
--- a/src/Bindings/PluginManager.h
+++ b/src/Bindings/PluginManager.h
@@ -1,9 +1,8 @@
#pragma once
-#include "../Item.h"
-
+#include "Defines.h"
@@ -36,7 +35,6 @@ class cPickup;
// fwd: Pawn.h
struct TakeDamageInfo;
-class cPawn;
// fwd: CommandOutput.h
class cCommandOutputCallback;
@@ -49,6 +47,8 @@ class cBlockEntityWithItems;
+class cItems;
+
// tolua_begin
@@ -120,6 +120,7 @@ public:
HOOK_PRE_CRAFTING,
HOOK_PROJECTILE_HIT_BLOCK,
HOOK_PROJECTILE_HIT_ENTITY,
+ HOOK_SERVER_PING,
HOOK_SPAWNED_ENTITY,
HOOK_SPAWNED_MONSTER,
HOOK_SPAWNING_ENTITY,
@@ -206,7 +207,7 @@ public:
bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward);
bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel);
bool CallHookPlayerJoined (cPlayer & a_Player);
- bool CallHookPlayerMoving (cPlayer & a_Player);
+ bool CallHookPlayerMoving (cPlayer & a_Player, const Vector3d a_OldPosition, const Vector3d a_NewPosition);
bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status);
bool CallHookPlayerPlacedBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
bool CallHookPlayerPlacingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
@@ -225,6 +226,7 @@ public:
bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos);
bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
+ bool CallHookServerPing (cClientHandle & a_ClientHandle, AString & a_ServerDescription, int & a_OnlinePlayersCount, int & a_MaxPlayersCount, AString & a_Favicon);
bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity);
bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster);
bool CallHookSpawningEntity (cWorld & a_World, cEntity & a_Entity);
diff --git a/src/Bindings/WebPlugin.cpp b/src/Bindings/WebPlugin.cpp
index 1178c127a..eca1c74e6 100644
--- a/src/Bindings/WebPlugin.cpp
+++ b/src/Bindings/WebPlugin.cpp
@@ -3,7 +3,6 @@
#include "WebPlugin.h"
#include "../WebAdmin.h"
-#include "../Server.h"
#include "../Root.h"
@@ -81,7 +80,9 @@ std::pair< AString, AString > cWebPlugin::GetTabNameForRequest(const HTTPRequest
else // Otherwise show the first tab
{
if (GetTabs().size() > 0)
+ {
Tab = *GetTabs().begin();
+ }
}
if (Tab != NULL)
diff --git a/src/Bindings/WebPlugin.h b/src/Bindings/WebPlugin.h
index 46bc0cd2d..9b825b918 100644
--- a/src/Bindings/WebPlugin.h
+++ b/src/Bindings/WebPlugin.h
@@ -1,7 +1,6 @@
#pragma once
-struct lua_State;
struct HTTPRequest;
diff --git a/src/Bindings/gen_LuaState_Call.lua b/src/Bindings/gen_LuaState_Call.lua
index fb1797dc0..7f62573c7 100644
--- a/src/Bindings/gen_LuaState_Call.lua
+++ b/src/Bindings/gen_LuaState_Call.lua
@@ -13,7 +13,7 @@ separate the arguments from the return values, a special type of cLuaState::cRet
-print("Generating LuaState_Call.inc...")
+print("Generating LuaState_Call.inc . . .")
@@ -54,6 +54,7 @@ local Combinations =
{9, 2},
-- Special combinations:
+ {5, 5},
{7, 3},
{8, 3},
{9, 5},
@@ -108,7 +109,7 @@ local function WriteOverload(f, a_NumParams, a_NumReturns)
-- Write the function signature:
f:write("bool Call(")
- f:write("FnT a_Function")
+ f:write("const FnT & a_Function")
for i = 1, a_NumParams do
f:write(", ParamT", i, " a_Param", i)
end
@@ -182,6 +183,33 @@ for _, combination in ipairs(Combinations) do
WriteOverload(f, combination[1], combination[2])
end
+-- Generate the cLuaState::GetStackValues() multi-param templates:
+for i = 2, 6 do
+ f:write("/** Reads ", i, " consecutive values off the stack */\ntemplate <\n")
+
+ -- Write the template function header:
+ local txt = {}
+ for idx = 1, i do
+ table.insert(txt, "\ttypename ArgT" .. idx)
+ end
+ f:write(table.concat(txt, ",\n"))
+
+ -- Write the argument declarations:
+ txt = {}
+ f:write("\n>\nvoid GetStackValues(\n\tint a_BeginPos,\n")
+ for idx = 1, i do
+ table.insert(txt, "\tArgT" .. idx .. " & Arg" .. idx)
+ end
+ f:write(table.concat(txt, ",\n"))
+
+ -- Write the function body:
+ f:write("\n)\n{\n")
+ for idx = 1, i do
+ f:write("\tGetStackValue(a_BeginPos + ", idx - 1, ", Arg", idx, ");\n")
+ end
+ f:write("}\n\n\n\n\n\n")
+end
+
-- Close the generated file
f:close()
@@ -189,7 +217,7 @@ f:close()
-print("LuaState_Call.inc generated")
+print("LuaState_Call.inc generated.")