mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
- Roles are objects and everything done to or with a role is a method on it: assign, unassign, has_player, has_permission, is_higher_than, is_lower_than, get_players, get_player_names, print. Assignment has one entry point, role:assign(player, options), with local_only as an option rather than a second function. - Roles are looked up by clusterio id with get_role; get_role_by_name searches the list for the few places, such as configs, which only know a name. The name map and the ordered list are gone, get_roles sorts on demand and the index field is replaced by the comparison methods. - Players are LuaPlayer objects only, with nil or index 0 for the server. - get_higher_roles and get_lower_roles replace print_to_roles_higher and print_to_roles_lower, call sites loop over them with role:print. - Permission groups are removed from roles again, exp_groups owns the mapping from roles to groups. - Seeding is a SeedRolesRequest behind a button on the roles page rather than running on first start, and creates only the roles; the player assignments are dropped. The seed lists each permission once at the lowest role which has it and lets the parent chain carry it up. - System commands unlock for core.admin rather than a permission of their own. - Role metatables are registered with Storage.register_metatable so the methods survive save and load, which the role records in storage needed. - The player list auth uses Roles.player_outranks directly, and the event carries role ids rather than names. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages";
|
|
|
|
declare module "@clusterio/lib" {
|
|
export interface InstanceConfigFields {
|
|
"exp_roles.sync_mode": "disabled" | "enabled" | "bidirectional";
|
|
}
|
|
}
|
|
|
|
// The in game properties of a role are part of the role, so they are covered by
|
|
// the core role permissions rather than permissions of their own. Assignments
|
|
// are only ever sent between the controller and an instance, so they need none.
|
|
|
|
export const plugin: lib.PluginDeclaration = {
|
|
name: "exp_roles",
|
|
title: "ExpGaming - Roles",
|
|
description: "Clusterio plugin providing syncing of in game roles",
|
|
|
|
features: [
|
|
"SavePatching",
|
|
"ScriptCommands",
|
|
],
|
|
|
|
messages: [
|
|
messages.RoleUpdatedEvent,
|
|
messages.AssignmentUpdatedEvent,
|
|
|
|
messages.RoleListRequest,
|
|
messages.RoleMetaUpdateRequest,
|
|
messages.SeedRolesRequest,
|
|
|
|
messages.AssignmentListRequest,
|
|
messages.AssignmentUpdateRequest,
|
|
],
|
|
|
|
instanceEntrypoint: "./dist/node/instance",
|
|
instanceConfigFields: {
|
|
"exp_roles.sync_mode": {
|
|
description: "Synchronize in game roles with the controller",
|
|
type: "string",
|
|
enum: ["disabled", "enabled", "bidirectional"],
|
|
initialValue: "bidirectional",
|
|
},
|
|
},
|
|
|
|
controllerEntrypoint: "./dist/node/controller",
|
|
controllerConfigFields: {
|
|
},
|
|
|
|
webEntrypoint: "./web",
|
|
};
|