Plugin Showcase
Previously I demonstrated how you can use the plugin system to add in a command. In this post I'm trying to show the true power of the plugin system. Using a server side C# Blazor application, you're able to use any services from the emulator. In this example I made a page that shows the list of online players and their current room.
The administration panel is a simple blazor application which is build in a standalone project. By referencing the Sirius Api we can use all services from the emulator in our project. The compiled project is placed in the plugins folder of the emulator after which the emulator will run the blazor application as a plugin. This allows close integration with the emulator, no need for RCON / TCP commands to be send and implemented by the server and you can easily extend this further to add more features.

Code:
@Page "/fetchdata"
@using Sirius.Api.Game.User
@using Sirius.Api.Game.Rooms @Inject IHabboCache HabboCache @Inject IGuestRoomDataRepository GuestRooms
<h1>Players</h1>
<p>View online players</p>
@if (_habbos == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th></th>
<th>Username</th>
<th>Time Online</th>
<th>Current Room</th>
</tr>
</thead>
<tbody>
@foreach (var habbo in _habbos)
{
<tr>
<td><img src="https://www.habbo.nl/habbo-imaging/avatarimage?figure=@(habbo.Info.Figure)&headonly=1" /></td>
<td>@habbo.Info.Name</td>
<td>
@{
var span = DateTime.Now - UnixTimeToDateTime(habbo.Info.LoginTimestamp);
if (span.Hours > 0)
@($"{span.Hours} hours, ")
@($"{span.Minutes} minutes")
}
</td>
<td>@{
if (habbo.CurrentRoom > 0)
{
var room = GuestRooms.Get(habbo.CurrentRoom).Result;
@($"({room.FlatId}): {room.Name}")
}
else
{
@(" - ")
}
}</td>
</tr>
}
</tbody>
</table>
}
@code {
private IHabbo[] _habbos;
protected override void OnInitialized()
{
_habbos = HabboCache.OnlineHabbos.Values.ToArray();
}
private DateTime UnixTimeToDateTime(long unixtime)
{
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
dateTime = dateTime.AddMilliseconds(unixtime).ToLocalTime();
return dateTime;
}
}