mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Renamed Commands and added ExpGamingCore.Groups
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingAdmin.TempBan": "?^4.0.0",
|
||||
"ExpGamingAdmin.Jail": "?^4.0.0",
|
||||
"ExpGamingAdmin.Warnings": "?^4.0.0",
|
||||
|
||||
@@ -261,7 +261,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingAdmin.TempBan": "?^4.0.0",
|
||||
"ExpGamingAdmin.Jail": "?^4.0.0",
|
||||
"ExpGamingAdmin.Warnings": "?^4.0.0",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingCore.Ranking": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"Hacks"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Commands": "^4.0.0"
|
||||
"ExpGamingCore.Command": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0"
|
||||
"ExpGamingCore.Command": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
"Tool"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingCore.Ranking": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingCore.Ranking": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
@@ -51,7 +51,7 @@
|
||||
"Hacks"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Commands": "^4.0.0"
|
||||
"ExpGamingCore.Command": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
},
|
||||
@@ -71,7 +71,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0"
|
||||
"ExpGamingCore.Command": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
},
|
||||
@@ -90,7 +90,7 @@
|
||||
"Tool"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingCore.Ranking": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
@@ -133,7 +133,7 @@
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Ranking": "?^4.0.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
@@ -155,7 +155,7 @@
|
||||
"Tools"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingAdmin.Teleport": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"ExpGamingCore.Ranking": "?^4.0.0",
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"Tools"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingCore.Commands": "^4.0.0",
|
||||
"ExpGamingCore.Command": "^4.0.0",
|
||||
"ExpGamingAdmin.Teleport": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCommands_4.0.0"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--- Command system that allows middle ware and auto validation of command arguments.
|
||||
-- @module ExpGamingCore.Commands@4.0.0
|
||||
-- @module ExpGamingCore.Command@4.0.0
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
-- @alias commands
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "Commands",
|
||||
"name": "Command",
|
||||
"version": "4.0.0",
|
||||
"type": "Submodule",
|
||||
"description": "A better command handler than the base game.",
|
||||
"location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Commands_4.0.0.zip",
|
||||
"location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Command_4.0.0.zip",
|
||||
"keywords": [
|
||||
"Library",
|
||||
"Lib",
|
||||
129
modules/ExpGamingCore/Group/control.lua
Normal file
129
modules/ExpGamingCore/Group/control.lua
Normal file
@@ -0,0 +1,129 @@
|
||||
--- Desction <get from json>
|
||||
-- @module ExpGamingCore@Group
|
||||
-- @author Cooldude2606
|
||||
-- @license Discord: Cooldude2606@5241
|
||||
-- @alais Group
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
-- Local Varibles
|
||||
|
||||
-- Module Define
|
||||
local module_verbose = false
|
||||
|
||||
--- Used as an interface for factorio permissions groups
|
||||
-- @type Group
|
||||
-- @field _prototype the prototype of this class
|
||||
-- @field groups a table of all groups, includes auto complete on the indexing
|
||||
local Group = {
|
||||
_prototype = {},
|
||||
groups = setmetatable({},{
|
||||
__index=table.autokey,
|
||||
__newindex=function(tbl,key,value)
|
||||
rawset(tbl,key,Group.define(obj))
|
||||
end
|
||||
})
|
||||
}
|
||||
|
||||
-- Function Define
|
||||
|
||||
--- Defines a new instance of a group
|
||||
-- @usage Group.define{name='foo',disallow={'edit_permission_group','delete_permission_group','add_permission_group'}} -- returns new group
|
||||
-- @usage Group{name='foo',disallow={'edit_permission_group','delete_permission_group','add_permission_group'}} -- returns new group
|
||||
-- @tparam table obj contains string name and table disallow of defines.input_action
|
||||
-- @treturn Group the group which has been made
|
||||
function Group.define(obj)
|
||||
if not type_error(game,nil,'Cant define Group during runtime.') then return end
|
||||
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})
|
||||
rawset(Group.groups,obj.name,obj)
|
||||
return obj
|
||||
end
|
||||
|
||||
--- Used to get the group of a player or the group by name
|
||||
-- @usage Group.get('foo') -- returns group foo
|
||||
-- @usage Group.get(player) -- returns group of player
|
||||
-- @tparam ?LuaPlayer|pointerToPlayer|string mixed can either be the name or raw group of a group or a player indenifier
|
||||
-- @treturn table the group which was found or nil
|
||||
function Group.get(mixed)
|
||||
local player = Game.get_player(mixed)
|
||||
if player then mixed = player.permission_group.name end
|
||||
if is_type(mixed,'table') and mixed.__self and mixed.name then mixed = mixed.name end
|
||||
return Group.groups[mixed]
|
||||
end
|
||||
|
||||
--- Used to get the factorio permission group linked to this group
|
||||
-- @usage group:get_raw() -- returns LuaPermissionGroup of this group
|
||||
-- @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})
|
||||
end
|
||||
|
||||
--- Used to add a player to this group
|
||||
-- @usage group:add_player(player) -- returns true if added
|
||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to add to the group
|
||||
-- @treturn boolean if the player was added
|
||||
function Group._prototype:add_player(player)
|
||||
if not self_test(self,'group','add_player') then return end
|
||||
local player = Game.get_player(player)
|
||||
if not player then error('Invalid player given to group.add_player.',2) end
|
||||
local raw_group = self:get_raw()
|
||||
return raw_group.add_player(player)
|
||||
end
|
||||
|
||||
--- Used to remove a player from this group
|
||||
-- @usage group:remove_player(player) -- returns true if removed
|
||||
-- @tparam ?LuaPlayer|pointerToPlayer player the player to remove from the group
|
||||
-- @treturn boolean if the player was removed
|
||||
function Group._prototype:remove_player(player)
|
||||
if not self_test(self,'group','remove_player') then return end
|
||||
local player = Game.get_player(player)
|
||||
if not player then error('Invalid player given to group.remove_player.',2) end
|
||||
local raw_group = self:get_raw()
|
||||
return raw_group.remove_player(player)
|
||||
end
|
||||
|
||||
--- Gets all players in this group
|
||||
-- @usage group:get_players(true) -- returns all online players
|
||||
-- @tparam[opt=false] boolean online if true returns only online players
|
||||
-- @treturn table table of players
|
||||
function Group._prototype:get_players(online)
|
||||
if not self_test(self,'group','get_players') then return end
|
||||
local raw_group = self:get_raw()
|
||||
local rtn = {}
|
||||
if online then for _,player in pairs(raw_group.players) do if player.connected then table.insert(rtn,player) end end end
|
||||
return online and rtn or raw_group.players
|
||||
end
|
||||
|
||||
--- Prints a message or value to all online players in this group
|
||||
-- @usage group.print('Hello, World!')
|
||||
-- @param rtn any value you wish to print, string not required
|
||||
-- @param colour the colour to print the message in
|
||||
-- @treturn number the number of players who recived the message
|
||||
function Group._prototype:print(rtn,colour)
|
||||
if not self_test(self,'group','print') then return end
|
||||
local players = self:get_players()
|
||||
local ctn = 0
|
||||
for _,player in pairs(players) do if player.connected then player_return(rtn,colour,player) ctn=ctn+1 end end
|
||||
return ctn
|
||||
end
|
||||
|
||||
-- Event Handlers Define
|
||||
|
||||
-- creates all permission groups and links them
|
||||
script.on_event('on_init',function(event)
|
||||
for name,group in pairs(Group.groups) do
|
||||
group._raw_group = game.permissions.create_group(name)
|
||||
for _,to_remove in pairs(group.disallow) do
|
||||
group._raw_group.set_allows_action(defines.input_action[to_remove],false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
return setmetatable(Group,{__call=function(tbl,...) tbl.define(...) end})
|
||||
20
modules/ExpGamingCore/Group/softmod.json
Normal file
20
modules/ExpGamingCore/Group/softmod.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Group",
|
||||
"version": "4.0.0",
|
||||
"type": "Submodule",
|
||||
"description": "Adds a system to manage and auto-create permission groups.",
|
||||
"location": "<blank>",
|
||||
"keywords": [
|
||||
"Groups",
|
||||
"ExpGaming",
|
||||
"System",
|
||||
"Management",
|
||||
"Manage",
|
||||
"Permissions"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib": "^0.8.0",
|
||||
"ExpGamingLib": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCore_4.0.0"
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
--- This file will be loaded when ExpGamingCore.Commands is present
|
||||
--- This file will be loaded when ExpGamingCore.Command is present
|
||||
-- @function _comment
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
@@ -438,7 +438,7 @@ require(module_path..'/src/config',{Ranking=Ranking})
|
||||
|
||||
function Ranking:on_init()
|
||||
if loaded_modules['ExpGamingCore.Server'] then verbose('ExpGamingCore.Server is installed; Loading server src') require(module_path..'/src/server',{Ranking=Ranking}) end
|
||||
if loaded_modules['ExpGamingCore.Commands'] then verbose('ExpGamingCore.Server is installed; Loading commands src') require(module_path..'/src/commands',{Ranking=Ranking}) end
|
||||
if loaded_modules['ExpGamingCore.Command'] then verbose('ExpGamingCore.Server is installed; Loading commands src') require(module_path..'/src/commands',{Ranking=Ranking}) end
|
||||
end
|
||||
|
||||
function Ranking:on_post()
|
||||
|
||||
@@ -468,7 +468,7 @@ end)
|
||||
|
||||
function Server:on_init()
|
||||
for name,id in pairs(defines.events) do if not script.get_event_handler(id) then script.on_event(id,Server._thread_handler) end end
|
||||
if loaded_modules['ExpGamingCore.Commands'] then verbose('ExpGamingCore.Commands is installed; Loading commands src') require(module_path..'/src/commands',{Server=Server}) end
|
||||
if loaded_modules['ExpGamingCore.Command'] then verbose('ExpGamingCore.Command is installed; Loading commands src') require(module_path..'/src/commands',{Server=Server}) end
|
||||
end
|
||||
|
||||
return Server
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"FactorioStdLib.Color": "^0.8.0",
|
||||
"FactorioStdLib.String": "^0.8.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Commands": "?^4.0.0"
|
||||
"ExpGamingCore.Command": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCore_4.0.0"
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
-- @author Cooldude2606
|
||||
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
|
||||
|
||||
--- This file will be loaded when ExpGamingCore.Commands is present
|
||||
--- This file will be loaded when ExpGamingCore.Command is present
|
||||
-- @function _comment
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"version": "4.0.0",
|
||||
"type": "Submodule",
|
||||
"description": "A better command handler than the base game.",
|
||||
"location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Commands_4.0.0.zip",
|
||||
"location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Command_4.0.0.zip",
|
||||
"keywords": [
|
||||
"Library",
|
||||
"Lib",
|
||||
@@ -107,7 +107,7 @@
|
||||
"FactorioStdLib.Color": "^0.8.0",
|
||||
"FactorioStdLib.String": "^0.8.0",
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Commands": "?^4.0.0"
|
||||
"ExpGamingCore.Command": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCore_4.0.0"
|
||||
},
|
||||
@@ -136,6 +136,47 @@
|
||||
"ExpGamingCore.Gui": "?^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCore_4.0.0"
|
||||
},
|
||||
"Command": {
|
||||
"name": "Command",
|
||||
"version": "4.0.0",
|
||||
"type": "Submodule",
|
||||
"description": "A better command handler than the base game.",
|
||||
"location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Command_4.0.0.zip",
|
||||
"keywords": [
|
||||
"Library",
|
||||
"Lib",
|
||||
"ExpGaming",
|
||||
"Core",
|
||||
"Commands"
|
||||
],
|
||||
"dependencies": {
|
||||
"ExpGamingLib": "^4.0.0",
|
||||
"FactorioStdLib.Table": "^0.8.0",
|
||||
"FactorioStdLib.Color": "^0.8.0",
|
||||
"FactorioStdLib.Game": "^0.8.0"
|
||||
},
|
||||
"collection": "ExpGamingCore_4.0.0"
|
||||
},
|
||||
"Group": {
|
||||
"name": "Group",
|
||||
"version": "4.0.0",
|
||||
"type": "Submodule",
|
||||
"description": "Adds a system to manage and auto-create permission groups.",
|
||||
"location": "<blank>",
|
||||
"keywords": [
|
||||
"Groups",
|
||||
"ExpGaming",
|
||||
"System",
|
||||
"Management",
|
||||
"Manage",
|
||||
"Permissions"
|
||||
],
|
||||
"dependencies": {
|
||||
"FactorioStdLib": "^0.8.0",
|
||||
"ExpGamingLib": "^4.0.0"
|
||||
},
|
||||
"collection": "ExpGamingCore_4.0.0"
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
|
||||
@@ -68,6 +68,26 @@ function ExpLib.is_type(v,test_type)
|
||||
return test_type and v and type(v) == test_type or not test_type and not v or false
|
||||
end
|
||||
|
||||
--- Compear types faster for faster valadation of prams, including giving an error if incorrect
|
||||
-- @usage type_error('foo','string','Value is not a string') -- return true
|
||||
-- @usage type_error('foo','table','Value is not a string') -- return error
|
||||
-- @param value the value to be tested
|
||||
-- @tparam[opt=nil] string type the type that the value should be
|
||||
-- @tparam string error_message the message given when type is not matched
|
||||
-- @treturn boolean if it matched or and error
|
||||
function ExpLib.type_error(value,type,error_message)
|
||||
return ExpLib.is_type(value,type) or error(error_message,3)
|
||||
end
|
||||
|
||||
--- A speailsied verion of type_error to test for self
|
||||
-- @usage self_test(self,'Object','get_name')
|
||||
-- @tparam table self the table that is the object
|
||||
-- @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)
|
||||
end
|
||||
|
||||
--- Will return a value of any type to the player/server console, allows colour for in-game players
|
||||
-- @usage player_return('Hello, World!') -- returns 'Hello, World!' to game.player or server console
|
||||
-- @usage player_return('Hello, World!','green') -- returns 'Hello, World!' to game.player with colour green or server console
|
||||
|
||||
@@ -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.Commands@4.0.0']='./modules/ExpGamingCore/Commands',
|
||||
['ExpGamingCore.Command@4.0.0']='./modules/ExpGamingCore/Commands',
|
||||
['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.Commands@^4.0.0']='./modules/ExpGamingCore/Commands',
|
||||
['ExpGamingCore.Command@^4.0.0']='./modules/ExpGamingCore/Commands',
|
||||
['ExpGamingCommands.home@4.0.0']='./modules/ExpGamingCommands/home',
|
||||
['ExpGamingCommands.cheatMode@4.0.0']='./modules/ExpGamingCommands/cheatMode',
|
||||
['ExpGamingCommands.bonus@4.0.0']='./modules/ExpGamingCommands/bonus',
|
||||
|
||||
Reference in New Issue
Block a user