Static Accessors: U and R
RocketMod provides two static classes that serve as entry points into the framework: U (in the Rocket.Unturned namespace) for Unturned-facing utilities, and R (in the Rocket.Core namespace) for core RocketMod utilities. They are static classes -- you call their members directly, not through an .Instance property.
Many older tutorials describe U.Instance and R.Instance as singletons with properties like Players, Events, Permissions, Plugins, and Commands. Those properties do not exist on U or R in the real API. This article documents what the U and R classes actually provide, and directs you to the real classes for each category of functionality.
Prerequisites
- A working RocketMod plugin. See Creating Your First RocketMod Plugin.
- Understanding of the plugin lifecycle. See Plugin Lifecycle.
The U static class (Rocket.Unturned)
U is a static class in Rocket.Unturned.U. It exposes a small set of utility members for interacting with the Unturned server wrapper.
U members
| Member | Kind | Description |
|---|---|---|
U.Translate | Method | Translate a string using RocketMod's translation system |
U.Reload | Method | Reload the RocketMod implementation |
U.Shutdown | Method | Shut down the RocketMod implementation |
U.ImplementationEvents | Property | Access to implementation-level events |
U.InstanceId | Property | The server instance identifier |
U.OnRocketImplementationInitialized | Event | Fires when the RocketMod implementation has finished initializing |
U.Translate
U.Translate is a static method that returns a translated string. It is used for server-level translations.
csharp
string message = U.Translate("some_translation_key");U.OnRocketImplementationInitialized
This event fires once the Unturned-specific RocketMod implementation has completed its initialization. Plugins that need to run code after the implementation layer is ready can subscribe here.
csharp
protected override void Load()
{
U.OnRocketImplementationInitialized += OnImplReady;
}
private void OnImplReady()
{
Rocket.Core.Logging.Logger.Log("Unturned implementation layer is ready.");
}The R static class (Rocket.Core)
R is a static class in Rocket.Core.R. It exposes a small set of utility members for the RocketMod core layer.
R members
| Member | Kind | Description |
|---|---|---|
R.Translate | Method | Translate a string using RocketMod's translation system |
R.Reload | Method | Reload RocketMod core |
R.OnRockedInitialized | Event | Fires when RocketMod core has finished initializing |
R.Translate
R.Translate is a static method that returns a translated string. It is used for framework-level translations. It serves the same underlying translation system as U.Translate.
csharp
string message = R.Translate("plugin_welcome");R.OnRockedInitialized
This event fires once RocketMod core has completed its initialization. It fires earlier than U.OnRocketImplementationInitialized, because the core initializes before the Unturned-specific implementation layer.
csharp
protected override void Load()
{
R.OnRockedInitialized += OnCoreReady;
}
private void OnCoreReady()
{
Rocket.Core.Logging.Logger.Log("RocketMod core is ready.");
}Where to find players
The U class does not have a Players property. To work with players, use the UnturnedPlayer class in Rocket.Unturned.Player.
Looking up players
UnturnedPlayer provides static factory methods for finding players:
| Method | Purpose |
|---|---|
UnturnedPlayer.FromCSteamID | Get an UnturnedPlayer from a CSteamID value |
UnturnedPlayer.FromName | Get an UnturnedPlayer by display name or character name |
UnturnedPlayer.FromPlayer | Get an UnturnedPlayer from an SDG Player object |
UnturnedPlayer.FromSteamPlayer | Get an UnturnedPlayer from an SDG SteamPlayer object |
csharp
UnturnedPlayer target = UnturnedPlayer.FromName("Notch");
if (target != null)
{
Rocket.Core.Logging.Logger.Log($"Found player: {target.DisplayName}");
}UnturnedPlayer properties
Once you have an UnturnedPlayer instance, the following properties are available:
| Property | Purpose |
|---|---|
DisplayName | The player's display name |
CharacterName | The player's character name |
CSteamID | The player's CSteamID value |
Id | The player's identifier |
IsAdmin | Whether the player is an admin |
Health | Current health |
Hunger | Current hunger |
Thirst | Current thirst |
Stamina | Current stamina |
Experience | Current experience |
Bleeding | Whether the player is bleeding |
Broken | Whether the player has a broken bone |
Infection | Current infection level |
Dead | Whether the player is dead |
GodMode | Whether god mode is active |
VanishMode | Whether vanish mode is active |
Position | The player's current position |
Rotation | The player's current rotation |
Stance | The player's current stance |
Ping | The player's latency |
IP | The player's IP address |
SteamName | The player's Steam display name |
SteamGroupID | The player's Steam group ID |
SteamProfile | The player's Steam profile data |
IsInVehicle | Whether the player is in a vehicle |
CurrentVehicle | The vehicle the player is in |
Inventory | The player's inventory |
Player | The underlying SDG.Unturned Player object |
Features | Feature flags for the player |
Events | Player-scoped events |
Reputation | The player's reputation value |
Color | The player's chat color |
UnturnedPlayer methods
| Method | Purpose |
|---|---|
Heal | Heal the player |
Damage | Apply damage to the player |
Suicide | Kill the player |
Teleport | Teleport the player |
Kick | Kick the player from the server |
Ban | Ban the player |
Admin | Grant or revoke admin status |
GiveItem | Give an item to the player |
GiveVehicle | Give a vehicle to the player |
GetSkill | Get a skill instance |
GetSkillLevel | Get a skill's current level |
SetSkillLevel | Set a skill's level |
MaxSkills | Maximize all skill levels |
TriggerEffect | Trigger an unturned effect on the player |
CompareTo | Compare with another player |
Where to find permissions
The R class does not have a Permissions property. Permission operations are handled by RocketPermissionsManager in Rocket.Core.Permissions.
RocketPermissionsManager methods
| Method | Purpose |
|---|---|
HasPermission | Check if a player has a specific permission |
GetPermissions | Get the list of permissions for a player |
GetGroups | Get the list of groups for a player |
GetGroup | Get a specific group |
AddGroup | Create a new permission group |
AddPlayerToGroup | Add a player to a permission group |
RemovePlayerFromGroup | Remove a player from a permission group |
DeleteGroup | Delete a permission group |
SaveGroup | Save changes to a permission group |
Reload | Reload permissions from disk |
Extension methods on IRocketPlayer
IRocketPlayerExtension in Rocket.Core.Extensions provides convenience methods directly on any IRocketPlayer:
csharp
bool hasPerm = player.HasPermission("myplugin.mycommand");
var perms = player.GetPermissions();Where to find plugins
The R class does not have a Plugins property. Plugin management is handled by RocketPluginManager in Rocket.Core.Plugins.
RocketPluginManager methods
| Method | Purpose |
|---|---|
GetPlugin | Get a loaded plugin by type or name |
GetPlugins | Get the list of all loaded plugins |
RocketPluginManager events
| Event | Description |
|---|---|
OnPluginsLoaded | Fires after all plugins have been loaded |
The RocketPlugin class
Each plugin is an instance of RocketPlugin (or a derived class). The base class exposes:
| Property | Description |
|---|---|
Name | The plugin's name |
State | The plugin's current PluginState |
Configuration | The plugin's configuration instance |
Directory | The plugin's data directory path |
Assembly | The plugin's assembly |
Translations | The plugin's translation list |
| Method | Description |
|---|---|
LoadPlugin | Load the plugin |
UnloadPlugin | Unload the plugin |
ReloadPlugin | Reload the plugin |
Translate | Translate a key using this plugin's translations |
IsDependencyLoaded | Check if a dependency plugin is loaded |
ExecuteDependencyCode | Execute code that depends on another plugin |
| Event | Description |
|---|---|
OnPluginLoading | Fires when the plugin starts loading |
OnPluginUnloading | Fires when the plugin starts unloading |
Where to find commands
The R class does not have a Commands property. Command management is handled by RocketCommandManager in Rocket.Core.Commands.
RocketCommandManager properties
| Property | Description |
|---|---|
Commands | The collection of registered commands |
RocketCommandManager methods
| Method | Purpose |
|---|---|
Register | Register a command |
Execute | Execute a command |
DeregisterFromAssembly | Deregister all commands from an assembly |
RegisterFromAssembly | Register all commands from an assembly |
GetCommand | Get a registered command by name |
GetCooldown | Get the remaining cooldown for a player and command |
SetCooldown | Set a cooldown for a player and command |
RocketCommandManager events
| Event | Description |
|---|---|
OnExecuteCommand | Fires when any command is executed |
Where to find events
The U class's ImplementationEvents property is the entry point for implementation-level events. For game events, two separate classes provide dedicated event sets.
UnturnedEvents (Rocket.Unturned.Events)
| Event | Description |
|---|---|
OnBeforePlayerConnected | Fires before a player completes connection |
OnPlayerConnected | Fires when a player connects |
OnPlayerDisconnected | Fires when a player disconnects |
OnPlayerDamaged | Fires when a player takes damage |
OnShutdown | Fires when the server shuts down |
UnturnedPlayerEvents (Rocket.Unturned.Events)
UnturnedPlayerEvents provides per-player events including chat, death, inventory, and stat updates:
| Category | Events |
|---|---|
| Chat | OnPlayerChatted |
| Life and death | OnPlayerDead / OnDead, OnPlayerDeath / OnDeath, OnPlayerRevive / OnRevive |
| Inventory | OnPlayerInventoryAdded / OnInventoryAdded, OnPlayerInventoryRemoved / OnInventoryRemoved, OnPlayerInventoryResized / OnInventoryResized, OnPlayerInventoryUpdated / OnInventoryUpdated, OnPlayerWear |
| Stats | OnPlayerUpdateHealth / OnUpdateHealth, OnPlayerUpdateFood / OnUpdateFood, OnPlayerUpdateWater / OnUpdateWater, OnPlayerUpdateStamina / OnUpdateStamina, OnPlayerUpdateExperience / OnUpdateExperience, OnPlayerUpdateBleeding / OnUpdateBleeding, OnPlayerUpdateBroken / OnUpdateBroken, OnPlayerUpdateVirus / OnUpdateVirus, OnPlayerUpdateLife / OnUpdateLife, OnPlayerUpdateStat / OnUpdateStat |
| Movement and stance | OnPlayerUpdatePosition, OnPlayerUpdateStance / OnUpdateStance, OnPlayerUpdateGesture / OnUpdateGesture |
Each event has two names: a OnPlayer... form and a shorter On... form. Both reference the same underlying event.
Thread safety
Both U and R are static classes and their members run on Unturned's main thread. Do not call U.Translate, R.Translate, or any method that touches Unity objects from a background thread, Task.Run() lambda, or async continuation that does not marshal back to the main thread.
csharp
// WRONG -- background thread
Task.Run(() =>
{
string msg = U.Translate("some_key"); // Crash or undefined behavior
});
// CORRECT -- on main thread
protected override void Load()
{
string msg = U.Translate("some_key"); // Safe
}Frequently asked questions
Do U.Instance and R.Instance exist?
No. U and R are static classes in the real API, accessed directly as U.Translate(), R.Translate(), etc. There is no .Instance property on either class. Code that references U.Instance or R.Instance will not compile against the real RocketMod API.
How do I access the player list?
Use UnturnedPlayer's static factory methods (FromName, FromCSteamID, FromPlayer, FromSteamPlayer). There is no Players collection property on U.
How do I check a player's permissions?
Use RocketPermissionsManager.HasPermission, or the IRocketPlayerExtension.HasPermission extension method directly on the player object. There is no R.Permissions property.
Where do I find loaded plugins?
Use RocketPluginManager.GetPlugin or RocketPluginManager.GetPlugins. There is no R.Plugins property.
Can I still use U and R for translations?
Yes. U.Translate and R.Translate are real methods that work. Translations are the primary use case for these two static classes.
What changed in this revision
| Removed claim | Reason |
|---|---|
U.Instance static property | Not found in the real RocketMod API surface. U is a static class; its members are accessed directly. |
R.Instance static property | Not found in the real RocketMod API surface. R is a static class; its members are accessed directly. |
U.Instance.Players collection and all player-find methods | Neither Players nor UnturnedPlayerCollection exist. Player lookup uses UnturnedPlayer static factory methods. |
U.Instance.Events property | U has ImplementationEvents, not Events. Game events live on UnturnedEvents and UnturnedPlayerEvents, separate classes. |
U.Instance.Settings property and all IRocketImplementationSettings members | IRocketImplementationSettings does not exist in the API surface. U has no Settings property. |
Vehicle events (OnVehicleExploded, OnVehicleDamaged, OnVehicleRepair, OnVehicleLockpicked) | None of these events exist in the RocketMod API surface. The UnturnedVehicle type was also not found. |
R.Permissions property and all RocketPermissionsManager method signatures as documented | R has no Permissions property. RocketPermissionsManager exists but its method signatures differ from what was documented. |
R.Plugins property and HasPlugin, GetPlugins as documented | R has no Plugins property. Plugin management is on RocketPluginManager. |
R.Commands property and Execute, GetCommands, GetCooldown, SetCooldown signatures as documented | R has no Commands property. Command management is on RocketCommandManager, with different method signatures. |
R.Settings property | R has no properties at all. Server settings are not accessible through R. |
RocketPlugin.Version property | RocketPlugin has no Version property in the real API. |
MonoBehaviour.Invoke for scheduling | PluginBase / MonoBehaviour.Invoke is not in the RocketMod API surface. |
Event-location errors: OnPlayerChatted on UnturnedEvents, OnPlayerDeath on UnturnedEvents | These events live on UnturnedPlayerEvents, not UnturnedEvents. Parameter types were also unverifiable and have been removed. |
Extension method examples using U.Instance.Players, U.Instance.Settings, R.Permissions paths | All removed because the access paths do not exist in the real API. |
| "Both U.Instance and R.Instance point to the same singleton" | There is no .Instance property on either class. The claim has no basis in the real API. |
| "Pre-2019 accessor changes" migration table | The entire premise of the old/new API paths is invalid; removed. |
Thread safety examples using U.Instance and R.Instance | Rewritten to use direct U.Translate(), R.Translate() access. |
