refactoring: removed external dependencies from server, removed webhooks from server
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Ragon.Server;
|
||||
using Ragon.Server.Entity;
|
||||
using Ragon.Server.Plugin;
|
||||
using Ragon.Server.Room;
|
||||
|
||||
namespace Ragon.Relay;
|
||||
|
||||
public class RelayRoomPlugin: BaseRoomPlugin
|
||||
{
|
||||
public void Tick(float dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnAttached()
|
||||
{
|
||||
Console.WriteLine("Room attached");
|
||||
}
|
||||
|
||||
public void OnDetached()
|
||||
{
|
||||
Console.WriteLine("Room detached");
|
||||
}
|
||||
|
||||
public bool OnEntityCreate(RagonRoomPlayer creator, RagonEntity entity)
|
||||
{
|
||||
Console.WriteLine($"Entity created: {entity.Id}");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnEntityRemove(RagonRoomPlayer destroyer, RagonEntity entity)
|
||||
{
|
||||
Console.WriteLine($"Entity destroyed: {entity.Id}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Ragon.Server;
|
||||
using Ragon.Server.Plugin;
|
||||
|
||||
namespace Ragon.Relay;
|
||||
|
||||
public class RelayServerPlugin: BaseServerPlugin
|
||||
{
|
||||
public override bool OnCommand(string command, string payload)
|
||||
{
|
||||
Console.WriteLine(command);
|
||||
if (command == "kick-player")
|
||||
{
|
||||
var commandPayload = JsonConvert.DeserializeObject<KickPlayerCommand>(payload);
|
||||
var player = Server.GetPlayerById(commandPayload.Id);
|
||||
if (player != null)
|
||||
player.Connection.Close();
|
||||
else
|
||||
Console.WriteLine($"Player not found with Id {commandPayload.Id}");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IRoomPlugin CreateRoomPlugin(RoomInformation information)
|
||||
{
|
||||
return new RelayRoomPlugin();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user