MultiuserEditorPermissions๏ƒ

Inherits: RefCounted < Object

Configurable role-based action matrix for the Multiuser Editor module.

Description๏ƒ

MultiuserEditorPermissions holds the per-action role allowlist used by MultiuserEditorPlugin to gate replication on emit (local), relay (host), and receive (every peer). Roles are Viewer, Editor, and Admin, stored as a bitmask. Some action types are also flagged as host-only, meaning only the session host (network id 1) is allowed to send them, regardless of role.

Defaults are set up by load_defaults() and may be customized via the editor setting blazium/multiuser_editor/permissions/overrides, parsed by apply_overrides(). The override format is action=role,role[@host_only|any];..., for example chat=Editor,Admin;scene_sync=Editor,Admin@any.

Methods๏ƒ

void

apply_overrides(overrides: String)

bool

can_perform(action: String, role: String) const

bool

can_perform_mask(action: String, role_mask: int) const

int

get_action_mask(action: String) const

bool

get_allow_widen_host_only() const

bool

is_host_only(action: String) const

bool

is_known_action(action: String) const

void

load_defaults()

int

role_from_string(role: String) static

String

role_to_string(role_bit: int) static

void

set_allow_widen_host_only(allow: bool)


Enumerations๏ƒ

enum Role: ๐Ÿ”—

Role ROLE_NONE = 0

Sentinel value for an unrecognized role string. Peers reported with this role are treated as unauthenticated and cannot perform any action.

Role ROLE_VIEWER = 1

Read-only role. Viewers may receive replication and observe the session, but cannot send mutating actions. Bitmask value 1.

Role ROLE_EDITOR = 2

Standard contributor role. Editors may send most non-host-only actions (scene/script edits, chat, cursor updates, file proposals). Bitmask value 2.

Role ROLE_ADMIN = 4

Full-privilege role granted to the session host. Admins may send every action, including host-only actions such as magic_repair_*, team_play_*, and force-push git operations. Bitmask value 4.


Method Descriptions๏ƒ

void apply_overrides(overrides: String) ๐Ÿ”—

Apply a semicolon-separated list of action=role,role[@host_only|any] overrides on top of the current matrix.


bool can_perform(action: String, role: String) const ๐Ÿ”—

Returns true when the given role string (Viewer/Editor/Admin) is allowed to send or apply the named action.


bool can_perform_mask(action: String, role_mask: int) const ๐Ÿ”—

Returns true when at least one role bit set in role_mask (a bitwise-OR of the ROLE_* constants) is permitted to send the named action. Composite masks are accepted, so a peer holding ROLE_EDITOR | ROLE_ADMIN satisfies any EDITOR-or-higher action. Returns false for unknown actions or when role_mask equals ROLE_NONE.


int get_action_mask(action: String) const ๐Ÿ”—

Returns the role bitmask currently registered for action (a bitwise-OR of the ROLE_* constants), or 0 when the action is unknown. Useful for inspecting the active permission matrix after load_defaults() and any apply_overrides() calls.


bool get_allow_widen_host_only() const ๐Ÿ”—

Returns whether the editor settings have authorized apply_overrides() to relax host-only actions to @any. Mirrors the blazium/multiuser_editor/permissions/allow_widen_host_only editor setting after the most recent refresh.


bool is_host_only(action: String) const ๐Ÿ”—

Returns true when only the session host may send the action (regardless of role).


bool is_known_action(action: String) const ๐Ÿ”—

Returns true when the action is registered in the matrix.


void load_defaults() ๐Ÿ”—

Reset the matrix to the built-in three-tier defaults.


int role_from_string(role: String) static ๐Ÿ”—

Parses a role string such as Viewer, Editor, Admin (case-sensitive canonical forms, plus the lower-case aliases viewer/editor/admin and the legacy alias Host for Admin) and returns the matching ROLE_* constant. Returns ROLE_NONE for unknown or empty input.


String role_to_string(role_bit: int) static ๐Ÿ”—

Returns the canonical string form of a single role bit (ROLE_VIEWER -> "Viewer", ROLE_EDITOR -> "Editor", ROLE_ADMIN -> "Admin"). ROLE_NONE and any other unrecognized value (including composite bitmasks) return "None".


void set_allow_widen_host_only(allow: bool) ๐Ÿ”—

When allow is true, subsequent apply_overrides() calls are permitted to relax actions tagged as host-only by the defaults to @any (any sender). When false (the secure default), such overrides are warned about and skipped. Mirrors the blazium/multiuser_editor/permissions/allow_widen_host_only editor setting; the plugin refreshes this flag whenever the editor settings change.