mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-17 00:40:42 +09:00
Rework features into a Feature class with per field events
Review points from Cooldude: - Feature.register(name[, config]) is required again and returns a feature object. Each feature has its config, its fields, and its overrides, so one registry holds all the data. Only the overrides are stored. On load each feature points at its own stored table again. - The methods are feature:guard(lib), feature:update_config(enabled, values), and feature:is_enabled(). Feature.get(name) looks up a feature, and commands flag the feature object. - update_config raises on_config_updated once per changed value, with the feature name, path, old value, and new value. The gui refresh only reacts to the "enabled" path. - apply only sets values. on_apply is gone. Lookup sets built from lists use Feature.to_set, which is cached by the list itself. A replaced list gets a new set, so the sets are also correct after a load. Protection exposes getters for its protected names and types. Web: settings use small inputs, the same size as the config pages. Fields are shaped like clusterio config field definitions. A field with an inputComponent renders the component registered with the web interface, so the role setting now uses core's role input, and other plugin inputs can be used later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4bc1773c82
commit
628e4df514
26 files changed
+468
-430
No files matched your search
@@ -3,17 +3,18 @@ Kicks players when all players on the server are afk
|
||||
]]
|
||||
|
||||
local Async = require("modules/exp_util/async")
|
||||
local Features = require("modules/exp_scenario/features")
|
||||
local Feature = require("modules/exp_scenario/features")
|
||||
local Roles = require("modules/exp_roles")
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local config = Features.config("afk_kick", {
|
||||
local feature = Feature.register("afk_kick", {
|
||||
admin_as_active = true, --- @setting admin_as_active When true admins will be treated as active regardless of afk time
|
||||
trust_as_active = true, --- @setting trust_as_active When true trusted players (by playtime) will be treated as active regardless of afk time
|
||||
active_role_id = Features.optional("number"), --- @setting active_role_id Players with this role or higher are treated as active regardless of afk time
|
||||
active_role_id = Feature.optional("number"), --- @setting active_role_id Players with this role or higher are treated as active regardless of afk time
|
||||
afk_minutes = 10, --- @setting afk_minutes The time in minutes that must pass for a player to be considered afk
|
||||
kick_minutes = 30, --- @setting kick_minutes The time in minutes that must pass without any active players for all players to be kicked
|
||||
trust_minutes = 600, --- @setting trust_minutes The time in minutes that a player must be online for to count as trusted
|
||||
})
|
||||
local config = feature.config
|
||||
|
||||
local ticks_per_minute = 3600
|
||||
|
||||
@@ -92,7 +93,7 @@ end
|
||||
|
||||
local e = defines.events
|
||||
|
||||
return Features.guard(config, {
|
||||
return feature:guard{
|
||||
events = {
|
||||
[e.on_player_joined_game] = on_player_joined_game,
|
||||
},
|
||||
@@ -100,4 +101,4 @@ return Features.guard(config, {
|
||||
[60 * 60 * 30] = check_afk_players,
|
||||
},
|
||||
has_active_player = has_active_player,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user