2023-07-29 00:26:12 +00:00
|
|
|
|
using System;
|
|
|
|
|
using QSB.API.Messages;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
|
|
|
|
|
namespace QSB.API;
|
|
|
|
|
|
2023-07-29 23:34:46 +00:00
|
|
|
|
public class QSBAPI : IQSBAPI
|
2023-07-29 00:26:12 +00:00
|
|
|
|
{
|
|
|
|
|
public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
|
|
|
|
|
|
|
|
|
|
public void SetCustomData<T>(uint playerId, string key, T data) => QSBPlayerManager.GetPlayer(playerId).SetCustomData(key, data);
|
|
|
|
|
public T GetCustomData<T>(uint playerId, string key) => QSBPlayerManager.GetPlayer(playerId).GetCustomData<T>(key);
|
|
|
|
|
|
2023-07-30 10:23:11 +00:00
|
|
|
|
public void SendMessage<T>(string messageType, T data, bool receiveLocally = false)
|
2023-07-29 00:26:12 +00:00
|
|
|
|
{
|
2023-07-30 10:23:11 +00:00
|
|
|
|
new AddonDataMessage(messageType, data, receiveLocally).Send();
|
2023-07-29 00:26:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 10:23:11 +00:00
|
|
|
|
public void RegisterHandler<T>(string messageType, Action<uint, T> handler)
|
2023-07-29 00:26:12 +00:00
|
|
|
|
{
|
2023-07-29 23:53:02 +00:00
|
|
|
|
AddonDataManager.RegisterHandler(messageType, handler);
|
2023-07-29 00:26:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|