mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Fixed some bugs in ExpGamingCore.Group
This commit is contained in:
32
modules/ExpGamingCore/Group/config.lua
Normal file
32
modules/ExpGamingCore/Group/config.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
-- defines for groups
|
||||
Group{
|
||||
name='_root',
|
||||
disallow={}
|
||||
}
|
||||
|
||||
Group{
|
||||
name='_admin',
|
||||
disallow={
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group'
|
||||
}
|
||||
}
|
||||
|
||||
Group{
|
||||
name='_member',
|
||||
disallow={
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group'
|
||||
}
|
||||
}
|
||||
|
||||
Group{
|
||||
name='_guest',
|
||||
disallow={
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group'
|
||||
}
|
||||
}
|
||||
@@ -17,15 +17,20 @@ local module_verbose = false
|
||||
-- @field _prototype the prototype of this class
|
||||
-- @field groups a table of all groups, includes auto complete on the indexing
|
||||
local Group = {
|
||||
_prototype = setmetatable({},{
|
||||
__index=function(tbl,key) return rawget(rawget(tbl,'_raw_group'),key) end
|
||||
}),
|
||||
_prototype = {},
|
||||
groups = setmetatable({},{
|
||||
__index=table.autokey,
|
||||
__newindex=function(tbl,key,value)
|
||||
rawset(tbl,key,Group.define(obj))
|
||||
end
|
||||
})
|
||||
}),
|
||||
on_init = function()
|
||||
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Group','ExpGamingCore.Group') end
|
||||
end,
|
||||
on_post = function(self)
|
||||
-- loads the groups in config
|
||||
require(module_path..'/config',{Group=self})
|
||||
end
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
@@ -40,7 +45,7 @@ function Group.define(obj)
|
||||
if not type_error(obj.name,'string','Group creation is invalid: group.name is not a string') then return end
|
||||
if not type_error(obj.disallow,'table','Group creation is invalid: group.disallow is not a table') then return end
|
||||
verbose('Created Group: '..obj.name)
|
||||
setmetatable(obj,{__index=Group._prototype})
|
||||
setmetatable(obj,{__index=function(tbl,key) return Group._prototype[key] or rawget(tbl,'_raw_group') and rawget(tbl,'_raw_group')[key] or nil end})
|
||||
rawset(Group.groups,obj.name,obj)
|
||||
return obj
|
||||
end
|
||||
@@ -62,8 +67,8 @@ end
|
||||
-- @treturn LuaPermissionGroup the factorio group linked to this group
|
||||
function Group._prototype:get_raw()
|
||||
if not self_test(self,'group','get_raw') then return end
|
||||
if not group._raw_group then error('No permissions group found, please to not remove groups with /permissions',2) return end
|
||||
return setmetatable({},{__index=group._raw_group})
|
||||
if not self._raw_group then error('No permissions group found, please to not remove groups with /permissions',2) return end
|
||||
return setmetatable({},{__index=self._raw_group})
|
||||
end
|
||||
|
||||
--- Used to add a player to this group
|
||||
|
||||
@@ -85,7 +85,7 @@ end
|
||||
-- @tparam string prototype_name the name of the class
|
||||
-- @tparam string function_name the name of the function
|
||||
function ExpLib.self_test(self,prototype_name,function_name)
|
||||
return ExpLib.is_type(value,'table') or error('Call to prototype without context, either supply a '..prototype_name..' or use '..prototype_name..':'..function_name,3)
|
||||
return ExpLib.is_type(self,'table') or error('Call to prototype without context, either supply a '..prototype_name..' or use '..prototype_name..':'..function_name,3)
|
||||
end
|
||||
|
||||
--- Will return a value of any type to the player/server console, allows colour for in-game players
|
||||
|
||||
@@ -11,14 +11,14 @@ return {
|
||||
['FactorioStdLib.Color@0.8.0']='./modules/FactorioStdLib/Color',
|
||||
['ExpGamingLib@^4.0.0']='./modules/ExpGamingLib',
|
||||
['ExpGamingLib@4.0.0']='./modules/ExpGamingLib',
|
||||
['ExpGamingCore.Command@4.0.0']='./modules/ExpGamingCore/Commands',
|
||||
['ExpGamingCore.Command@4.0.0']='./modules/ExpGamingCore/Command',
|
||||
['ExpGamingCore.Server@4.0.0']='./modules/ExpGamingCore/Server',
|
||||
['ExpGamingCore.Ranking@^4.0.0']='./modules/ExpGamingCore/Ranking',
|
||||
['ExpGamingCore.Ranking@4.0.0']='./modules/ExpGamingCore/Ranking',
|
||||
['ExpGamingBot.autoChat@4.0.0']='./modules/ExpGamingBot/autoChat',
|
||||
['ExpGamingCore.Server@^4.0.0']='./modules/ExpGamingCore/Server',
|
||||
['ExpGamingCommands.tags@4.0.0']='./modules/ExpGamingCommands/tags',
|
||||
['ExpGamingCore.Command@^4.0.0']='./modules/ExpGamingCore/Commands',
|
||||
['ExpGamingCore.Command@^4.0.0']='./modules/ExpGamingCore/Command',
|
||||
['ExpGamingCommands.home@4.0.0']='./modules/ExpGamingCommands/home',
|
||||
['ExpGamingCommands.cheatMode@4.0.0']='./modules/ExpGamingCommands/cheatMode',
|
||||
['ExpGamingCommands.bonus@4.0.0']='./modules/ExpGamingCommands/bonus',
|
||||
@@ -47,4 +47,5 @@ return {
|
||||
['ExpGamingAdmin.Jail@4.0.0']='./modules/ExpGamingAdmin/Jail',
|
||||
['ExpGamingAdmin.Commands@4.0.0']='./modules/ExpGamingAdmin/Commands',
|
||||
['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban',
|
||||
['ExpGamingCore.Group@4.0.0']='./modules/ExpGamingCore/Group',
|
||||
}
|
||||
Reference in New Issue
Block a user