Hello, nice concept but the plugin has many issues. 1.0.5 should not be available for download. I have not checked prior versions
All hooks should be unsubscribed in Init() hook and subscribed once initialization is complete to avoid exceptions being thrown during server startup. This is a common problem with the OnEntitySpawned hook
Null checks should be using IsValid() instead of entity != null as it will throw an exception when entity.net is null. Example: if (priv != null) should be if (priv.IsValid())
OnTick and OnPlayerTick hooks:
(12:27:16) | Calling 'OnPlayerTick' on 'ScrapRaidProtection v1.0.5' took average 1243ms
(12:27:26) | Calling 'OnPlayerTick' on 'ScrapRaidProtection v1.0.5' took average 1151ms
(12:27:36) | Calling 'OnEntityTakeDamage' on 'ScrapRaidProtection v1.0.5' took average 1135ms
(12:27:46) | Calling 'OnPlayerTick' on 'ScrapRaidProtection v1.0.5' took average 1125ms
These hooks are badly optimized and cause serious server lag. Also, the server this is running on is top of the line so it's not a limitation of the machineOnTick should be replaced with a timer since you are using it at specific times. This is a heavy hook and should not be used for its current implementation
OnEntitySpawned - this hook does not have a null check in the timer callback and will throw an exception
OnEntityDeath - this hook is missing and should be used in combination with OnEntityKill.
void OnEntityDeath(BuildingPrivilege priv, HitInfo hitInfo) => OnEntityKill(priv); will fix this bugcalling LoadAllTcs in Init() is throwing a KeyNotFoundException on line 878. calling AddProtectedTc in OnCupboardAuthorize() is throwing the same exception from the same line. both of these issues are fixed by deleting the config file, so the update notes should reflect that this is required. You can avoid this issue in the future by using a standard configuration. https://umod.org/plugins/water-works has a great example of this, in the region Configuration.
I can look at the file again once you've addressed these issues