mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Fixed Existing Lua Check Errors
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
--- This is a very simple config file which adds a admin only auth functio;
|
||||
--- This is a very simple config file which adds a admin only auth function;
|
||||
-- not much to change here its more so it can be enabled and disabled from ./config/file_loader.lua;
|
||||
-- either way you can change the requirements to be "admin" if you wanted to
|
||||
-- @config Commands-Auth-Admin
|
||||
|
||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
|
||||
Commands.add_authenticator(function(player,command,tags,reject)
|
||||
-- luacheck:ignore 212/command
|
||||
Commands.add_authenticator(function(player, command, tags, reject)
|
||||
if tags.admin_only then
|
||||
if player.admin then
|
||||
return true
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||
|
||||
Commands.add_authenticator(function(player,command,tags,reject)
|
||||
-- luacheck:ignore 212/tags
|
||||
Commands.add_authenticator(function(player, command, tags, reject)
|
||||
if Roles.player_allowed(player,'command/'..command) then
|
||||
return true
|
||||
else
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--[[-- This file contains some common command param parse functions;
|
||||
this file is less of a config and more of a requirement but you may wish to change how some behave;
|
||||
as such you need to be confident with lua but you edit this config file;
|
||||
use Commands.add_parse('name',function(input,player,reject) end) to add a parse;
|
||||
use Commands.add_parse('name',function(input, player, reject) end) to add a parse;
|
||||
see ./expcore/commands.lua for more details
|
||||
@config Commands-Parse
|
||||
@usage Adds Parses:
|
||||
@@ -22,9 +22,8 @@ see ./expcore/commands.lua for more details
|
||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
local Game = require 'utils.game' --- @dep utils.game
|
||||
|
||||
|
||||
|
||||
Commands.add_parse('boolean',function(input,player,reject)
|
||||
-- luacheck:ignore 212/player
|
||||
Commands.add_parse('boolean',function(input, player)
|
||||
if not input then return end -- nil check
|
||||
input = input:lower()
|
||||
if input == 'yes'
|
||||
@@ -37,7 +36,7 @@ Commands.add_parse('boolean',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('string-options',function(input,player,reject,options)
|
||||
Commands.add_parse('string-options',function(input, player, reject, options)
|
||||
if not input then return end -- nil check
|
||||
input = input:lower()
|
||||
for option in options do
|
||||
@@ -48,7 +47,7 @@ Commands.add_parse('string-options',function(input,player,reject,options)
|
||||
return reject{'reject-string-options',options:concat(', ')}
|
||||
end)
|
||||
|
||||
Commands.add_parse('string-max-length',function(input,player,reject,max_length)
|
||||
Commands.add_parse('string-max-length',function(input, player, reject, max_length)
|
||||
if not input then return end -- nil check
|
||||
local length = input:len()
|
||||
if length > max_length then
|
||||
@@ -58,7 +57,7 @@ Commands.add_parse('string-max-length',function(input,player,reject,max_length)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('number',function(input,player,reject)
|
||||
Commands.add_parse('number',function(input, player, reject)
|
||||
if not input then return end -- nil check
|
||||
local number = tonumber(input)
|
||||
if not number then
|
||||
@@ -68,7 +67,7 @@ Commands.add_parse('number',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('integer',function(input,player,reject)
|
||||
Commands.add_parse('integer',function(input, player, reject)
|
||||
if not input then return end -- nil check
|
||||
local number = tonumber(input)
|
||||
if not number then
|
||||
@@ -78,27 +77,27 @@ Commands.add_parse('integer',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('number-range',function(input,player,reject,range_min,range_max)
|
||||
local number = Commands.parse('number',input,player,reject)
|
||||
Commands.add_parse('number-range',function(input, player, reject, range_min, range_max)
|
||||
local number = Commands.parse('number',input, player, reject)
|
||||
if not number then return end -- nil check
|
||||
if number < range_min or number > range_max then
|
||||
return reject{'expcore-commands.reject-number-range',range_min,range_max}
|
||||
return reject{'expcore-commands.reject-number-range',range_min, range_max}
|
||||
else
|
||||
return number
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('integer-range',function(input,player,reject,range_min,range_max)
|
||||
local number = Commands.parse('integer',input,player,reject)
|
||||
Commands.add_parse('integer-range',function(input, player, reject, range_min, range_max)
|
||||
local number = Commands.parse('integer',input, player, reject)
|
||||
if not number then return end -- nil check
|
||||
if number < range_min or number > range_max then
|
||||
return reject{'expcore-commands.reject-number-range',range_min,range_max}
|
||||
return reject{'expcore-commands.reject-number-range',range_min, range_max}
|
||||
else
|
||||
return number
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('player',function(input,player,reject)
|
||||
Commands.add_parse('player',function(input, player, reject)
|
||||
if not input then return end -- nil check
|
||||
local input_player = Game.get_player_from_any(input)
|
||||
if not input_player then
|
||||
@@ -108,8 +107,8 @@ Commands.add_parse('player',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('player-online',function(input,player,reject)
|
||||
local input_player = Commands.parse('player',input,player,reject)
|
||||
Commands.add_parse('player-online',function(input, player, reject)
|
||||
local input_player = Commands.parse('player',input, player, reject)
|
||||
if not input_player then return end -- nil check
|
||||
if not input_player.connected then
|
||||
return reject{'expcore-commands.reject-player-online'}
|
||||
@@ -118,8 +117,8 @@ Commands.add_parse('player-online',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('player-alive',function(input,player,reject)
|
||||
local input_player = Commands.parse('player-online',input,player,reject)
|
||||
Commands.add_parse('player-alive',function(input, player, reject)
|
||||
local input_player = Commands.parse('player-online',input, player, reject)
|
||||
if not input_player then return end -- nil check
|
||||
if not input_player.character or not input_player.character.health or input_player.character.health <= 0 then
|
||||
return reject{'expcore-commands.reject-player-alive'}
|
||||
@@ -128,7 +127,7 @@ Commands.add_parse('player-alive',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('force',function(input,player,reject)
|
||||
Commands.add_parse('force',function(input, player, reject)
|
||||
if not input then return end -- nil check
|
||||
local force = game.forces[input]
|
||||
if not force then
|
||||
@@ -138,7 +137,7 @@ Commands.add_parse('force',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('surface',function(input,player,reject)
|
||||
Commands.add_parse('surface',function(input, player, reject)
|
||||
if not input then return end
|
||||
local surface = game.surfaces[input]
|
||||
if not surface then
|
||||
|
||||
@@ -12,14 +12,15 @@ local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||
local auto_complete = _C.auto_complete --- @dep expcore.common
|
||||
require 'config.expcore.command_general_parse'
|
||||
|
||||
Commands.add_parse('role',function(input,player,reject)
|
||||
-- luacheck:ignore 212/player
|
||||
Commands.add_parse('role',function(input, player, reject)
|
||||
if not input then return end
|
||||
local roles = Roles.config.order
|
||||
local rev_roles = {}
|
||||
for i=#roles,1,-1 do
|
||||
table.insert(rev_roles,roles[i])
|
||||
for i=#roles, 1,-1 do
|
||||
table.insert(rev_roles, roles[i])
|
||||
end
|
||||
local role = auto_complete(rev_roles,input)
|
||||
local role = auto_complete(rev_roles, input)
|
||||
role = Roles.get_role_by_name(role)
|
||||
if not role then
|
||||
return reject{'expcore-role.reject-role'}
|
||||
@@ -28,8 +29,8 @@ Commands.add_parse('role',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('player-role',function(input,player,reject)
|
||||
local input_player = Commands.parse('player',input,player,reject)
|
||||
Commands.add_parse('player-role',function(input, player, reject)
|
||||
local input_player = Commands.parse('player',input, player, reject)
|
||||
if not input_player then return end -- nil check
|
||||
local player_highest = Roles.get_player_highest_role(player)
|
||||
local input_player_highest = Roles.get_player_highest_role(input_player)
|
||||
@@ -40,14 +41,14 @@ Commands.add_parse('player-role',function(input,player,reject)
|
||||
end
|
||||
end)
|
||||
|
||||
Commands.add_parse('player-role-online',function(input,player,reject)
|
||||
local input_player = Commands.parse('player-role',input,player,reject)
|
||||
Commands.add_parse('player-role-online',function(input, player, reject)
|
||||
local input_player = Commands.parse('player-role',input, player, reject)
|
||||
if not input_player then return end -- nil check
|
||||
return Commands.parse('player-online',input_player,player,reject)
|
||||
return Commands.parse('player-online',input_player, player, reject)
|
||||
end)
|
||||
|
||||
Commands.add_parse('player-role-alive',function(input,player,reject)
|
||||
local input_player = Commands.parse('player-role',input,player,reject)
|
||||
Commands.add_parse('player-role-alive',function(input, player, reject)
|
||||
local input_player = Commands.parse('player-role',input, player, reject)
|
||||
if not input_player then return end -- nil check
|
||||
return Commands.parse('player-alive',input_player,player,reject)
|
||||
return Commands.parse('player-alive',input_player, player, reject)
|
||||
end)
|
||||
@@ -6,7 +6,7 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
local Global = require 'utils.global' --- @dep utils.global
|
||||
|
||||
local disabled_commands = {}
|
||||
Global.register(disabled_commands,function(tbl)
|
||||
Global.register(disabled_commands, function(tbl)
|
||||
disabled_commands = tbl
|
||||
end)
|
||||
|
||||
@@ -22,7 +22,8 @@ function Commands.enable(command_name)
|
||||
disabled_commands[command_name] = nil
|
||||
end
|
||||
|
||||
Commands.add_authenticator(function(player,command,tags,reject)
|
||||
-- luacheck:ignore 212/player 212/tags
|
||||
Commands.add_authenticator(function(player, command, tags, reject)
|
||||
if disabled_commands[command] then
|
||||
return reject{'command-auth.command-disabled'}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user