Skip to main content

Plugin Base

Namespace: DeadworksManaged.Api

DeadworksPluginBase

The recommended base class for all plugins. Provides the Timer property and default no-op implementations for all lifecycle hooks.

public class MyPlugin : DeadworksPluginBase
{
public override string Name => "My Plugin";
}

Properties

PropertyTypeDescription
NamestringDisplay name of the plugin (abstract — must override)
TimerITimerPer-plugin timer service for scheduling actions

Lifecycle Hooks

MethodDescription
OnLoad(bool isReload)Called when plugin is loaded. isReload is true during hot-reload
OnUnload()Called when plugin is unloaded. Clean up hooks and timers here
OnPrecacheResources()Called during map load. Use Precache.AddResource() here
OnStartupServer()Called when the server starts (new map load)
OnGameFrame(bool simulating, bool firstTick, bool lastTick)Called every server frame. simulating is true during active gameplay

Server Event Hooks

MethodDescription
OnTakeDamage(TakeDamageEvent)Entity takes damage. Return HookResult.Stop to block. See Damage
OnModifyCurrency(ModifyCurrencyEvent)Player currency modified. Return Stop to block. See Players
OnChatMessage(ChatMessage)Player sends chat message. Return Stop to block
OnClientConCommand(ClientConCommandEvent)Client sends console command. Return Stop to block

Client Lifecycle Hooks

MethodDescription
OnClientPutInServer(ClientPutInServerEvent)Client initially connected to server
OnClientFullConnect(ClientFullConnectEvent)Client fully connected and in-game
OnClientDisconnect(ClientDisconnectedEvent)Client disconnected

Entity Lifecycle Hooks

MethodDescription
OnEntityCreated(EntityCreatedEvent)New entity created
OnEntitySpawned(EntitySpawnedEvent)Entity fully spawned
OnEntityDeleted(EntityDeletedEvent)Entity about to be deleted
OnEntityStartTouch(EntityTouchEvent)Two entities begin touching
OnEntityEndTouch(EntityTouchEvent)Two entities stop touching

HookResult

Return values for hooks and event handlers:

ValueDescription
HookResult.HandledEvent was consumed, but allow other plugins to process
HookResult.StopBlock the event entirely — no further processing

IDeadworksPlugin

The core interface that DeadworksPluginBase implements. You can implement this directly instead of inheriting from the base class, but the base class is recommended as it provides default no-op implementations and the Timer property.

IPluginConfig<T>

Interface for plugins with JSON configuration. See Configuration.

public class MyPlugin : DeadworksPluginBase, IPluginConfig<MyConfig>
{
public MyConfig Config { get; set; } = new();
}

See Also