1
0

Added cPlugin_NewLua::GetLocalDirectory() and exported it to Lua so plugins can store their settings in their own folder.

Core now stores banned players and whitelist data in its own directory

git-svn-id: http://mc-server.googlecode.com/svn/trunk@850 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth 2012-09-08 20:49:29 +00:00
parent 675d35cd46
commit 6bc916fc3c
5 changed files with 48 additions and 5 deletions

View File

@ -101,7 +101,7 @@ function Initialize( Plugin )
end end
-- Load whitelist, and add default values and stuff -- Load whitelist, and add default values and stuff
WhiteListIni = cIniFile("whitelist.ini") WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" )
if ( WhiteListIni:ReadFile() == true ) then if ( WhiteListIni:ReadFile() == true ) then
if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then
if( WhiteListIni:GetNumValues("WhiteList") > 0 ) then if( WhiteListIni:GetNumValues("WhiteList") > 0 ) then
@ -121,7 +121,7 @@ function Initialize( Plugin )
end end
-- Load banned players, and add default values and stuff -- Load banned players, and add default values and stuff
BannedPlayersIni = cIniFile("banned.ini") BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" )
if ( BannedPlayersIni:ReadFile() == true ) then if ( BannedPlayersIni:ReadFile() == true ) then
if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then
LOGINFO("Core: loaded " .. BannedPlayersIni:GetNumValues("Banned") .. " banned players.") LOGINFO("Core: loaded " .. BannedPlayersIni:GetNumValues("Banned") .. " banned players.")

View File

@ -1,6 +1,6 @@
/* /*
** Lua binding: AllToLua ** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 09/08/12 18:04:37. ** Generated automatically by tolua++-1.0.92 on 09/08/12 22:43:41.
*/ */
#ifndef __cplusplus #ifndef __cplusplus
@ -10314,6 +10314,38 @@ static int tolua_AllToLua_cPlugin_NewLua_Tick00(lua_State* tolua_S)
} }
#endif //#ifndef TOLUA_DISABLE #endif //#ifndef TOLUA_DISABLE
/* method: GetLocalDirectory of class cPlugin_NewLua */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_NewLua_GetLocalDirectory00
static int tolua_AllToLua_cPlugin_NewLua_GetLocalDirectory00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"const cPlugin_NewLua",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const cPlugin_NewLua* self = (const cPlugin_NewLua*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLocalDirectory'", NULL);
#endif
{
AString tolua_ret = (AString) self->GetLocalDirectory();
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetLocalDirectory'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: CreateWebPlugin of class cPlugin_NewLua */ /* method: CreateWebPlugin of class cPlugin_NewLua */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_NewLua_CreateWebPlugin00 #ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_NewLua_CreateWebPlugin00
static int tolua_AllToLua_cPlugin_NewLua_CreateWebPlugin00(lua_State* tolua_S) static int tolua_AllToLua_cPlugin_NewLua_CreateWebPlugin00(lua_State* tolua_S)
@ -21865,6 +21897,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"OnDisable",tolua_AllToLua_cPlugin_NewLua_OnDisable00); tolua_function(tolua_S,"OnDisable",tolua_AllToLua_cPlugin_NewLua_OnDisable00);
tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlugin_NewLua_Initialize00); tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlugin_NewLua_Initialize00);
tolua_function(tolua_S,"Tick",tolua_AllToLua_cPlugin_NewLua_Tick00); tolua_function(tolua_S,"Tick",tolua_AllToLua_cPlugin_NewLua_Tick00);
tolua_function(tolua_S,"GetLocalDirectory",tolua_AllToLua_cPlugin_NewLua_GetLocalDirectory00);
tolua_function(tolua_S,"CreateWebPlugin",tolua_AllToLua_cPlugin_NewLua_CreateWebPlugin00); tolua_function(tolua_S,"CreateWebPlugin",tolua_AllToLua_cPlugin_NewLua_CreateWebPlugin00);
tolua_variable(tolua_S,"__cWebPlugin__",tolua_get_cPlugin_NewLua___cWebPlugin__,NULL); tolua_variable(tolua_S,"__cWebPlugin__",tolua_get_cPlugin_NewLua___cWebPlugin__,NULL);
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);

View File

@ -1,6 +1,6 @@
/* /*
** Lua binding: AllToLua ** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 09/08/12 18:04:38. ** Generated automatically by tolua++-1.0.92 on 09/08/12 22:43:41.
*/ */
/* Exported function */ /* Exported function */

View File

@ -68,7 +68,7 @@ bool cPlugin_NewLua::Initialize()
ManualBindings::Bind( m_LuaState ); ManualBindings::Bind( m_LuaState );
} }
std::string PluginPath = FILE_IO_PREFIX + std::string("Plugins/") + m_Directory + "/"; std::string PluginPath = GetLocalDirectory() + "/";
// Load all files for this plugin, and execute them // Load all files for this plugin, and execute them
AStringList Files = GetDirectoryContents(PluginPath.c_str()); AStringList Files = GetDirectoryContents(PluginPath.c_str());
@ -131,6 +131,15 @@ bool cPlugin_NewLua::Initialize()
AString cPlugin_NewLua::GetLocalDirectory(void) const
{
return FILE_IO_PREFIX + std::string("Plugins/") + m_Directory;
}
void cPlugin_NewLua::OnDisable() void cPlugin_NewLua::OnDisable()
{ {
cCSLock Lock( m_CriticalSection ); cCSLock Lock( m_CriticalSection );

View File

@ -48,6 +48,7 @@ public: //tolua_export
virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override; virtual bool OnHandshake (cClientHandle * a_Client, const AString & a_Username) override;
const AString & GetDirectory(void) const {return m_Directory; } const AString & GetDirectory(void) const {return m_Directory; }
AString GetLocalDirectory(void) const; //tolua_export
virtual void SetName( const AString & a_Name ) override { cPlugin::SetName(a_Name); } virtual void SetName( const AString & a_Name ) override { cPlugin::SetName(a_Name); }