Repository navigation
Managers
DSMOO provides several Managers that handle core server systems such as players, stages, events, bans, recordings, and game modes.
These managers can be injected into your plugin through dependency injection, just like ILogger or EventManager.
Example:
public class ExampleManager(EventManager eventManager, PlayerManager playerManager, ILogger logger) : Manager
{
public override void Initialize()
{
eventManager.OnPlayerJoined.Subscribe(OnPlayerJoined);
}
private void OnPlayerJoined(PlayerJoinedEventArgs args)
{
foreach (var player in playerManager.RealPlayers)
{
logger.Info(player.Name);
}
}
}Below are the most important managers you may want to use when creating plugins.
The EventManager is one of the most important managers in the framework.
It provides access to all events that happen on the server.
Plugins can subscribe to these events to react to gameplay actions.
Examples of events include:
- Players joining
- Players switching stages
- Players performing actions
- Packets being received
- Game start / end events
Example:
public class ExampleManager(EventManager eventManager, ILogger logger) : Manager
{
public override void Initialize()
{
eventManager.OnPlayerJoined.Subscribe(OnPlayerJoined);
}
private void OnPlayerJoined(PlayerJoinedEventArgs args)
{
logger.Info($"{args.Player.Name} joined the server");
}
}💡 Tip
Most plugins interact with the server primarily through events.
The PlayerManager keeps track of all players currently known to the server.
Useful properties include:
-
Players→ all players including dummy players -
RealPlayers→ only real connected players -
PlayerCount→ number of unique connected players
Example:
public class ExampleManager(PlayerManager playerManager, ILogger logger) : Manager
{
public override void Initialize()
{
foreach (var player in playerManager.RealPlayers)
{
logger.Info(player.Name);
}
}
}PlayerManager also provides a powerful player search system used by commands.
var result = playerManager.SearchForPlayers(["Mario"]);
foreach (var player in result.Players)
{
logger.Info(player.Name);
}The search result contains:
-
Players→ players that matched -
FailedToFind→ inputs that matched no players -
MultipleMatches→ inputs that matched multiple players
This is often used together with command helpers to format messages.
The StageManager provides information about game stages, kingdoms, and map data.
It can be used to:
- convert stage aliases to real stage names
- find warp connections between stages
- determine map positions
- access kingdom information
Example:
public class ExampleManager(StageManager stageManager, ILogger logger) : Manager
{
public override void Initialize()
{
var stage = stageManager.GetStageFromInput("cascade");
logger.Info(stage ?? "Stage not found");
}
}Example: finding a warp connection between stages.
var warp = stageManager.GetConnection("CapWorldHomeStage", "CapWorldTowerStage");The BanManager handles bans for players and gameplay elements.
It supports banning:
- Player profiles
- IP addresses
- Stages
- Game modes
- Captures
Example: banning a player.
public class ExampleManager(BanManager banManager) : Manager
{
public void Ban(IPlayer player)
{
banManager.BanPlayer(player);
}
}Example: checking if a player is banned.
if (banManager.IsPlayerBanned(player))
{
logger.Info("Player is banned");
}The manager automatically stores bans in a config file.
The GameModeManager handles custom game modes and hint systems.
It is responsible for:
- starting games
- managing stage presets
- managing hint presets
- loading game implementations
Example: starting a game.
var game = gameModeManager.StartGame(
"hideandseek",
"*",
"cascade",
"default"
);The manager will:
- resolve players
- load the stage configuration
- create the game instance
- start the game
The DummyManager allows plugins to create dummy players (bots).
These are often used for:
- recordings
- replays
- scripted gameplay
Example:
var dummy = await dummyManager.CreateDummy("ReplayBot");The dummy behaves like a player but is fully controlled by the server.
The RecordingManager allows you to record and replay player movement and actions.
This can be used for:
- gameplay replays
- scripted events
- demonstrations
- ghost players
Example: starting a recording.
var recording = recordingManager.StartRecording(player);Stopping the recording:
recordingManager.StopRecording(recording);Playing the recording using a dummy:
await recordingManager.PlayRecording(recording);Recordings can also be stored to disk and loaded later.
MessageHelper is a small utility class used to format command responses for player searches.
It converts a PlayerSearch result into a readable CommandResult.
Example:
var search = playerManager.SearchForPlayers(["Mario"]);
return MessageHelper.FormatMessage(search, "Affected players");The helper automatically handles:
- players that were found
- failed searches
- ambiguous matches
Now that you know the most important managers, you can start combining them with:
- Commands
- Events
- Configs
to create more advanced plugins.