Skip to content

Commit

Permalink
doc: add admin only strictness to the config documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MSchmoecker committed Nov 30, 2024
1 parent 61fc0f4 commit ca4fc98
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
17 changes: 17 additions & 0 deletions JotunnLib/Documentation/tutorials/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ Local settings will be overriden by the servers values as long as the client is

Changing the configs at runtime will sync the changes to all clients connected to the server.

## Admin Only Strictness

Usually, the `IsAdminOnly` flag is enforcing players to be admin on the server to change the configuration.
However, without having Jotunn installed on the server the admin status cannot be detected reliably.

To change this behaviour, the `SynchronizationMode` can be set to `AdminOnlyStrictness.IfOnServer`.
This means `IsAdminOnly` configs are only synced and enforced if the server has Jotunn installed.
If not installed on the server, all players are free to change any config values.
This can useful for mods that want to behave like client-only mods on vanilla servers but still sync configs on modded servers.
```cs
[SynchronizationMode(AdminOnlyStrictness.IfOnServer)]
internal class TestMod : BaseUnityPlugin
{
...
}
```

## Synced admin status

Upon connection to a server, Jötunn checks the admin status of the connecting player on that server, given that Jötunn is installed on both sides.
Expand Down
23 changes: 15 additions & 8 deletions JotunnLib/Utils/ModCompatibility/NetworkCompatibilityAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,33 @@ public enum CompatibilityLevel
/// </summary>
[Obsolete("Use NotEnforced instead")]
NoNeedForSync = 0,

/// <summary>
/// Mod is checked only if the client and server have loaded it and ignores if just one side has it.
/// </summary>
[Obsolete("Use VersionCheckOnly")]
OnlySyncWhenInstalled = 1,

/// <summary>
/// Mod must be loaded on server and client. Version checking depends on the VersionStrictness.
/// </summary>
EveryoneMustHaveMod = 2,

/// <summary>
/// If mod is installed on the server, every client has to have it. VersionStrictness does apply when both sides have it.
/// </summary>
ClientMustHaveMod = 3,

/// <summary>
/// If mod is installed on the client, the server has to have it. VersionStrictness does apply when both sides have it.
/// </summary>
ServerMustHaveMod = 4,

/// <summary>
/// Version check is performed when both server and client have the mod, no check if the mod is actually installed.
/// </summary>
VersionCheckOnly = 5,

/// <summary>
/// Mod is not checked at all, VersionsStrictness does not apply.
/// </summary>
Expand All @@ -51,31 +57,32 @@ public enum VersionStrictness : int
/// No version check is done
/// </summary>
None = 0,

/// <summary>
/// Mod must have the same Major version
/// </summary>
Major = 1,

/// <summary>
/// Mods must have the same Minor version
/// </summary>
Minor = 2,

/// <summary>
/// Mods must have the same Patch version
/// </summary>
Patch = 3
}

/// <summary>
/// Mod compatibility attribute<br />
/// <br/>
/// PLEASE READ<br />
/// Example usage:<br />
/// If your mod adds its own RPCs, EnforceModOnClients is likely a must (otherwise clients would just discard the messages from the server), same version you do have to determine, if your sent data changed<br />
/// If your mod adds items, you always should enforce mods on client and same version (there could be nasty side effects with different versions of an item)<br />
/// If your mod is just GUI changes (for example bigger inventory, additional equip slots) there is no need to set this attribute
/// Mod compatibility attribute<br />
/// <br/>
/// If your mod adds its own RPCs, EnforceModOnClients is likely a must (otherwise clients would just discard the messages from the server), same version you do have to determine, if your sent data changed.<br />
/// If your mod adds items, you always should enforce mods on client and same version (there could be nasty side effects with different versions of an item).<br />
/// If your mod is just GUI changes (for example bigger inventory, additional equip slots) there is no need to set this attribute
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly)]
public class NetworkCompatibilityAttribute: Attribute
public class NetworkCompatibilityAttribute : Attribute
{
/// <summary>
/// Compatibility Level
Expand Down

0 comments on commit ca4fc98

Please sign in to comment.