Changeset 455 for binary-improvements/7dtd-server-fixes/src/API.cs
- Timestamp:
- Jul 31, 2023, 4:06:13 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/API.cs
r446 r455 1 1 using System.Collections.Generic; 2 2 using AllocsFixes.PersistentData; 3 using JetBrains.Annotations; 3 4 using Platform.Steam; 4 5 5 6 namespace AllocsFixes { 7 [UsedImplicitly] 6 8 public class API : IModApi { 7 9 public void InitMod (Mod _modInstance) { 8 10 ModEvents.GameStartDone.RegisterHandler (GameAwake); 9 ModEvents.GameShutdown.RegisterHandler (GameShutdown);10 11 ModEvents.SavePlayerData.RegisterHandler (SavePlayerData); 11 12 ModEvents.PlayerSpawning.RegisterHandler (PlayerSpawning); … … 15 16 } 16 17 17 p ublic void GameAwake () {18 private static void GameAwake () { 18 19 PersistentContainer.Load (); 19 20 } 20 21 21 public void GameShutdown () { 22 } 23 24 public void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) { 22 private static void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) { 25 23 PersistentContainer.Instance.Players.GetOrCreate (_cInfo.InternalId, _cInfo.PlatformId, _cInfo.CrossplatformId).Update (_cInfo, _playerDataFile); 26 24 } 27 25 28 p ublic void PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) {26 private static void PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) { 29 27 string owner = null; 30 28 if (_cInfo.PlatformId is UserIdentifierSteam identifierSteam) { … … 32 30 } 33 31 34 Log.Out ("Player connected" + 35 ", entityid=" + _cInfo.entityId + 36 ", name=" + _cInfo.playerName + 37 ", pltfmid=" + (_cInfo.PlatformId?.CombinedString ?? "<unknown>") + 38 ", crossid=" + (_cInfo.CrossplatformId?.CombinedString ?? "<unknown/none>") + 39 ", steamOwner=" + (owner ?? "<unknown/none>") + 40 ", ip=" + _cInfo.ip 32 Log.Out ( 33 $"Player connected, entityid={_cInfo.entityId}, name={_cInfo.playerName}, pltfmid={_cInfo.PlatformId?.CombinedString ?? "<unknown>"}, crossid={_cInfo.CrossplatformId?.CombinedString ?? "<unknown/none>"}, steamOwner={owner ?? "<unknown/none>"}, ip={_cInfo.ip}" 41 34 ); 42 35 } 43 36 44 p ublic void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) {37 private static void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) { 45 38 Player p = PersistentContainer.Instance.Players.GetByInternalId (_cInfo.InternalId); 46 39 if (p != null) { … … 53 46 } 54 47 55 p ublic void PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) {48 private static void PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) { 56 49 PersistentContainer.Instance.Players.GetOrCreate (_cInfo.InternalId, _cInfo.PlatformId, _cInfo.CrossplatformId).SetOnline (_cInfo); 57 50 PersistentContainer.Instance.Save (); 58 51 } 59 52 60 private const string ANSWER = 61 " [ff0000]I[-] [ff7f00]W[-][ffff00]A[-][80ff00]S[-] [00ffff]H[-][0080ff]E[-][0000ff]R[-][8b00ff]E[-]"; 53 private const string ANSWER = " [ff0000]I[-] [ff7f00]W[-][ffff00]A[-][80ff00]S[-] [00ffff]H[-][0080ff]E[-][0000ff]R[-][8b00ff]E[-]"; 62 54 63 p ublic bool ChatMessage (ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName,55 private static bool ChatMessage (ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName, 64 56 bool _localizeMain, List<int> _recipientEntityIds) { 65 57 if (string.IsNullOrEmpty (_msg) || !_msg.EqualsCaseInsensitive ("/alloc")) { … … 68 60 69 61 if (_cInfo != null) { 70 Log.Out ( "Sent chat hook reply to {0}", _cInfo.InternalId);62 Log.Out ($"Sent chat hook reply to {_cInfo.InternalId}"); 71 63 _cInfo.SendPackage (NetPackageManager.GetPackage<NetPackageChat> ().Setup (EChatType.Whisper, -1, ANSWER, "", false, null)); 72 64 } else { 73 Log.Error ( "ChatHookExample: Argument _cInfo null on message: {0}", _msg);65 Log.Error ($"ChatHookExample: Argument _cInfo null on message: {_msg}"); 74 66 } 75 67
Note:
See TracChangeset
for help on using the changeset viewer.