mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
Move the scenario onto exp_roles and remove the legacy role system
Every call site of expcore.roles now uses exp_roles, and the legacy module, its config, and the glue which refreshed guis on role events are deleted. Where a file only renamed the require and the permission strings the change is mechanical; the rest: - Jail is now "give the Jail role" and unjail "take it away". The role has a higher priority than every other so holding it suppresses them, which is what stashing and restoring the roles was for. - The command role authority derives exp_scenario.command.<name> from the command name, and the role parsers use player_outranks rather than comparing indexes with their own root check. - The admin and spectator triggers, and the gui refresh on role changes, live in exp_scenario/control/roles.lua; the system commands trigger stays with the command authority. - The player list warn button is keyed on create_warning, the permission the command behind it already required, and report on create_report. Both were keyed on names no role held, so only root ever saw them. - The warps and tasks configs say exp_roles where they said expcore.roles. - The role tables the readme and player list read are replaced by get_player_names and get_roles. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
eb715cc176
commit
7034f17b5d
@@ -4,7 +4,7 @@ Various bonus related event handlers
|
||||
TODO Refactor this fully, this is temp to get it out of the player bonus gui file
|
||||
]]
|
||||
|
||||
local Roles = require("modules/exp_legacy/expcore/roles")
|
||||
local Roles = require("modules/exp_roles")
|
||||
local config = require("modules/exp_legacy/config/bonus")
|
||||
|
||||
--- @param event EventData.on_force_created
|
||||
@@ -26,7 +26,7 @@ end
|
||||
--- @param event EventData.on_player_died
|
||||
local function fast_respawn(event)
|
||||
local player = assert(game.get_player(event.player_index))
|
||||
if Roles.player_has_flag(player, "instant-respawn") then
|
||||
if Roles.player_has_permission(player, "exp_scenario.player.instant_respawn") then
|
||||
player.ticks_to_respawn = 120
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Adds auto replies to chat messages, as well as chat commands
|
||||
]]
|
||||
|
||||
local Roles = require("modules.exp_legacy.expcore.roles")
|
||||
local Roles = require("modules/exp_roles")
|
||||
local config = require("modules.exp_legacy.config.chat_reply")
|
||||
local prefix = config.command_prefix
|
||||
local prefix_len = string.len(prefix)
|
||||
@@ -20,7 +20,7 @@ local function on_console_chat(event)
|
||||
-- Check if the player can chat commands
|
||||
local commands_allowed = true
|
||||
if config.command_admin_only and not player.admin then commands_allowed = false end
|
||||
if config.command_permission and not Roles.player_allowed(player, config.command_permission) then commands_allowed = false end
|
||||
if config.command_permission and not Roles.player_has_permission(player, config.command_permission) then commands_allowed = false end
|
||||
|
||||
-- Check if a key word appears in the message
|
||||
for key_word, reply in pairs(config.messages) do
|
||||
|
||||
@@ -3,7 +3,7 @@ Log certain actions into a file when events are triggered
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Roles = require("modules.exp_legacy.expcore.roles")
|
||||
local Roles = require("modules/exp_roles")
|
||||
local config = require("modules.exp_legacy.config.deconlog")
|
||||
|
||||
local seconds_time_format = ExpUtil.format_time_factory{ format = "short", hours = true, minutes = true, seconds = true }
|
||||
@@ -79,7 +79,7 @@ end
|
||||
local function get_log_player(event)
|
||||
local player = assert(game.get_player(event.player_index))
|
||||
|
||||
if Roles.player_has_flag(player, "deconlog-bypass") then
|
||||
if Roles.player_has_permission(player, "exp_scenario.bypass.deconstruction_log") then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Makes trees which are marked for decon "decay" quickly to allow faster building
|
||||
|
||||
local Gui = require("modules/exp_gui")
|
||||
local Async = require("modules/exp_util/async")
|
||||
local Roles = require("modules.exp_legacy.expcore.roles")
|
||||
local Roles = require("modules/exp_roles")
|
||||
|
||||
local PlayerData = require("modules.exp_legacy.expcore.player_data")
|
||||
local HasEnabledDecon = PlayerData.Settings:combine("HasEnabledDecon")
|
||||
@@ -57,9 +57,9 @@ local remove_trees_async =
|
||||
--- @param player LuaPlayer
|
||||
--- @return "fast" | "allow" | "disallow"
|
||||
local function get_permission(player)
|
||||
if Roles.player_allowed(player, "fast-tree-decon") then
|
||||
if Roles.player_has_permission(player, "exp_scenario.decon.fast_trees") then
|
||||
return HasEnabledDecon:get(player) and "fast" or "allow"
|
||||
elseif Roles.player_allowed(player, "standard-decon") then
|
||||
elseif Roles.player_has_permission(player, "exp_scenario.decon.standard") then
|
||||
return "allow"
|
||||
else
|
||||
return "disallow"
|
||||
@@ -101,7 +101,7 @@ Gui.toolbar.create_button{
|
||||
tooltip = { "exp_fast-decon.tooltip-main" },
|
||||
auto_toggle = true,
|
||||
visible = function(player, _)
|
||||
return Roles.player_allowed(player, "fast-tree-decon")
|
||||
return Roles.player_has_permission(player, "exp_scenario.decon.fast_trees")
|
||||
end
|
||||
}:on_click(function(def, player, element)
|
||||
local state = Gui.toolbar.get_button_toggled_state(def, player)
|
||||
|
||||
@@ -3,7 +3,7 @@ Disable new players from having certain items in their inventory, most commonly
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Roles = require("modules.exp_legacy.expcore.roles")
|
||||
local Roles = require("modules/exp_roles")
|
||||
local config = require("modules.exp_legacy.config.nukeprotect")
|
||||
|
||||
--- Check all items in the given inventory
|
||||
@@ -12,7 +12,7 @@ local config = require("modules.exp_legacy.config.nukeprotect")
|
||||
--- @param banned_items string[]
|
||||
local function check_items(player, type, banned_items)
|
||||
-- If the player has perms to be ignored, then they should be
|
||||
if config.ignore_permission and Roles.player_allowed(player, config.ignore_permission) then return end
|
||||
if config.ignore_permission and Roles.player_has_permission(player, config.ignore_permission) then return end
|
||||
if config.ignore_admins and player.admin then return end
|
||||
|
||||
local items = {} --- @type LuaItemStack[]
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
--[[-- Control - Roles
|
||||
Applies the in game effects of the player permissions defined by the scenario
|
||||
]]
|
||||
|
||||
local Gui = require("modules/exp_gui")
|
||||
local Roles = require("modules/exp_roles")
|
||||
|
||||
Roles.define_permission_trigger("exp_scenario.player.admin", function(player, state)
|
||||
player.admin = state
|
||||
end)
|
||||
|
||||
Roles.define_permission_trigger("exp_scenario.player.spectator", function(player, state)
|
||||
player.spectator = state
|
||||
end)
|
||||
|
||||
return {
|
||||
events = {
|
||||
--- @diagnostic disable-next-line: access-invisible
|
||||
[Roles.events.on_player_roles_changed] = Gui._ensure_consistency,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user