diff options
author | satoshinm <snmatsutake@yahoo.co.jp> | 2017-08-27 23:10:20 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2017-08-27 23:10:20 +0200 |
commit | 6bc503151746ea05842009983c7de932fa80cd03 (patch) | |
tree | a7ce87c25b2acb9c5f76cd1a25180b77ebf16f26 /src/Bindings | |
parent | Implement anvil chunk sparsing (diff) | |
download | cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.gz cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.bz2 cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.lz cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.xz cuberite-6bc503151746ea05842009983c7de932fa80cd03.tar.zst cuberite-6bc503151746ea05842009983c7de932fa80cd03.zip |
Diffstat (limited to 'src/Bindings')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 59 | ||||
-rw-r--r-- | src/Bindings/Plugin.h | 1 | ||||
-rw-r--r-- | src/Bindings/PluginLua.cpp | 10 | ||||
-rw-r--r-- | src/Bindings/PluginLua.h | 1 | ||||
-rw-r--r-- | src/Bindings/PluginManager.cpp | 18 | ||||
-rw-r--r-- | src/Bindings/PluginManager.h | 2 |
6 files changed, 91 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index c87e9ed20..ee9cb61e9 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -33,6 +33,7 @@ #include "../HTTP/UrlParser.h" #include "../Item.h" #include "../LineBlockTracer.h" +#include "../Server.h" #include "../Root.h" #include "../StringCompression.h" #include "../WebAdmin.h" @@ -2365,6 +2366,27 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L) +static int tolua_cClientHandle_GetForgeMods(lua_State * L) +{ + cLuaState S(L); + if ( + !S.CheckParamSelf("cClientHandle") || + !S.CheckParamEnd(2) + ) + { + return 0; + } + cClientHandle * Client; + S.GetStackValue(1, Client); + + S.Push(Client->GetForgeMods()); + return 1; +} + + + + + static int tolua_cClientHandle_GetUUID(lua_State * tolua_S) { // Check the params: @@ -3399,6 +3421,37 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S) +static int tolua_cServer_RegisterForgeMod(lua_State * a_LuaState) +{ + cLuaState L(a_LuaState); + if ( + !L.CheckParamSelf("cServer") || + !L.CheckParamString(2, 3) || + !L.CheckParamNumber(4) || + !L.CheckParamEnd(5) + ) + { + return 0; + } + + cServer * Server; + AString Name, Version; + UInt32 Protocol; + L.GetStackValues(1, Server, Name, Version, Protocol); + + if (!Server->RegisterForgeMod(Name, Version, Protocol)) + { + tolua_error(L, "duplicate Forge mod name registration", nullptr); + return 0; + } + + return 0; +} + + + + + static int tolua_cScoreboard_GetTeamNames(lua_State * L) { cLuaState S(L); @@ -4007,6 +4060,8 @@ void cManualBindings::Bind(lua_State * tolua_S) tolua_beginmodule(tolua_S, "cClientHandle"); tolua_constant(tolua_S, "MAX_VIEW_DISTANCE", cClientHandle::MAX_VIEW_DISTANCE); tolua_constant(tolua_S, "MIN_VIEW_DISTANCE", cClientHandle::MIN_VIEW_DISTANCE); + + tolua_function(tolua_S, "GetForgeMods", tolua_cClientHandle_GetForgeMods); tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage); tolua_function(tolua_S, "GetUUID", tolua_cClientHandle_GetUUID); tolua_function(tolua_S, "GenerateOfflineUUID", tolua_cClientHandle_GenerateOfflineUUID); @@ -4164,6 +4219,10 @@ void cManualBindings::Bind(lua_State * tolua_S) tolua_function(tolua_S, "GetTeamNames", tolua_cScoreboard_GetTeamNames); tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cServer"); + tolua_function(tolua_S, "RegisterForgeMod", tolua_cServer_RegisterForgeMod); + tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S, "cStringCompression"); tolua_function(tolua_S, "CompressStringZLIB", tolua_CompressStringZLIB); tolua_function(tolua_S, "UncompressStringZLIB", tolua_UncompressStringZLIB); diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 22e8f15e2..fc0e2b4fc 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -69,6 +69,7 @@ public: virtual bool OnKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage) = 0; virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) = 0; virtual bool OnLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) = 0; + virtual bool OnLoginForge (cClientHandle & a_Client, const AStringMap & a_Mods) = 0; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) = 0; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 5af336a95..9105f2555 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -550,6 +550,15 @@ bool cPluginLua::OnLogin(cClientHandle & a_Client, UInt32 a_ProtocolVersion, con +bool cPluginLua::OnLoginForge(cClientHandle & a_Client, const AStringMap & a_Mods) +{ + return CallSimpleHooks(cPluginManager::HOOK_LOGIN_FORGE, &a_Client, a_Mods); +} + + + + + bool cPluginLua::OnPlayerAnimation(cPlayer & a_Player, int a_Animation) { return CallSimpleHooks(cPluginManager::HOOK_PLAYER_ANIMATION, &a_Player, a_Animation); @@ -1059,6 +1068,7 @@ const char * cPluginLua::GetHookFnName(int a_HookType) case cPluginManager::HOOK_HANDSHAKE: return "OnHandshake"; case cPluginManager::HOOK_KILLING: return "OnKilling"; case cPluginManager::HOOK_LOGIN: return "OnLogin"; + case cPluginManager::HOOK_LOGIN_FORGE: return "OnLoginForge"; case cPluginManager::HOOK_PLAYER_BREAKING_BLOCK: return "OnPlayerBreakingBlock"; case cPluginManager::HOOK_PLAYER_BROKEN_BLOCK: return "OnPlayerBrokenBlock"; case cPluginManager::HOOK_PLAYER_EATING: return "OnPlayerEating"; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 4de5751e7..7904fe115 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -90,6 +90,7 @@ public: virtual bool OnKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage) override; virtual bool OnKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI) override; virtual bool OnLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username) override; + virtual bool OnLoginForge (cClientHandle & a_Client, const AStringMap & a_Mods) override; virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 1d977fcde..7c4712f0f 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -789,6 +789,24 @@ bool cPluginManager::CallHookLogin(cClientHandle & a_Client, UInt32 a_ProtocolVe +bool cPluginManager::CallHookLoginForge(cClientHandle & a_Client, AStringMap & a_Mods) +{ + FIND_HOOK(HOOK_LOGIN_FORGE) + VERIFY_HOOK; + + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnLoginForge(a_Client, a_Mods)) + { + return true; + } + } + return false; +} + + + + bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation) { diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index f3fc3551a..66f7d290a 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -102,6 +102,7 @@ public: HOOK_KILLED, HOOK_KILLING, HOOK_LOGIN, + HOOK_LOGIN_FORGE, HOOK_PLAYER_BREAKING_BLOCK, HOOK_PLAYER_BROKEN_BLOCK, HOOK_PLAYER_DESTROYED, @@ -248,6 +249,7 @@ public: bool CallHookKilled (cEntity & a_Victim, TakeDamageInfo & a_TDI, AString & a_DeathMessage); bool CallHookKilling (cEntity & a_Victim, cEntity * a_Killer, TakeDamageInfo & a_TDI); bool CallHookLogin (cClientHandle & a_Client, UInt32 a_ProtocolVersion, const AString & a_Username); + bool CallHookLoginForge (cClientHandle & a_Client, AStringMap & a_Mods); bool CallHookPlayerAnimation (cPlayer & a_Player, int a_Animation); bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); |