diff --git a/QSB/API/Messages/AddonCustomDataSyncMessage.cs b/QSB/API/Messages/AddonCustomDataSyncMessage.cs index 7bd8f078..f36e00db 100644 --- a/QSB/API/Messages/AddonCustomDataSyncMessage.cs +++ b/QSB/API/Messages/AddonCustomDataSyncMessage.cs @@ -8,7 +8,5 @@ public class AddonCustomDataSyncMessage : QSBMessage<(uint playerId, string key, { public AddonCustomDataSyncMessage(uint playerId, string key, object data) : base((playerId, key, data.ToBytes())) { } - public override void OnReceiveLocal() => OnReceiveRemote(); - public override void OnReceiveRemote() => QSBPlayerManager.GetPlayer(Data.playerId).SetCustomData(Data.key, Data.data.ToObject()); } diff --git a/QSB/API/Messages/AddonDataMessage.cs b/QSB/API/Messages/AddonDataMessage.cs index b23de375..cc0e1424 100644 --- a/QSB/API/Messages/AddonDataMessage.cs +++ b/QSB/API/Messages/AddonDataMessage.cs @@ -1,6 +1,4 @@ -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -using QSB.Messaging; +using QSB.Messaging; using QSB.Utility; namespace QSB.API.Messages; diff --git a/QSB/API/QSBAPI.cs b/QSB/API/QSBAPI.cs index d4624e08..13fd1cd2 100644 --- a/QSB/API/QSBAPI.cs +++ b/QSB/API/QSBAPI.cs @@ -27,7 +27,7 @@ public class QSBAPI : IQSBAPI public UnityEvent OnPlayerLeave() => QSBAPIEvents.OnPlayerLeaveEvent; public void SetCustomData(uint playerId, string key, T data) - => new AddonCustomDataSyncMessage(playerId, key, data).Send(); + => QSBPlayerManager.GetPlayer(playerId).SetCustomData(key, data); public T GetCustomData(uint playerId, string key) => QSBPlayerManager.GetPlayer(playerId).GetCustomData(key); diff --git a/QSB/Player/PlayerInfo.cs b/QSB/Player/PlayerInfo.cs index dd85b7cd..5b2cd9f6 100644 --- a/QSB/Player/PlayerInfo.cs +++ b/QSB/Player/PlayerInfo.cs @@ -1,10 +1,12 @@ using OWML.Common; using QSB.Animation.Player; +using QSB.API.Messages; using QSB.Audio; using QSB.ClientServerStateSync; using QSB.HUD; using QSB.Messaging; using QSB.ModelShip; +using QSB.Patches; using QSB.Player.Messages; using QSB.Player.TransformSync; using QSB.QuantumSync.WorldObjects; @@ -182,7 +184,15 @@ public partial class PlayerInfo private Dictionary _customData = new(); public void SetCustomData(string key, T data) - => _customData[key] = data; + { + _customData[key] = data; + + if (!QSBPatch.Remote) + { + new AddonCustomDataSyncMessage(PlayerId, key, data).Send(); + } + } + public T GetCustomData(string key) {