Refactor of commands

This commit is contained in:
Cooldude2606
2019-03-01 20:24:23 +00:00
parent e547f76d6f
commit 62dcfe8694
288 changed files with 5364 additions and 1067 deletions

View File

@@ -0,0 +1,49 @@
--- Adds a custom ban function to the admin command set.
-- @module ExpGamingAdmin.Ban@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local AdminGui = require('ExpGamingAdmin.Gui')
local Server = require('ExpGamingCore.Server')
local Game = require('FactorioStdLib.Game')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
end
}
-- Function Define
AdminGui.add_button('Ban','utility/danger_icon',{'ExpGamingAdmin.tooltip-ban'},function(player,byPlayer)
Admin.open(byPlayer,player,'Ban')
end)
function Admin.ban(player,by_player,reason)
player = Game.get_player(player)
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
reason = Admin.create_reason(reason,by_player_name)
Admin.set_banned(player,true)
if Sync then Sync.emit_embedded{
title='Player Ban',
color=Color.to_hex(defines.textcolor.crit),
description='There was a player banned.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player_name,
['Reason:']=reason
} end
if Admin.move_inventory then Admin.move_inventory(player) end
Server.interface(game.ban_player,true,player,reason)
end
Admin.add_action('Ban',Admin.ban)
-- Module Return
return setmetatable(ThisModule,{__call=Admin.ban})

View File

@@ -0,0 +1,23 @@
{
"name": "ExpGamingAdmin.Ban",
"version": "4.0.0",
"description": "Adds a custom ban function to the admin command set.",
"location": "FSM_ARCHIVE",
"keywords": [
"Ban",
"Admin",
"Set",
"ExpGaming"
],
"dependencies": {
"ExpGamingAdmin.Gui": "^4.0.0",
"ExpGamingCore.Server": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"FactorioStdLib.Color": "?^0.8.0",
"ExpGamingCore.Sync": "?^4.0.0",
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,58 @@
--- Adds a function to clear a players inventory and move the items to spawn.
-- @module ExpGamingAdmin.ClearInventory@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local Game = require('FactorioStdLib.Game')
-- Module Define
local module_verbose = false
local ThisModule = {}
-- Function Define
local inventories = {
defines.inventory.player_main,
defines.inventory.player_quickbar,
defines.inventory.player_trash,
defines.inventory.player_guns,
defines.inventory.player_ammo,
defines.inventory.player_armor
}
function Admin.move_item_to_spawn(item,surface,chests)
chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
local chest = nil
while not chest or not chest.get_inventory(defines.inventory.chest).can_insert(item) do
chest = table.remove(chests,1)
if not chest then chest = surface.create_entity{
name='iron-chest',
position=surface.find_non_colliding_position('iron-chest',{0,0},32,1)
} end
end
chest.get_inventory(defines.inventory.chest).insert(item)
table.insert(chests,chest)
return chests
end
function Admin.move_inventory(player)
player = Game.get_player(player)
if not player then return end
local chests = player.surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
for _,_inventory in pairs(inventories) do
local inventory = player.get_inventory(_inventory)
if inventory then
for item,count in pairs(inventory.get_contents()) do
item = {name=item,count=count}
chests = Admin.move_item_to_spawn(item,player.surface,chests)
end
inventory.clear()
end
end
end
Admin.add_action('Clear Inventory',Admin.move_inventory)
-- Module Return
return setmetatable(ThisModule,{__call=Admin.move_inventory})

View File

@@ -0,0 +1,20 @@
{
"name": "ExpGamingAdmin.ClearInventory",
"version": "4.0.0",
"description": "Adds a function to clear a players inventoy and move the items to spawn.",
"location": "FSM_ARCHIVE",
"keywords": [
"Spawn",
"Items",
"Admin",
"Move",
"Clear",
"Inventory"
],
"dependencies": {
"FactorioStdLib.Game": "^0.8.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,25 @@
--- A full ranking system for factorio.
-- @module ExpGamingAdmin.Commands@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
local Admin = require('ExpGamingAdmin')
--- Used to clear all parts of a player, removing warnings, reports, jail and temp ban
-- @command clear-all
-- @param player the player to clear
commands.add_command('clear-all', 'Clears a player of any temp-ban, reports or warnings', {
['player']={true,'player'}
}, function(event,args)
Admin.clear_player(args.player,event.player_index)
end)
return {
on_init = function(self)
if loaded_modules['ExpGamingAdmin.TempBan'] then verbose('ExpGamingAdmin.TempBan is installed; Loading tempban src') require(module_path..'/src/tempban',{self=Admin}) end
if loaded_modules['ExpGamingAdmin.Jail'] then verbose('ExpGamingAdmin.Jail is installed; Loading tempban src') require(module_path..'/src/jail',{self=Admin}) end
if loaded_modules['ExpGamingAdmin.Warnings'] then verbose('ExpGamingAdmin.Warnings is installed; Loading tempban src') require(module_path..'/src/warnings',{self=Admin}) end
if loaded_modules['ExpGamingAdmin.Reports'] then verbose('ExpGamingAdmin.Reports is installed; Loading tempban src') require(module_path..'/src/reports',{self=Admin}) end
if loaded_modules['ExpGamingAdmin.ClearInventory'] then verbose('ExpGamingAdmin.ClearInventory is installed; Loading tempban src') require(module_path..'/src/clear',{self=Admin}) end
end
}

View File

@@ -0,0 +1,29 @@
{
"name": "ExpGamingAdmin.Commands",
"version": "4.0.0",
"description": "Admins many of the admin featues which the script can use as in game commands.",
"location": "FSM_ARCHIVE",
"keywords": [
"ExpGaming",
"Admin",
"Tools",
"Commands",
"Temp ban",
"Jail",
"Clear Inventory",
"Report",
"Warnings"
],
"dependencies": {
"ExpGamingLib": "^4.0.0",
"ExpGamingCore.Command": "^4.0.0",
"ExpGamingAdmin.TempBan": "?^4.0.0",
"ExpGamingAdmin.Jail": "?^4.0.0",
"ExpGamingAdmin.Warnings": "?^4.0.0",
"ExpGamingAdmin.Reports": "?^4.0.0",
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,12 @@
local Admin = self
--- Clears a players inventory and moves it to chests in spawn
-- @command clear-inv
-- @param player the player to clear the inventory of
commands.add_command('clear-inv', 'Clears a player\'s invetory', {
['player'] = {true,'player-rank'}
}, function(event,args)
local player = args.player
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
Admin.move_inventory(player)
end)

View File

@@ -0,0 +1,30 @@
local Admin = self
local Role = require('ExpGamingCore.Role')
local Server = require('ExpGamingCore.Server')
--- Used to jail a player which stops them from moving
-- @command jail
-- @param player the player to be jailed
-- @param[opt] reason the reason the player was jailed
commands.add_command('jail', 'Jails a player', {
['player']={true,'player-rank'},
['reason']={false,'string-inf'}
}, function(event,args)
local player = args.player
local reason = args.reason
if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player.name} return commands.error end
if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player.name} return commands.error end
Admin.jail(player,event.player_index,reason)
end)
--- Used to unjail a player
-- @command unjail
-- @param player the player to unjail
commands.add_command('unjail', 'Returns a player\'s old rank', {
['player']={true,'player'}
}, function(event,args)
local player = args.player
if Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
Admin.set_banned(player,false)
Server.interface(Role.revert,true,player,event.player_index,2)
end)

View File

@@ -0,0 +1,35 @@
local Admin = self
local Role = require('ExpGamingCore.Role')
local Game = require('FactorioStdLib.Game')
--- Reports a player
-- @command report
-- @param player the player to report
-- @param[opt] reason the reason why the player was reported
commands.add_command('report', 'Reports a player', {
['player']={true,'player-rank'},
['reason']={false,'string-inf'}
}, function(event,args)
local _player = Game.get_player(event)
local player = args.player
local reason = args.reason
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
if Role.has_flag(player,'not_reportable') then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end
for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end
for _,report in pairs(global.addons.reports.verified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end
Admin.report(player,event.player_index,reason)
end)
--- Clears the reports of the player
-- @command clear-reports
-- @param player the player to clear the reports of
commands.add_command('clear-reports', 'Clears a player\'s reports', {
['player'] = {true,function(value)
local player,err = commands.validate['player'](value)
if err then return commands.error(err) end
local rtn = not Admin.is_banned(player) and player
if not rtn then return commands.error{'ExpGamingAdmin.cant-report-ban',value} end return rtn
end}
}, function(event,args)
Admin.clear_reports(args.player,event.player_index)
end)

View File

@@ -0,0 +1,15 @@
local Admin = self
--- Used to temp ban a player and give a reason
-- @command temp-ban
-- @param player the player to temp ban
-- @param[opt] reason the reason for the ban
commands.add_command('temp-ban', 'Temporarily ban a player', {
['player']={true,'player-rank'},
['reason']={false,'string-inf'}
}, function(event,args)
local player = args.player
local reason = args.reason
if Admin.is_banned(player) and Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
Admin.temp_ban(player,event.player_index,reason)
end)

View File

@@ -0,0 +1,28 @@
local Admin = self
local Role = require('ExpGamingCore.Role')
--- Gives a warning to a player
-- @command warn
-- @param player the player to give a warning to
-- @param[opt] reason the reason the player was given a warning
commands.add_command('warn', 'Gives a player a warning', {
['player']={true,'player-rank'},
['reason']={false,'string-inf'}
}, function(event,args)
local player = args.player
local reason = args.reason
if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player.name} return commands.error end
if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player.name} return commands.error end
Admin.give_warning(player,event.player_index,reason)
end)
--- Clears the warning of a player
-- @command clear-warnings
-- @param player the player to clear the warning of
commands.add_command('clear-warnings', 'Clears a player\'s warnings', {
['player'] = {true,'player'}
}, function(event,args)
local player = args.player
if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end
Admin.clear_warnings(player,event.player_index)
end)

View File

@@ -0,0 +1,202 @@
--- Adds a gui that can be used to access all the admin commands.
-- @module ExpGamingAdmin.Gui@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias AdminGui
-- Module Require
local Admin = require('ExpGamingAdmin')
local Gui = require('ExpGamingCore.Gui')
local Role = require('ExpGamingCore.Role')
local Game = require('FactorioStdLib.Game')
local playerInfo -- ExpGamingPlayer.playerInfo@^4.0.0
-- Module Define
local module_verbose = false
local AdminGui = {
on_init=function()
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo')
else playerInfo = function(player,frame)
frame.add{
type='label',
caption={'ExpGamingAdmin.no-info-file'}
}
end end
--code
end,
buttons={}
}
function Admin.open(player,pre_select_player,pre_select_action)
Gui.center.clear(player)
Admin.center(player,pre_select_player,pre_select_action)
end
-- Function Define
function AdminGui.add_button(name,caption,tooltip,callback)
AdminGui.buttons[name] = Gui.inputs.add{
type='button',
name='admin-gui-'..name,
caption=caption,
tooltip=tooltip
}:on_event('click',function(event)
local parent = event.element.parent
local pre_select_player = parent.player and parent.player.caption or nil
callback(pre_select_player,event.player_index)
end)
end
function AdminGui.draw(frame,filter_buttons)
local frame = frame.add{
type='flow',
name='admin'
}
frame.add{
type='label',
caption='',
name='player'
}.style.visible = false
local function format(btn)
btn.style.height = 30
btn.style.width = 30
end
for name,button in pairs(AdminGui.buttons) do
if not filter_buttons or filter_buttons[name] then format(button(frame)) end
end
return frame.player
end
-- Gui Define
local function get_players(_player,root_frame,state)
local players = {'Select Player'}
local _players = state and game.players or game.connected_players
for _,player in pairs(_players) do
if player.name ~= _player.name then
if not Admin.is_banned or not Admin.is_banned(player) then
table.insert(players,player.name)
end
end
end
return players
end
local online_check = Gui.inputs.add_checkbox('online-check-admin-commands',false,'Show Offline',false,function(player,element)
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,true)
element.parent['player-drop-down-admin-commands'].selected_index = 1
end,function(player,element)
element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,false)
element.parent['player-drop-down-admin-commands'].selected_index = 1
end)
local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',get_players,1,function(player,selected,items,element)
element.parent.parent.player.caption = selected
local player_info_flow = element.parent.parent.info_flow
player_info_flow.clear()
if selected == 'Select Player' then return
else playerInfo(selected,player_info_flow,true) end
local role = Role.get_highest(player)
local _role = Role.get_highest(selected)
if role.index >= _role.index then element.parent.warning.caption = {'ExpGamingAdmin.warning'}
else element.parent.warning.caption = '' end
end)
local reason_input = Gui.inputs.add_text('reason-input-admin-commands',false,'Enter Reason',function(player,text,element)
if string.len(text) < 20 or text == 'Enter Reason' then
element.parent.warning.caption = {'ExpGamingAdmin.short-reason'}
else
element.parent.warning.caption = ''
end
end)
local action_drop_down = Gui.inputs.add_drop_down('action-drop-down-rank-change',function() return {'Select Action',unpack(Admin.action_names)} end,1,function(player,selected,items,element)
element.parent.parent.action.caption = selected
if selected == 'Jail' or selected == 'Kick' or selected == 'Ban' or selected == 'Temp Ban' then
element.parent['reason-input-admin-commands'].style.visible = true
else
element.parent['reason-input-admin-commands'].style.visible = false
end
end)
local take_action = Gui.inputs{
type='button',
name='admin-commands-take',
caption={'ExpGamingAdmin.take-action'}
}:on_event('click',function(event)
local dropdowns = event.element.parent
local role = Role.get_highest(event.player_index)
local _action= dropdowns.parent.action.caption ~= 'Select Action' and dropdowns.parent.action.caption or nil
local _player = Game.get_player(dropdowns.parent.player.caption)
if not _player or not _action then dropdowns.warning.caption = {'ExpGamingAdmin.invalid'} return end
local _role = Role.get_highest(_player)
if role.index >= _role.index then dropdowns.warning.caption = {'ExpGamingAdmin.rank-high'} return end
local _reason = dropdowns['reason-input-admin-commands'] and dropdowns['reason-input-admin-commands'].text
if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 10) then return end
Admin.take_action(_action,_player,event.player_index,_reason)
Gui.center.clear(event)
end)
Admin.center = Gui.center{
name='admin-commands',
caption='utility/danger_icon',
tooltip={'ExpGamingAdmin.tooltip'},
draw=function(self,frame,pre_select_player,pre_select_action)
frame.caption={'ExpGamingAdmin.name'}
frame = frame.add{
type='flow',
direction='horizontal'
}
local dropdowns = frame.add{
type='flow',
direction='vertical'
}
local player_info_flow = frame.add{
name='info_flow',
type='flow',
direction='vertical'
}
player_info_flow.style.height = 280
player_info_flow.style.width = 200
local label = dropdowns.add{
type='label',
caption={'ExpGamingAdmin.message'}
}
label.style.single_line = false
label.style.width = 200
online_check:draw(dropdowns)
local _drop = player_drop_down:draw(dropdowns)
if pre_select_player then Gui.set_dropdown_index(_drop,pre_select_player.name) end
_drop = action_drop_down:draw(dropdowns)
Gui.set_dropdown_index(_drop,pre_select_action)
local _text = reason_input:draw(dropdowns)
if pre_select_action == 'Jail' or pre_select_action == 'Kick' or pre_select_action == 'Ban' then
_text.style.visible = true else _text.style.visible = false
end
if pre_select_player then playerInfo(pre_select_player,player_info_flow,true) end
_text.style.width = 200
label = dropdowns.add{
name='warning',
type='label',
caption='',
style='bold_red_label'
}
label.style.single_line = false
label.style.width = 200
take_action:draw(dropdowns)
local caption = pre_select_player and pre_select_player.name or ''
frame.add{
name='player',
type='label',
caption=caption
}.style.visible = false
caption = pre_select_action or ''
frame.add{
name='action',
type='label',
caption=caption
}.style.visible = false
end
}
-- Module Return
-- calling will draw the admin buttons to that frame
return setmetatable(AdminGui,{__call=function(self,...) return self.draw(...) end})

View File

@@ -0,0 +1,23 @@
{
"name": "ExpGamingAdmin.Gui",
"version": "4.0.0",
"description": "Adds a gui that can be used to access all the admin commands.",
"location": "FSM_ARCHIVE",
"keywords": [
"Admin",
"ExpGaming",
"Commands",
"Gui"
],
"dependencies": {
"ExpGamingCore.Gui": "^4.0.0",
"ExpGamingCore.Role": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"ExpGamingPlayer": "?^4.0.0",
"ExpGamingPlayer.playerInfo": "?^4.0.0",
"mod-gui": "*",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,51 @@
--- Adds a jail function to the admin set, require ExpGamingRole to work.
-- @module ExpGamingAdmin.Jail@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local AdminGui = require('ExpGamingAdmin.Gui')
local Server = require('ExpGamingCore.Server')
local Role = require('ExpGamingCore.Role')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
end
}
-- Function Define
AdminGui.add_button('jail','utility/clock',{'ExpGamingAdmin.tooltip-jail'},function(player,byPlayer)
Admin.open(byPlayer,player,'Jail')
end)
function Admin.jail(player,by_player,reason)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
reason = Admin.create_reason(reason,by_player.name)
Admin.set_banned(player,'jail')
if Sync then Sync.emit_embedded{
title='Player Jail',
color=Color.to_hex(defines.textcolor.med),
description='There was a player jailed.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player.name,
['Reason:']=reason
} end
Role.meta.last_jail = player.name
player.driving = false
Server.interface(Role.assign,true,player,'Jail',by_player.name)
Server.interface(Role.unassign,true,player,Role.get(player),by_player.name)
end
Admin.add_action('Jail',Admin.jail)
-- Module Return
return setmetatable(ThisModule,{__call=Admin.jail})

View File

@@ -0,0 +1,24 @@
{
"name": "ExpGamingAdmin.Jail",
"version": "4.0.0",
"description": "Adds a jail function to the admin set, require ExpGamingRole to work.",
"location": "FSM_ARCHIVE",
"keywords": [
"Jail",
"Roles",
"Admin",
"ExpGaming"
],
"dependencies": {
"ExpGamingAdmin.Gui": "^4.0.0",
"ExpGamingCore.Server": "^4.0.0",
"ExpGamingCore.Role": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"FactorioStdLib.Color": "?^0.8.0",
"ExpGamingCore.Sync": "?^4.0.0",
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,47 @@
--- Adds a kick function to the admin function set.
-- @module ExpGamingAdmin.Kick@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local AdminGui = require('ExpGamingAdmin.Gui')
local Server = require('ExpGamingCore.Server')
local Game = require('FactorioStdLib.Game')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
end
}
-- Function Define
AdminGui.add_button('Kick','utility/warning_icon',{'ExpGamingAdmin.tooltip-kick'},function(player,byPlayer)
Admin.open(byPlayer,player,'Kick')
end)
function Admin.kick(player,by_player,reason)
player = Game.get_player(player)
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
reason = Admin.create_reason(reason,by_player_name)
if Sync then Sync.emit_embedded{
title='Player Kick',
color=Color.to_hex(defines.textcolor.high),
description='There was a player kicked.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player_name,
['Reason:']=reason
} end
if Admin.move_inventory then Admin.move_inventory(player) end
Server.interface(game.kick_player,true,player,reason)
end
Admin.add_action('Kick',Admin.kick)
-- Module Return
return setmetatable(ThisModule,{__call=Admin.kick})

View File

@@ -0,0 +1,23 @@
{
"name": "ExpGamingAdmin.Kick",
"version": "4.0.0",
"description": "Adds a kick function to the admin function set.",
"location": "FSM_ARCHIVE",
"keywords": [
"Admin",
"ExpGaming",
"Kick",
"Commands"
],
"dependencies": {
"ExpGamingAdmin.Gui": "^4.0.0",
"ExpGamingCore.Server": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"FactorioStdLib.Color": "?^0.8.0",
"ExpGamingCore.Sync": "?^4.0.0",
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,163 @@
--- Adds a report system into the game that can also push notifactions to discord.
-- @module ExpGamingAdmin.Reports@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local Role = require('ExpGamingCore.Role')
local Gui = require('ExpGamingCore.Gui')
local Game = require('FactorioStdLib.Game')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
end
}
-- Global Define
local global = {
reports={},
verified={}
}
Global.register(global,function(tbl) global = tbl end)
-- Local Variables
local report_to_warnings = 1 -- used in count_reports
local verified_to_warnings = 3 -- used in count_reports
local reports_needed_for_jail = 6
-- Function Define
local function report_message(player,by_player,reason)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
if Admin.is_banned(player,true) == 'report' then return end
Role.print(Role.meta.groups.User.lowest,{'ExpGamingAdmin.low-print',player.name,reason},defines.textcolor.info,true)
Role.print(Role.meta.groups.Admin.lowest,{'ExpGamingAdmin.high-print',player.name,by_player.name,reason},defines.textcolor.med)
if Sync then Sync.emit_embedded{
title='Player Report',
color=Color.to_hex(defines.textcolor.med),
description='A player was reported.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player.name,
['Reason:']=reason
} end
end
local function cheak_reports(player)
player = Game.get_player(player)
if not player then return end
local reports = Admin.count_reports(player)
if reports >= reports_needed_for_jail and Role.get_highest(player).group.name ~= 'Jail' then
Admin.jail(player,'<server>','Too many user reports. Contact an Admin to be unjailed.')
end
end
function Admin.count_reports(player)
player = Game.get_player(player)
if not player then return 0 end
local _count = 0
if global.reports[player.name] then
for _ in pairs(global.reports[player.name]) do
_count=_count+report_to_warnings
end
end
if global.verified[player.name] then
for _ in pairs(global.verified[player.name]) do
_count=_count+verified_to_warnings
end
end
return _count
end
function Admin.report(player,by_player,reason)
player, by_player = Admin.valid_players(player,by_player)
if not player or Role.has_flag(player,'not_reportable') then return end
if Admin.is_banned(by_player) or Role.has_flag(by_player,'is_jail') then return end
if Role.has_flag(by_player,'is_verified') then
global.verified[player.name] = global.verified[player.name] or {}
local reports = global.verified[player.name]
for _,value in pairs(reports) do
if value[1] == by_player.name then return end
end
table.insert(reports,{by_player.name,reason})
else
global.reports[player.name] = global.reports[player.name] or {}
local reports = global.reports[player.name]
for _,value in pairs(reports) do
if value[1] == by_player.name then return end
end
table.insert(reports,{by_player.name,reason})
end
report_message(player,by_player,reason)
cheak_reports(player)
end
function Admin.clear_reports(player,by_player,no_emit)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
global.reports[player.name]={}
global.verified[player.name]={}
if not no_emit and Sync then
Sync.emit_embedded{
title='Player Clear',
color=Color.to_hex(defines.textcolor.low),
description='A player had their reports cleared.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player.name,
}
end
end
local confirm_report = Gui.inputs{
type='button',
name='admin-report-confirm',
caption='utility/spawn_flag',
tooltip={'ExpGamingAdmin.report'}
}:on_event('click',function(event)
local parent = event.element.parent
local player = Game.get_player(parent.player.caption)
local reason = parent.reason.text
Admin.report(player,event.player_index,reason)
Gui.center.clear(event.player_index)
end)
Admin.report_btn = Gui.inputs{
type='button',
name='admin-report',
caption='utility/spawn_flag',
tooltip={'ExpGamingAdmin.report'}
}:on_event('click',function(event)
local parent = event.element.parent
local player = Game.get_player(parent.children[1].name)
if not player then return end
local _player = Game.get_player(event)
Gui.center.clear(_player)
local frame = Gui.center.get_flow(_player).add{
type='frame',
name='report-gui'
}
_player.opened=frame
frame.caption={'ExpGamingAdmin.report'}
frame.add{
type='textfield',
name='reason'
}.style.width = 300
local btn = confirm_report:draw(frame)
btn.style.height = 30
btn.style.width = 30
frame.add{
type='label',
name='player',
caption=player.name
}.style.visible = false
end)
-- Module Return
return ThisModule

View File

@@ -0,0 +1,25 @@
{
"name": "ExpGamingAdmin.Reports",
"version": "4.0.0",
"description": "Adds a report system into the game that can also push notifactions to discord.",
"location": "FSM_ARCHIVE",
"keywords": [
"Report",
"Player",
"Admin",
"ExpGaming",
"Player List",
"Commands"
],
"dependencies": {
"ExpGamingCore.Server": "^4.0.0",
"ExpGamingCore.Role": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"FactorioStdLib.Color": "?^0.8.0",
"ExpGamingCore.Sync": "?^4.0.0",
"ExpGamingCore.Gui": "^4.0.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,43 @@
--- Adds three function to admin: tp, bring and go to, these all move the player
-- @module ExpGamingAdmin.Teleport@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local AdminGui = require('ExpGamingAdmin.Gui')
local Game = require('FactorioStdLib.Game')
-- Module Define
local module_verbose = false
local ThisModule = {}
-- Function Define
AdminGui.add_button('Go To','utility/export_slot',{'ExpGamingAdmin.tooltip-go-to'},function(player,byPlayer)
Admin.go_to(player,byPlayer)
end)
AdminGui.add_button('Bring','utility/import_slot',{'ExpGamingAdmin.tooltip-bring'},function(player,byPlayer)
Admin.bring(player,byPlayer)
end)
function Admin.tp(from_player, to_player)
local _from_player = Game.get_player(from_player)
local _to_player = Game.get_player(to_player)
if not _from_player or not _to_player then return end
_from_player.teleport(_to_player.surface.find_non_colliding_position('player',_to_player.position,32,1),_to_player.surface)
end
function Admin.go_to(player,by_player)
Admin.tp(by_player, player)
end
function Admin.bring(player,by_player)
Admin.tp(player, by_player)
end
Admin.add_action('Go To',Admin.go_to)
Admin.add_action('Bring',Admin.bring)
-- Module Return
return setmetatable(ThisModule,{__call=Admin.tp})

View File

@@ -0,0 +1,22 @@
{
"name": "ExpGamingAdmin.Teleport",
"version": "4.0.0",
"description": "Adds three function to admin: tp, bring and go to, these all move the player.",
"location": "FSM_ARCHIVE",
"keywords": [
"Tp",
"Bring",
"Go To",
"Admin",
"ExpGaming",
"Teleport",
"Commands"
],
"dependencies": {
"ExpGamingAdmin.Gui": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,48 @@
--- Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.
-- @module ExpGamingAdmin.KicTempBan@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local Server = require('ExpGamingCore.Server')
local Role = require('ExpGamingCore.Role')
local Game = require('FactorioStdLib.Game')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
end
}
-- Function Define
function Admin.temp_ban(player,by_player,reason)
local player = Game.get_player(player)
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
if not player or Admin.is_banned(player) then return end
Admin.set_banned(player,'temp')
if Sync then Sync.emit_embedded{
title='Player Temp-Ban',
color=Color.to_hex(defines.textcolor.high),
description='A player was jailed.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player_name,
['Reason:']=Admin.create_reason(reason,by_player_name)
} end
game.print({'ExpGamingAdmin.temp-ban',player.name,by_player_name,reason},defines.textcolor.info)
if Admin.move_inventory then Admin.move_inventory(player) end
Role.meta.last_jail = player.name
Server.interface(Role.unassign,true,player,Role.get(player),by_player_name)
Server.interface(Role.assign,true,player,'Jail',by_player_name)
end
Admin.add_action('Temp Ban',Admin.temp_ban)
-- Module Return
return setmetatable(ThisModule,{__call=Admin.temp_ban})

View File

@@ -0,0 +1,24 @@
{
"name": "ExpGamingAdmin.TempBan",
"version": "4.0.0",
"description": "Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.",
"location": "FSM_ARCHIVE",
"keywords": [
"Jail",
"Temp Ban",
"Admin",
"ExpGaming",
"Roles"
],
"dependencies": {
"ExpGamingCore.Server": "^4.0.0",
"ExpGamingCore.Role": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"FactorioStdLib.Color": "?^0.8.0",
"ExpGamingCore.Sync": "?^4.0.0",
"ExpGamingAdmin.ClearInventory": "?^4.0.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,142 @@
--- Adds a warning system into the admin set which can be used by admins and the script.
-- @module ExpGamingAdmin.Warnings@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Admin = require('ExpGamingAdmin')
local Server = require('ExpGamingCore.Server')
local Role = require('ExpGamingCore.Role')
local Game = require('FactorioStdLib.Game')
local Color -- FactorioStdLib.Color@^0.8.0
local Sync -- ExpGamingCore.Sync@^4.0.0
-- Local Variables
local take_action = 8 -- the first admin given warning jumps to this number, this case kick-warn is giving
local remove_warnings_time = {}
local min_time_to_remove_warning = 18000 -- this is in ticks
local punishments = {
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'nothing'},
{'message',{'ExpGamingAdmin-Warnings.message'},defines.textcolor.info},
{'message',{'ExpGamingAdmin-Warnings.message'},defines.textcolor.info},
{'message',{'ExpGamingAdmin-Warnings.kick-warn'},defines.textcolor.med},
{'kick'},
{'message',{'ExpGamingAdmin-Warnings.temp-warn'},defines.textcolor.high},
{'temp-ban'},
{'message',{'ExpGamingAdmin-Warnings.ban-warn'},defines.textcolor.high},
{'message',{'ExpGamingAdmin-Warnings.last-warn'},defines.textcolor.crit},
{'ban'}
}
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end
if loaded_modules['ExpGamingAdmin.Reports'] then
take_action = take_action + 1
table.insert(punishments,take_action,{'report',{'ExpGamingAdmin-Warnings.reported'},defines.textcolor.med})
end
end,
on_post=function()
local highest = nil
for _,role in pairs(Role.roles) do
local power = role.index
if not highest and not role.not_reportable then highest = power-1 end
local _power = power; if highest then _power = power-highest end
if role.not_reportable then remove_warnings_time[power] = 0
else remove_warnings_time[power] = min_time_to_remove_warning*_power end
end
end
}
-- Global Define
local global = {}
Global.register(global,function(tbl) global = tbl end)
-- Function Define
local function give_punishment(player,by_player,reason)
player, by_player = Admin.valid_players(player,by_player)
reason = reason or 'No Other Reason'
local warnings = Admin.get_warnings(player)
local punishment = punishments[warnings]
if not punishment or punishment[1] == 'nothing' then return
elseif punishment[1] == 'message' then
local message = punishment[2]
local colour = punishment[3]
player_return(message,colour,player)
elseif punishment[1] == 'report' then
local message = punishment[2]
local colour = punishment[3]
player_return(message,colour,player)
Admin.report(player,'<server>',reason)
elseif punishment[1] == 'kick' then
Admin.kick(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
elseif punishment[1] == 'temp-ban' then
Admin.temp_ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
elseif punishment[1] == 'ban' then
Admin.ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
end
end
function Admin.get_warnings(player)
player = Game.get_player(player)
return global[player.name] or 0
end
function Admin.give_warning(player,by_player,reason,min)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
min = Game.get_player(by_player) and Game.get_player(by_player) ~= SERVER and take_action or min or 0
local warnings = Admin.get_warnings(player)
if warnings < min then warnings = min-1 end
warnings = warnings+1
global[player.name] = warnings
if warnings > take_action then
player_return({'ExpGamingAdmin-Warnings.warning-given-by',by_player.name},defines.textcolor.info,player)
game.print({'ExpGamingAdmin-Warnings.player-warning',player.name,by_player.name,reason})
end
give_punishment(player,by_player,reason)
end
function Admin.clear_warnings(player,by_player,no_emit)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
global[player.name]=nil
if not no_emit and Sync then
Sync.emit_embedded{
title='Player Clear',
color=Color.to_hex(defines.textcolor.low),
description='A player had their warnings cleared.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player.name,
}
end
end
-- Event Handlers Define
Event.add(defines.events.on_tick,function(event)
if (game.tick % min_time_to_remove_warning) == 0 then
for name,warnings in pairs(global) do
if warnings > 0 then
local role = Role.get_highest(name)
local time_to_remove = remove_warnings_time[role.index]
if (game.tick % time_to_remove) == 0 then
global[name]=warnings-1
if global[name] > 5 then
player_return({'ExpGamingAdmin-Warnings.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.textcolor.low,name)
end
end
end
end
end
end)
-- Module Return
return ThisModule

View File

@@ -0,0 +1,11 @@
[ExpGamingAdmin-Warnings]
warning-given-by=This Warnings Was Given By: __1__
player-warning=__1__ was given a warning by __2__ reason: __3__
temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset
remove-warn=You are had a warning Removed, you have __1__ warnings, next removed in __2__
message=You Are Currently Reciving Warnings From The Script, This Will Continue Unless You Cease And Desist
reported=You Have Been Reported To The Admins By The Script, Further Acction May Be Taken If You Do Not Cease And Desist.
kick-warn=You Are On A Warning To Be KICKED, The Script Will Auto Kick If You Do Not Cease And Desist.
temp-warn=You Are On A Warning To Be TEMP BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
ban-warn=You Are On A Warning To Be BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
last-warn=YOU ARE ON A LAST WARNING TO BE BANNED, THE SCRIPT WILL AUTO BAN IF YOU DO NOT CEASE AND DESIST.

View File

@@ -0,0 +1,10 @@
[ExpGamingAdmin-Warnings]
warning-given-by=This warning was given by: __1__
player-warning=__1__ was given a warning by __2__ for: __3__
remove-warn=One of your warnings expired. You have __1__ warnings left, next warning will be removed in __2__
message=You are currently being warned by the system. These will continue until you cease and desist.
reported=You have been reported to the admins by the system. Further action may be taken if you do not cease and desist.
kick-warn=This is your last warning before you get kicked. The system will automatically kick you if you do not cease and desist.
temp-warn=This is your last warning before you get temporary banned. The system will automatically ban you if you do not cease and desist.
ban-warn=WARNING: This is your last warning before you get BANNED. The system will automatically BAN you if you do not cease and desist.
last-warn=WARNING: This is your last warning before you get PERMANENTLY BANNED. The system will automatically PERMANENTLY BAN you if you do not cease and desist.

View File

@@ -0,0 +1,11 @@
[ExpGamingAdmin-Warnings]
warning-given-by=This Warnings Was Given By: __1__
player-warning=__1__ was given a warning by __2__ reason: __3__
temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset
remove-warn=You are had a warning Removed, you have __1__ warnings, next removed in __2__
message=You Are Currently Reciving Warnings From The Script, This Will Continue Unless You Cease And Desist
reported=You Have Been Reported To The Admins By The Script, Further Acction May Be Taken If You Do Not Cease And Desist.
kick-warn=You Are On A Warning To Be KICKED, The Script Will Auto Kick If You Do Not Cease And Desist.
temp-warn=You Are On A Warning To Be TEMP BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
ban-warn=You Are On A Warning To Be BANNED, The Script Will Auto Ban If You Do Not Cease And Desist.
last-warn=YOU ARE ON A LAST WARNING TO BE BANNED, THE SCRIPT WILL AUTO BAN IF YOU DO NOT CEASE AND DESIST.

View File

@@ -0,0 +1,11 @@
[ExpGamingAdmin-Warnings]
warning-given-by=Deze waarschuwing is gegeven door: __1__
player-warning=__1__ is gewaarschuwd door __2__ met de reden: __3__
temp-ban=__1__ is verbannen door __2__ en is gejailed tot de volgende reset.
remove-warn=Een waarschuwing is verlopen. Je hebt nu nog maar __1__ waarschuwing, volgende waarschuwing verloopt in __2__
message=Je ontvangt waarschuwingen door het systeem. Deze waarschuwingen stoppen niet tot je stopt met wat je verkeerd doet.
reported=Je bent gerapporteerd aan de administrators door het systeem. Je zal bestraft worden als je niet stopt met wat je verkeerd doet.
kick-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je gekickt wordt.
temp-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je tijdelijk verbannen wordt.
ban-warn=WAARSCHUWING: Dit is je laatste waarschuwing voordat je permanent verbannen wordt.
last-warn=DIT IS JE LAATSTE WAARSCHUWING. Het systeem zal je automatisch VERBANNEN als je niet stopt met wat je verkeerd doet.

View File

@@ -0,0 +1,10 @@
[ExpGamingAdmin-Warnings]
warning-given-by=Den här varningen gavs av: __1__
player-warning=__1__ var tillfälligt bannlyst av __2__ och kommer att förbli i fängelset tills nästa återställning (reset)
remove-warn=En av dina varningar har gått ut. Du har __1__ varning kvar, nästa varning kommer at tas bort om __2__
message=Du får för nuvarande varningar av systemet. De kommer fortsätta tills du upphör med överträdelsen.
reported= Du har blivit rapporterad till administrationen av systemet. Mer påföljd kan komma att tas om du inte upphör med överträdelsen.
kick-warn=Det här är din sista varning innan du blir sparkad. Systemet kommer att automatisk sparka dig om du inte upphör med överträdelsen
temp-warn=Det här är din sista varning innan du blir tillfälligt bannlyst. Systemet kommer att automatiskt bannlysa dig om du inte upphör överträdelsen
ban-warn=VARNING: Det här är din sista varning innan du blir bannlyst. Systemet kommer att automatisk bannlysa dig om du inte upphör med överträdelsen.
last-warn=VARNING: Det här är din sista varning innan du blir permanent bannlyst. Systemet kommer att automatiskt permanent bannlysa dig om du inte upphör med överträdelsen.

View File

@@ -0,0 +1,26 @@
{
"name": "ExpGamingAdmin.Warnings",
"version": "4.0.0",
"description": "Adds a warning system into the admin set which can be used by admins and the script.",
"location": "FSM_ARCHIVE",
"keywords": [
"Warning",
"Admin",
"ExpGaming",
"Report",
"Kick",
"Punishments",
"Ban"
],
"dependencies": {
"ExpGamingCore.Server": "^4.0.0",
"ExpGamingCore.Role": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"FactorioStdLib.Color": "?^0.8.0",
"ExpGamingAdmin.Reports": "?^4.0.0",
"ExpGamingCore.Sync": "?^4.0.0",
"ExpGamingAdmin": "^4.0.0"
},
"collection": "ExpGamingAdmin@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,103 @@
--- The base functions required to make the others work.
-- @module ExpGamingAdmin@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias Admin
-- Module Require
local Game = require('FactorioStdLib.Game')
local Color = require('FactorioStdLib.Color')
local Role -- ExpGamingCore.Role@^4.0.0
local Sync -- ExpGamingCore.Sync@^4.0.0
local Server -- ExpGamingCore.Server@^4.0.0
-- Module Define
local module_verbose = false
local Admin = {
on_init=function()
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
if loaded_modules['ExpGamingCore.Server'] then
Server = require('ExpGamingCore.Server')
Server.add_module_to_interface('Admin','ExpGamingAdmin')
end
end,
actions={},
action_functions={},
action_names={}
}
-- Global Define
local global = {
banned = {}
}
Global.register(global,function(tbl) global = tbl end)
-- Function Define
function Admin.valid_players(player,by_player)
player = Game.get_player(player)
by_player = Game.get_player(by_player) or SERVER
return player, by_player
end
function Admin.create_reason(reason,name)
reason = reason or 'No Reason'
if not string.find(string.lower(reason),string.lower(name)) then reason = reason..' - '..name end
if Sync and Sync.info.date ~= '0000/00/00' and not string.find(string.lower(reason),Sync.info.date) then reason = reason..' - '..Sync.info.date end
if not string.find(string.lower(reason),'appeal') then reason = reason..' - Visit www.explosivegaming.nl to appeal.' end
return reason
end
function Admin.allowed(player)
player = Game.get_player(player)
if Role then
return Role.allowed(player,'admin-commands')
else return player.admin end
end
function Admin.set_banned(player,set)
player = Game.get_player(player)
if not player then return false end
global.banned[player.name] = set
end
function Admin.is_banned(player,detail)
player = Game.get_player(player)
if not player then return false end
local banned = global.banned[player.name]
if banned == true then return true end
if not banned then return false end
if detail then return banned
else return true end
end
function Admin.add_action(action,callback)
verbose('Added admin action: '..action)
Admin.actions[string.lower(action)] = table.insert(Admin.action_names,action)
Admin.action_functions[string.lower(action)] = callback
end
function Admin.take_action(action,player,by_player,reason)
if Admin.action_functions[string.lower(action)] then Admin.action_functions[string.lower(action)](player,by_player,reason) end
if Admin[action] then Admin[action](player,by_player,reason) end
end
function Admin.clear_player(player,by_player)
player, by_player = Admin.valid_players(player,by_player)
if not player then return end
if Server and Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player) end
if Admin.clear_warnings then Admin.clear_warnings(player,by_player,true) end
if Admin.clear_reports then Admin.clear_reports(player,by_player,true) end
if Server and Role.has_flag(player,'is_jail') then Server.interface(Role.revert,true,player,by_player,2) end
if Sync then Sync.emit_embedded{
title='Player Clear',
color=Color.to_hex(defines.textcolor.low),
description='A player had their reports and warnings cleared.',
['Player:']='<<inline>>'..player.name,
['By:']='<<inline>>'..by_player.name,
} end
Admin.set_banned(player,false)
end
-- Module Return
return Admin

View File

@@ -0,0 +1,15 @@
[ExpGamingAdmin]
name=Admin-Befehle
tooltip=Die mächtigsten Befehle sind hier zuhause.
no-info-file=Die Informationsdatei wurde nicht gefunden.
message=Wähle einen Spieler und eine Aktion. Stell vor dem Ausführen sicher, dass der Richtige ist!
warning=Achtung, dieser Spieler hat einen höheren Rang als du selbst, weshalb du seinen Rang nicht ändern kannst.
short-reason=Achtung, dies ist ein sehr kurzer Grund. Bitte versuche, mehr Informationen anzugeben. (Warning: The reason is too short. UPDATE)
rank-high=Dieser Spieler hat einen hohen Rang. Bitte benutze nur Ingame-Befehle gegen diese Person, wenn du dir sicher bist!
invalid=Der Spieler oder die Aktion war ungültig. Bitte versuche es noch einmal!
take-action= Ergreife Maßnahme
tooltip-ban=Banne Spieler
tooltip-kick=Kicke Spieler
tooltip-jail=Sperre Spieler ins Gefängnis
tooltip-go-to=Gehe zum Spieler
tooltip-bring=Bringe den Spieler zu dir

View File

@@ -0,0 +1,21 @@
[ExpGamingAdmin]
name=Admin Commands
tooltip=Admin commands make their home here
no-info-file=No info file was found
message=Please select a player and an action to take. Make sure to choose the correct one!
warning=Warning: This player outranks you. Therefore, you cannot edit their rank.
short-reason=Warning: The reason is too short.
rank-high=Warning: This player outranks you. Therefore, you cannot edit their rank.
invalid=The player or the action is invalid. Please try again!
take-action=Take Action
tooltip-ban=Ban Player
tooltip-kick=Kick Player
tooltip-jail=Jail Player
tooltip-go-to=Go To Player
tooltip-bring=Bring Player
temp-ban=__1__ was temporary banned by __2__ and will remain in jail until next reset
report=Report Player
cant-report-ban=Invalid player as player is banned; Either unban or use /clear-all <player_name>
low-print=__1__ has been reported by a user for: __2__
high-print=__1__ has been reported by __2__ for: __3__
cant-report=This player can't be reported.

View File

@@ -0,0 +1,15 @@
[ExpGamingAdmin]
name=Commandes Admin
tooltip=Des commandes très puissantes résident ici.
no-info-file=Aucun fichier info trouvé
message=Veuillez sélectionner un joueur et une action, faites en sorte que ce soit la bonne !
warning=Attention, ce joueur est de rang supérieur au vôtre, vous ne pouvez le modifier.
short-reason=Attention, la raison indiquée est trop courte. Soyez concis mais aussi précis. (Warning: The reason is too short. UPDATE)
rank-high=Ce joueur est de rang supérieur, veuillez utiliser une commande dont vous maîtriser l'utilisation !
invalid=Le Joueur ou l'action est invalide, ré-essayez !
take-action=Agir
tooltip-ban=Bannir un Joueur
tooltip-kick=Exclure un Joueur
tooltip-jail=Emprisonner un Joueur
tooltip-go-to=Aller à la position d'un Joueur
tooltip-bring=Amener le Joueur à soi

View File

@@ -0,0 +1,15 @@
[ExpGamingAdmin]
name=Admin Commands
tooltip=Admin Commands kan je hier vinden.
no-info-file=Infobestand niet gevonden.
message=Selecteer een speler en de bijbehorende actie. Wees er zeker van dat je de correcte actie kiest.
warning=Fout: Je kan de rank van deze speler niet aanpassen omdat het jouw rank overtreft.
short-reason=Fout: De reden is te kort. (Warning: The reason is too short. UPDATE)
rank-high=Fout: Deze speler overtreft jouw rank.
invalid=Fout: De speler kan niet gevonden worden en/of de actie is onjuist. Probeer opnieuw!
take-action=Actie ondernemen
tooltip-ban=Ban speler
tooltip-kick=Kick speler
tooltip-jail=Jail speler
tooltip-go-to=Ga naar speler
tooltip-bring=Breng speler

View File

@@ -0,0 +1,19 @@
[ExpGamingAdmin]
name=Adminkommandon
tooltip=Adminkommando gör dit hem här
no-info-file=Ingen informationsfil kunde hittas
message=Var snäll och välj en spelare och en åtgärd att utfärda, se till att du väljer den rätta!
warning=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang.
short-reason=Warning: Skälet är för kort.
rank-high=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang.
invalid=Spelaren eller åtgärden är ogiltig. Var vänlig och försök igen!
take-action=Utför åtgärd.
tooltip-ban=Bannlys Spelare
tooltip-kick=Sparka Spelare
tooltip-jail=Fängsla Spelare
tooltip-go-to=Gå till Spelare
tooltip-bring=Hämta spelare
report=Rapportera Spelare
low-print=__1__ har blivit rapporterad av __2__ för: __3__
high-print=__1__ har blivit rapporterad av __2__ för: __3__
cant-report=Den här spelaren kan inte bli rapporterad.

View File

@@ -0,0 +1,37 @@
{
"name": "ExpGamingAdmin",
"version": "4.0.0",
"description": "A set of useful admin commands and functions that can be used by other modules.",
"location": "FSM_ARCHIVE",
"keywords": [
"Admin",
"ExpGaming",
"Set",
"Commands",
"Functions",
"Scripts",
"Useful"
],
"author": "Cooldude2606",
"contact": "Discord: Cooldude2606#5241",
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
"submodules": {
"ExpGamingAdmin": "4.0.0",
"ExpGamingAdmin.Ban": "4.0.0",
"ExpGamingAdmin.ClearInventory": "4.0.0",
"ExpGamingAdmin.Gui": "4.0.0",
"ExpGamingAdmin.Jail": "4.0.0",
"ExpGamingAdmin.Kick": "4.0.0",
"ExpGamingAdmin.Reports": "4.0.0",
"ExpGamingAdmin.Teleport": "4.0.0",
"ExpGamingAdmin.TempBan": "4.0.0",
"ExpGamingAdmin.Warnings": "4.0.0",
"ExpGamingAdmin.Commands": "4.0.0"
},
"dependencies": {
"ExpGamingCore.Role": "?^4.0.0",
"ExpGamingCore.Sync": "?^4.0.0",
"ExpGamingCore.Server": "?^4.0.0",
"FactorioStdLib.Game": "^0.8.0"
}
}