From 7fb1a14cb3935cabf99d86bb169944d8d8659da4 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 24 Apr 2021 01:53:05 +0100 Subject: [PATCH] Changed ignore_role to ignore_permission --- config/expcore/roles.lua | 3 ++- config/protection.lua | 2 +- modules/control/protection.lua | 11 ++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/config/expcore/roles.lua b/config/expcore/roles.lua index 9b826202..46cd7072 100644 --- a/config/expcore/roles.lua +++ b/config/expcore/roles.lua @@ -210,7 +210,8 @@ Roles.new_role('Regular','Reg') 'command/rainbow', 'command/go-to-spawn', 'command/me', - 'standard-decon' + 'standard-decon', + 'bypass-entity-protection' } :set_auto_assign_condition(function(player) if player.online_time >= hours3 then diff --git a/config/protection.lua b/config/protection.lua index 74281985..fbba783d 100644 --- a/config/protection.lua +++ b/config/protection.lua @@ -1,6 +1,6 @@ return { ignore_admins = true, --- @setting ignore_admins If admins are ignored by the protection filter - ignore_role = 'Regular', --- @setting ignore_role This role will be ignored by the protection filter, leave nil if expcore.roles is not used + ignore_permission = 'bypass-entity-protection', --- @setting ignore_permission Players with this permission will be ignored by the protection filter, leave nil if expcore.roles is not used repeat_count = 5, --- @setting repeat_count Number of protected entities to be removed to count as repeated repeat_lifetime = 3600*20, --- @setting repeat_lifetime How old repeats must be before being removed refresh_rate = 3600*5, --- @setting refresh_rate How often old repeats will be removed diff --git a/modules/control/protection.lua b/modules/control/protection.lua index dbb22b21..e8320378 100644 --- a/modules/control/protection.lua +++ b/modules/control/protection.lua @@ -32,12 +32,9 @@ for _, config_key in ipairs{'always_protected_names', 'always_protected_types', end -- convert ignore role if present -if config.ignore_role then - local Roles = require 'expcore.roles' - local role = Roles.get_role_by_name(config.ignore_role) - config.ignore_role = function(player) - return Roles.player_has_role(player, role) - end +local Roles +if config.ignore_permission then + Roles = require 'expcore.roles' --- @dep expcore.roles end ----- Global Variables ----- @@ -157,7 +154,7 @@ Event.add(defines.events.on_pre_player_mined_item, function(event) local player = game.get_player(event.player_index) -- Check if the player should be ignored if config.ignore_admins and player.admin then return end - if config.ignore_role and config.ignore_role(player) then return end + if config.ignore_permission and Roles.player_allowed(player, config.ignore_permission) then return end -- Check if the entity is protected if check_always_protected(entity) or EntityProtection.is_entity_protected(entity)