♻️ plugin api

This commit is contained in:
2023-04-14 14:32:04 +04:00
parent 6c4a51534a
commit fc28f512ba
21 changed files with 155 additions and 97 deletions
@@ -22,26 +22,14 @@ namespace Ragon.Server.Plugin;
public class BaseServerPlugin: IServerPlugin
{
private IRagonServer _ragonServer;
public IRagonServer Server { get; protected set; }
public RagonLobbyPlayer? GetPlayerById(string id)
public virtual void OnAttached(IRagonServer server)
{
var context = _ragonServer.ResolveContext(id);
return context?.LobbyPlayer;
Server = server;
}
public RagonLobbyPlayer? GetPlayerByConnection(INetworkConnection connection)
{
var context = _ragonServer.ResolveContext(connection);
return context?.LobbyPlayer;
}
public void OnAttached(IRagonServer server)
{
_ragonServer = server;
}
public void OnDetached()
public virtual void OnDetached()
{
}
@@ -56,16 +44,6 @@ public class BaseServerPlugin: IServerPlugin
return true;
}
public virtual bool OnRoomLeave(RagonRoomPlayer player, RagonRoom room)
{
return true;
}
public virtual bool OnRoomJoin(RagonRoomPlayer player, RagonRoom room)
{
return true;
}
public virtual bool OnCommand(string command, string payload)
{
return true;