|
1 | | -# SmartCleanup (Rust / uMod Plugin) |
| 1 | +# SmartCleanup (Rust / Carbon and uMod Plugin) |
2 | 2 |
|
3 | | -**Author:** SeesAll\ |
4 | | -**Version:** 0.3.1 |
| 3 | +**Author:** SeesAll |
5 | 4 |
|
6 | | -SmartCleanup is a modern replacement for legacy Rust cleanup plugins |
7 | | -such as EntityCleanup. It safely removes abandoned structures and |
8 | | -deployables while protecting legitimate player builds. |
| 5 | +**Version:** 0.4.0 |
9 | 6 |
|
10 | | ------------------------------------------------------------------------- |
| 7 | +SmartCleanup is a safety-first replacement for legacy Rust cleanup plugins such as EntityCleanup. It identifies abandoned structures and selected deployables without repeatedly scanning and mutating the server's entire entity collection. |
11 | 8 |
|
12 | | -## Why SmartCleanup Exists |
| 9 | +## Highlights |
13 | 10 |
|
14 | | -Older cleanup plugins treated all deployables the same which could lead |
15 | | -to: - accidental removal of legitimate player storage - unsafe cleanup |
16 | | -inside base areas - unnecessary performance overhead |
| 11 | +- Building and deployable cleanup with category controls |
| 12 | +- Fast PvP, Balanced, PvE/Conservative, Custom, and auto-detected profiles |
| 13 | +- Persistent entity age and owner-activity state across reloads/restarts |
| 14 | +- Bounded startup/reconciliation indexing and cleanup batches |
| 15 | +- Dry-run required before a manual destructive run |
| 16 | +- Whole-building protection when any connected part is protected |
| 17 | +- Event protection for RaidableBases, AirfieldEvent, MonumentAddons, CopyPaste, monument entities, unsaved entities, non-Steam owners, and configured skin IDs |
| 18 | +- Extensible protection API for present and future event plugins |
| 19 | +- Invalid-config backup and fail-safe scheduled-cleanup shutdown |
17 | 20 |
|
18 | | -SmartCleanup introduces category-aware cleanup, safer privilege |
19 | | -detection, and performance-focused evaluation. |
| 21 | +## Safety Model |
20 | 22 |
|
21 | | ------------------------------------------------------------------------- |
| 23 | +SmartCleanup checks protections before cleanup eligibility. By default it protects: |
22 | 24 |
|
23 | | -## Key Features |
| 25 | +- whitelisted and never-clean prefabs; |
| 26 | +- recently active owners; |
| 27 | +- entities inside TC privilege and TC-authorized owners; |
| 28 | +- an entire connected building when any part of it is protected; |
| 29 | +- event and monument entities; |
| 30 | +- unsaved or plugin-owned entities; |
| 31 | +- entities registered by another plugin. |
24 | 32 |
|
25 | | -### Intelligent Cleanup Categories |
| 33 | +The default monument protection is intentionally conservative. If a server deliberately wants abandoned player deployables inside monuments cleaned, disable `Protect Entities Inside Monuments` only after testing with all installed event plugins. |
26 | 34 |
|
27 | | -Server owners can control which deployable types are eligible for |
28 | | -cleanup: |
| 35 | +## Profiles and Overrides |
29 | 36 |
|
30 | | -- Production deployables (furnaces, BBQs, campfires) |
31 | | -- Lighting deployables (lanterns, tuna lamps) |
32 | | -- Traps (bear traps, landmines, spike traps) |
33 | | -- Utility deployables |
34 | | -- Water and farming deployables |
35 | | -- Electrical and industrial deployables |
36 | | -- Storage deployables |
37 | | -- Workbench deployables |
38 | | -- Privilege deployables |
39 | | -- Commerce deployables |
| 37 | +1. Auto Detect |
| 38 | +2. Fast PvP |
| 39 | +3. Balanced |
| 40 | +4. PvE / Conservative |
| 41 | +5. Custom |
40 | 42 |
|
41 | | ------------------------------------------------------------------------- |
| 43 | +Profile defaults now remain authoritative unless the matching `Override Profile ...` switch is enabled. Custom profile values are always taken from the advanced settings. `AutoTuneWriteToConfig` pins the detected profile when explicitly enabled; set `ServerProfile` back to `1` to resume automatic detection. |
42 | 44 |
|
43 | | -### Safety Systems |
44 | | - |
45 | | -SmartCleanup includes multiple layers of protection: |
46 | | - |
47 | | -- TC privilege detection |
48 | | -- Connected structure protection |
49 | | -- Recent player activity protection |
50 | | -- Health thresholds |
51 | | -- Never-clean prefab list |
52 | | -- Force-allow prefab list |
53 | | - |
54 | | -These systems prevent accidental cleanup of legitimate bases. |
55 | | - |
56 | | ------------------------------------------------------------------------- |
57 | | - |
58 | | -### Server Profiles |
59 | | - |
60 | | -SmartCleanup supports preset environments: |
61 | | - |
62 | | -1. Auto Detect |
63 | | -2. Fast PvP |
64 | | -3. Balanced |
65 | | -4. PvE / Conservative |
66 | | -5. Custom |
67 | | - |
68 | | -Profiles automatically adjust cleanup timings based on server style. |
69 | | - |
70 | | ------------------------------------------------------------------------- |
71 | | - |
72 | | -### Performance-Focused Design |
73 | | - |
74 | | -Compared to older cleanup plugins SmartCleanup improves performance by: |
75 | | - |
76 | | -- Tracking cleanup candidates instead of repeatedly scanning all |
77 | | - entities |
78 | | -- Evaluating entities in controlled batches |
79 | | -- Running scheduled checks at configurable intervals |
80 | | -- Avoiding unnecessary processing of protected structures |
81 | | - |
82 | | -This design scales significantly better on medium and large Rust |
83 | | -servers. |
84 | | - |
85 | | ------------------------------------------------------------------------- |
86 | | - |
87 | | -### Logging Controls |
88 | | - |
89 | | -Admins can choose how much information appears in console: |
90 | | - |
91 | | -- Debug logging |
92 | | -- Scheduled cleanup summaries |
93 | | -- Removal-only logging (recommended for production) |
94 | | - |
95 | | ------------------------------------------------------------------------- |
96 | | - |
97 | | -## Default Always-Allow Cleanup Prefabs |
98 | | - |
99 | | -SmartCleanup always allows cleanup for common clutter deployables: |
| 45 | +## Admin Commands |
100 | 46 |
|
101 | | - campfire |
102 | | - lantern.deployed |
103 | | - bbq.deployed |
| 47 | +Permission: `smartcleanup.admin` |
104 | 48 |
|
105 | | -These objects are frequently abandoned across the map and safe to remove |
106 | | -when outside TC. |
| 49 | +```text |
| 50 | +/smartcleanup status |
| 51 | +/smartcleanup dryrun |
| 52 | +/smartcleanup run confirm |
| 53 | +/smartcleanup retune |
| 54 | +/smartcleanup rebuild |
| 55 | +``` |
107 | 56 |
|
108 | | ------------------------------------------------------------------------- |
| 57 | +`dryrun` performs no removals. A successful manual dry-run opens a 120-second confirmation window for `run confirm`. Scheduled cleanup does not require this manual confirmation gate. |
109 | 58 |
|
110 | | -## Admin Commands |
| 59 | +## Event Plugin Integration |
111 | 60 |
|
112 | | - /smartcleanup status |
113 | | - /smartcleanup dryrun |
114 | | - /smartcleanup run |
115 | | - /smartcleanup rebuild |
| 61 | +SmartCleanup has built-in conservative protection, but event authors can explicitly protect entities: |
116 | 62 |
|
117 | | -### Command Descriptions |
| 63 | +```csharp |
| 64 | +SmartCleanup?.Call("API_ProtectEntity", entity, "MyEvent"); |
| 65 | +SmartCleanup?.Call("API_UnprotectEntity", entity, "MyEvent"); |
| 66 | +``` |
118 | 67 |
|
119 | | - Command Description |
120 | | - ----------------------- --------------------------------------------- |
121 | | - /smartcleanup status Shows current runtime configuration |
122 | | - /smartcleanup dryrun Simulates cleanup without removing entities |
123 | | - /smartcleanup run Executes cleanup immediately |
124 | | - /smartcleanup rebuild Rebuilds the internal candidate tracker |
| 68 | +Alternatively, another plugin may block cleanup for an entity: |
125 | 69 |
|
126 | | ------------------------------------------------------------------------- |
| 70 | +```csharp |
| 71 | +private object CanSmartCleanupEntity(BaseEntity entity) |
| 72 | +{ |
| 73 | + return IsMyEventEntity(entity) ? (object)false : null; |
| 74 | +} |
| 75 | +``` |
127 | 76 |
|
128 | | -## Testing Mode |
| 77 | +Register event entities when the event starts and unregister them when it ends. Entity destruction is handled automatically. |
129 | 78 |
|
130 | | -For testing cleanup behaviour administrators can disable scheduled |
131 | | -cleanup: |
| 79 | +## Testing and Deployment |
132 | 80 |
|
133 | | - "Disable Scheduled Cleanup For Testing": true |
| 81 | +For a first deployment, enable: |
134 | 82 |
|
135 | | ------------------------------------------------------------------------- |
| 83 | +```json |
| 84 | +"Disable Scheduled Cleanup For Testing": true |
| 85 | +``` |
136 | 86 |
|
137 | | -## Performance Notes |
| 87 | +Then reload SmartCleanup, wait for the bounded index rebuild to finish, check `/smartcleanup status`, and run `/smartcleanup dryrun`. Only disable testing mode after reviewing the dry-run totals and protected-reason breakdown. |
138 | 88 |
|
139 | | -SmartCleanup was built with performance in mind. |
| 89 | +SmartCleanup stores runtime state in `oxide/data/SmartCleanup_State.json`. The state is reset automatically on a new Rust save. Configuration remains in `oxide/config/SmartCleanup.json` and is merged forward during schema upgrades. |
140 | 90 |
|
141 | | -Compared to legacy plugins it: |
| 91 | +Never run SmartCleanup and another automatic entity cleanup plugin at the same time. |
142 | 92 |
|
143 | | -- reduces full entity scans |
144 | | -- processes entities in controlled batches |
145 | | -- skips protected structures early |
146 | | -- uses category filtering to minimize work |
| 93 | +## Default Cleanup Categories |
147 | 94 |
|
148 | | -The result is a cleanup system that scales much better on long-wipe |
149 | | -servers with large entity counts. |
| 95 | +Production, lighting, and trap deployables are eligible by default. Storage, workbenches, privilege, commerce, electrical/industrial, water/farming, and utility deployables remain protected unless enabled in configuration. |
150 | 96 |
|
151 | | ------------------------------------------------------------------------- |
| 97 | +Default always-eligible clutter prefabs are `campfire`, `lantern.deployed`, and `bbq.deployed`; they still must pass age, location, activity, event, and other safety checks. |
152 | 98 |
|
153 | 99 | ## License |
154 | 100 |
|
|