diff --git a/RustPlusApi.sln b/RustPlusApi.sln index b1aad13..3616f7c 100644 --- a/RustPlusApi.sln +++ b/RustPlusApi.sln @@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SendTeamChat", "RustPlusApi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SetEntityValue", "RustPlusApi\Examples\SetEntityValue\SetEntityValue.csproj", "{4E5DCE64-A8E5-42C0-8786-EA1FF36CACE4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StrobeEntity", "RustPlusApi\Examples\StrobeEntity\StrobeEntity.csproj", "{3C4E8016-7B7F-4C5E-A5CA-A92A3797AA2B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetMapMarkers", "RustPlusApi\Examples\GetMapMarkers\GetMapMarkers.csproj", "{DD34FAE8-30AA-4787-A6D1-77C330A0928F}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RustPlusApi.Fcm", "RustPlusApi\RustPlusApi.Fcm\RustPlusApi.Fcm.csproj", "{CFDFB335-A783-4F82-8094-3ED14E3EBC49}" @@ -59,13 +57,29 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetSmartSwitchChanges", "Ru EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetStorageMonitorChanges", "RustPlusApi\Examples\GetStorageMonitorChanges\GetStorageMonitorChanges.csproj", "{2E65E71F-1C4E-4813-86C9-C5F5D3E60187}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetMapMarkersLegacy", "RustPlusApi\Examples\Legacy\GetMapMarkersLegacy\GetMapMarkersLegacy.csproj", "{70F7555D-DEC9-45E7-BB64-CB31704A2C0A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetMapMarkersLegacy", "RustPlusApi\Examples\Legacy\GetMapMarkersLegacy\GetMapMarkersLegacy.csproj", "{70F7555D-DEC9-45E7-BB64-CB31704A2C0A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTeamChatLegacy", "RustPlusApi\Examples\Legacy\GetTeamChatLegacy\GetTeamChatLegacy.csproj", "{2223E2FE-9CAA-45DF-9F47-E52371018077}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTeamInfoLegacy", "RustPlusApi\Examples\Legacy\GetTeamInfoLegacy\GetTeamInfoLegacy.csproj", "{4E63E17B-7FD4-4B58-9F22-265B0EE92672}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTimeLegacy", "RustPlusApi\Examples\Legacy\GetTimeLegacy\GetTimeLegacy.csproj", "{4255A1A9-C7D8-45F5-81C3-BBCA96886DAA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PromoteToLeaderLegacy", "RustPlusApi\Examples\Legacy\PromoteToLeader\PromoteToLeaderLegacy.csproj", "{80F46159-40F8-4CA3-90A1-EAE62E6BF2F3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendTeamMessageLegacy", "RustPlusApi\Examples\Legacy\SendTeamMessageLegacy\SendTeamMessageLegacy.csproj", "{232323AD-2A44-4EF4-AD71-100563083FAD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetTeamChatChangesLegacy", "RustPlusApi\Examples\Legacy\GetTeamChatChangesLegacy\GetTeamChatChangesLegacy.csproj", "{F8EDEF6A-5EF8-4D01-9C6E-FB379ACF9C9E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetClanChatLegacy", "RustPlusApi\Examples\Legacy\GetClanChatLegacy\GetClanChatLegacy.csproj", "{D90102B3-1F28-42C9-AE3D-D19E689C4D4E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetClanChatChangesLegacy", "RustPlusApi\Examples\Legacy\GetClanChatChangesLegacy\GetClanChatChangesLegacy.csproj", "{248A7713-161F-4A78-9C33-14E5470DFB08}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetTeamChatLegacy", "RustPlusApi\Examples\Legacy\GetTeamChatLegacy\GetTeamChatLegacy.csproj", "{2223E2FE-9CAA-45DF-9F47-E52371018077}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SetEntityValueLegacy", "RustPlusApi\Examples\Legacy\SetEntityValueLegacy\SetEntityValueLegacy.csproj", "{F4BB95F4-2171-4087-889D-F65158AFD713}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetTeamInfoLegacy", "RustPlusApi\Examples\Legacy\GetTeamInfoLegacy\GetTeamInfoLegacy.csproj", "{4E63E17B-7FD4-4B58-9F22-265B0EE92672}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrobeEntityLegacy", "RustPlusApi\Examples\Legacy\StrobeEntityLegacy\StrobeEntityLegacy.csproj", "{9A41A0A3-9FAD-42E2-BD22-E3B4E2DBA161}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetTimeLegacy", "RustPlusApi\Examples\Legacy\GetTimeLegacy\GetTimeLegacy.csproj", "{4255A1A9-C7D8-45F5-81C3-BBCA96886DAA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToggleEntityLegacy", "RustPlusApi\Examples\Legacy\ToggleEntityLegacy\ToggleEntityLegacy.csproj", "{172AAEAA-0F46-457C-9494-8BBEE5377D66}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -105,10 +119,6 @@ Global {4E5DCE64-A8E5-42C0-8786-EA1FF36CACE4}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E5DCE64-A8E5-42C0-8786-EA1FF36CACE4}.Release|Any CPU.ActiveCfg = Release|Any CPU {4E5DCE64-A8E5-42C0-8786-EA1FF36CACE4}.Release|Any CPU.Build.0 = Release|Any CPU - {3C4E8016-7B7F-4C5E-A5CA-A92A3797AA2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3C4E8016-7B7F-4C5E-A5CA-A92A3797AA2B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3C4E8016-7B7F-4C5E-A5CA-A92A3797AA2B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3C4E8016-7B7F-4C5E-A5CA-A92A3797AA2B}.Release|Any CPU.Build.0 = Release|Any CPU {DD34FAE8-30AA-4787-A6D1-77C330A0928F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD34FAE8-30AA-4787-A6D1-77C330A0928F}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD34FAE8-30AA-4787-A6D1-77C330A0928F}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -189,6 +199,38 @@ Global {4255A1A9-C7D8-45F5-81C3-BBCA96886DAA}.Debug|Any CPU.Build.0 = Debug|Any CPU {4255A1A9-C7D8-45F5-81C3-BBCA96886DAA}.Release|Any CPU.ActiveCfg = Release|Any CPU {4255A1A9-C7D8-45F5-81C3-BBCA96886DAA}.Release|Any CPU.Build.0 = Release|Any CPU + {80F46159-40F8-4CA3-90A1-EAE62E6BF2F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80F46159-40F8-4CA3-90A1-EAE62E6BF2F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80F46159-40F8-4CA3-90A1-EAE62E6BF2F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80F46159-40F8-4CA3-90A1-EAE62E6BF2F3}.Release|Any CPU.Build.0 = Release|Any CPU + {232323AD-2A44-4EF4-AD71-100563083FAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {232323AD-2A44-4EF4-AD71-100563083FAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {232323AD-2A44-4EF4-AD71-100563083FAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {232323AD-2A44-4EF4-AD71-100563083FAD}.Release|Any CPU.Build.0 = Release|Any CPU + {F8EDEF6A-5EF8-4D01-9C6E-FB379ACF9C9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8EDEF6A-5EF8-4D01-9C6E-FB379ACF9C9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8EDEF6A-5EF8-4D01-9C6E-FB379ACF9C9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8EDEF6A-5EF8-4D01-9C6E-FB379ACF9C9E}.Release|Any CPU.Build.0 = Release|Any CPU + {D90102B3-1F28-42C9-AE3D-D19E689C4D4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D90102B3-1F28-42C9-AE3D-D19E689C4D4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D90102B3-1F28-42C9-AE3D-D19E689C4D4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D90102B3-1F28-42C9-AE3D-D19E689C4D4E}.Release|Any CPU.Build.0 = Release|Any CPU + {248A7713-161F-4A78-9C33-14E5470DFB08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {248A7713-161F-4A78-9C33-14E5470DFB08}.Debug|Any CPU.Build.0 = Debug|Any CPU + {248A7713-161F-4A78-9C33-14E5470DFB08}.Release|Any CPU.ActiveCfg = Release|Any CPU + {248A7713-161F-4A78-9C33-14E5470DFB08}.Release|Any CPU.Build.0 = Release|Any CPU + {F4BB95F4-2171-4087-889D-F65158AFD713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F4BB95F4-2171-4087-889D-F65158AFD713}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F4BB95F4-2171-4087-889D-F65158AFD713}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F4BB95F4-2171-4087-889D-F65158AFD713}.Release|Any CPU.Build.0 = Release|Any CPU + {9A41A0A3-9FAD-42E2-BD22-E3B4E2DBA161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A41A0A3-9FAD-42E2-BD22-E3B4E2DBA161}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A41A0A3-9FAD-42E2-BD22-E3B4E2DBA161}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A41A0A3-9FAD-42E2-BD22-E3B4E2DBA161}.Release|Any CPU.Build.0 = Release|Any CPU + {172AAEAA-0F46-457C-9494-8BBEE5377D66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {172AAEAA-0F46-457C-9494-8BBEE5377D66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {172AAEAA-0F46-457C-9494-8BBEE5377D66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {172AAEAA-0F46-457C-9494-8BBEE5377D66}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -201,7 +243,6 @@ Global {E9F90342-34DE-4166-9769-483A3FA1F144} = {BC948ADE-1674-4955-B27C-F0E96100978E} {D70DD514-081F-4055-8779-6626DA96D18D} = {BC948ADE-1674-4955-B27C-F0E96100978E} {4E5DCE64-A8E5-42C0-8786-EA1FF36CACE4} = {BC948ADE-1674-4955-B27C-F0E96100978E} - {3C4E8016-7B7F-4C5E-A5CA-A92A3797AA2B} = {BC948ADE-1674-4955-B27C-F0E96100978E} {DD34FAE8-30AA-4787-A6D1-77C330A0928F} = {BC948ADE-1674-4955-B27C-F0E96100978E} {A4EF8656-723B-4E2E-9457-57DCB24CB409} = {BC948ADE-1674-4955-B27C-F0E96100978E} {FF9758F9-2500-4CE1-AACE-8C67134046F4} = {A4EF8656-723B-4E2E-9457-57DCB24CB409} @@ -223,6 +264,14 @@ Global {2223E2FE-9CAA-45DF-9F47-E52371018077} = {EBB661D0-93FF-4742-AF91-9036027CD136} {4E63E17B-7FD4-4B58-9F22-265B0EE92672} = {EBB661D0-93FF-4742-AF91-9036027CD136} {4255A1A9-C7D8-45F5-81C3-BBCA96886DAA} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {80F46159-40F8-4CA3-90A1-EAE62E6BF2F3} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {232323AD-2A44-4EF4-AD71-100563083FAD} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {F8EDEF6A-5EF8-4D01-9C6E-FB379ACF9C9E} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {D90102B3-1F28-42C9-AE3D-D19E689C4D4E} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {248A7713-161F-4A78-9C33-14E5470DFB08} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {F4BB95F4-2171-4087-889D-F65158AFD713} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {9A41A0A3-9FAD-42E2-BD22-E3B4E2DBA161} = {EBB661D0-93FF-4742-AF91-9036027CD136} + {172AAEAA-0F46-457C-9494-8BBEE5377D66} = {EBB661D0-93FF-4742-AF91-9036027CD136} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A4B4251F-ADA4-418D-95B5-27BA99A307A3} diff --git a/RustPlusApi/Examples/Legacy/GetClanChatChangesLegacy/GetClanChatChangesLegacy.csproj b/RustPlusApi/Examples/Legacy/GetClanChatChangesLegacy/GetClanChatChangesLegacy.csproj new file mode 100644 index 0000000..cb85ff3 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/GetClanChatChangesLegacy/GetClanChatChangesLegacy.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + diff --git a/RustPlusApi/Examples/Legacy/GetClanChatChangesLegacy/Program.cs b/RustPlusApi/Examples/Legacy/GetClanChatChangesLegacy/Program.cs new file mode 100644 index 0000000..eba974d --- /dev/null +++ b/RustPlusApi/Examples/Legacy/GetClanChatChangesLegacy/Program.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); + +rustPlus.Connected += async (_, _) => +{ + // This method is not fully integrated in Rust so it will not work until the Clan update is released. + var message = await rustPlus.GetClanChatLegacyAsync(); + + Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); +}; + +rustPlus.MessageReceived += (_, message) => +{ + if (message.Broadcast is not { ClanChanged: not null }) return; + + Console.WriteLine($"Message:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/GetClanChatLegacy/GetClanChatLegacy.csproj b/RustPlusApi/Examples/Legacy/GetClanChatLegacy/GetClanChatLegacy.csproj new file mode 100644 index 0000000..cb85ff3 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/GetClanChatLegacy/GetClanChatLegacy.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + diff --git a/RustPlusApi/Examples/Legacy/GetClanChatLegacy/Program.cs b/RustPlusApi/Examples/Legacy/GetClanChatLegacy/Program.cs new file mode 100644 index 0000000..45ca5cf --- /dev/null +++ b/RustPlusApi/Examples/Legacy/GetClanChatLegacy/Program.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); + +rustPlus.Connected += async (_, _) => +{ + // This method is not fully integrated in Rust so it will not work until the Clan update is released. + var message = await rustPlus.GetClanChatLegacyAsync(); + + Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); + + rustPlus.Dispose(); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/GetEntityChangesLegacy.csproj b/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/GetEntityChangesLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/GetEntityChangesLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/GetEntityChangesLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/Program.cs b/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/Program.cs index f7de659..dda9a6e 100644 --- a/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/Program.cs +++ b/RustPlusApi/Examples/Legacy/GetEntityChangesLegacy/Program.cs @@ -5,7 +5,7 @@ using static __Constants.ExamplesConst; var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); -const uint entityId = 0; +const uint entityId = 3716008; rustPlus.Connected += async (_, _) => { @@ -18,8 +18,7 @@ { if (message.Broadcast is not { EntityChanged: not null }) return; - var entityChanged = message.Broadcast.EntityChanged; - Console.WriteLine($"Message:\n{JsonConvert.SerializeObject(entityChanged, JsonSettings)}"); + Console.WriteLine($"Message:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); }; await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/GetEntityInfoLegacy/GetEntityInfoLegacy.csproj b/RustPlusApi/Examples/Legacy/GetEntityInfoLegacy/GetEntityInfoLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetEntityInfoLegacy/GetEntityInfoLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetEntityInfoLegacy/GetEntityInfoLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/GetInfoLegacy/GetInfoLegacy.csproj b/RustPlusApi/Examples/Legacy/GetInfoLegacy/GetInfoLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetInfoLegacy/GetInfoLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetInfoLegacy/GetInfoLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/GetInfoLegacy/Program.cs b/RustPlusApi/Examples/Legacy/GetInfoLegacy/Program.cs index fb3aa41..a229e26 100644 --- a/RustPlusApi/Examples/Legacy/GetInfoLegacy/Program.cs +++ b/RustPlusApi/Examples/Legacy/GetInfoLegacy/Program.cs @@ -8,7 +8,7 @@ rustPlus.Connected += async (_, _) => { - var message = await rustPlus.GetInfoLegacyAsync(); + var message = await rustPlus.GetTeamChatLegacyAsync(); Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); diff --git a/RustPlusApi/Examples/Legacy/GetMapLegacy/GetMapLegacy.csproj b/RustPlusApi/Examples/Legacy/GetMapLegacy/GetMapLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetMapLegacy/GetMapLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetMapLegacy/GetMapLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/GetMapMarkersLegacy/GetMapMarkersLegacy.csproj b/RustPlusApi/Examples/Legacy/GetMapMarkersLegacy/GetMapMarkersLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetMapMarkersLegacy/GetMapMarkersLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetMapMarkersLegacy/GetMapMarkersLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/GetTeamChatChangesLegacy/GetTeamChatChangesLegacy.csproj b/RustPlusApi/Examples/Legacy/GetTeamChatChangesLegacy/GetTeamChatChangesLegacy.csproj new file mode 100644 index 0000000..cb85ff3 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/GetTeamChatChangesLegacy/GetTeamChatChangesLegacy.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + diff --git a/RustPlusApi/Examples/Legacy/GetTeamChatChangesLegacy/Program.cs b/RustPlusApi/Examples/Legacy/GetTeamChatChangesLegacy/Program.cs new file mode 100644 index 0000000..eb3eb14 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/GetTeamChatChangesLegacy/Program.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; + +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); + +rustPlus.Connected += async (_, _) => +{ + var message = await rustPlus.GetTeamChatLegacyAsync(); + + Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); +}; + +rustPlus.MessageReceived += (_, message) => +{ + if (message.Broadcast is not { TeamMessage: not null }) return; + + Console.WriteLine($"Message:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/GetTeamChatLegacy/GetTeamChatLegacy.csproj b/RustPlusApi/Examples/Legacy/GetTeamChatLegacy/GetTeamChatLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetTeamChatLegacy/GetTeamChatLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetTeamChatLegacy/GetTeamChatLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/GetTeamInfoLegacy/GetTeamInfoLegacy.csproj b/RustPlusApi/Examples/Legacy/GetTeamInfoLegacy/GetTeamInfoLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetTeamInfoLegacy/GetTeamInfoLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetTeamInfoLegacy/GetTeamInfoLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/GetTimeLegacy/GetTimeLegacy.csproj b/RustPlusApi/Examples/Legacy/GetTimeLegacy/GetTimeLegacy.csproj index d9c9c6e..cb85ff3 100644 --- a/RustPlusApi/Examples/Legacy/GetTimeLegacy/GetTimeLegacy.csproj +++ b/RustPlusApi/Examples/Legacy/GetTimeLegacy/GetTimeLegacy.csproj @@ -1,11 +1,11 @@  - - Exe - net8.0 - enable - enable - + + Exe + net8.0 + enable + enable + diff --git a/RustPlusApi/Examples/Legacy/PromoteToLeader/Program.cs b/RustPlusApi/Examples/Legacy/PromoteToLeader/Program.cs new file mode 100644 index 0000000..58ba8b1 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/PromoteToLeader/Program.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); +const ulong steamId = 0; + +rustPlus.Connected += async (_, _) => +{ + var message = await rustPlus.PromoteToLeaderLegacyAsync(steamId); + + Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); + + rustPlus.Dispose(); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/PromoteToLeader/PromoteToLeaderLegacy.csproj b/RustPlusApi/Examples/Legacy/PromoteToLeader/PromoteToLeaderLegacy.csproj new file mode 100644 index 0000000..cb85ff3 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/PromoteToLeader/PromoteToLeaderLegacy.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + diff --git a/RustPlusApi/Examples/Legacy/SendTeamMessageLegacy/Program.cs b/RustPlusApi/Examples/Legacy/SendTeamMessageLegacy/Program.cs new file mode 100644 index 0000000..b7e769c --- /dev/null +++ b/RustPlusApi/Examples/Legacy/SendTeamMessageLegacy/Program.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); +const string teamMessage = "Hello world!"; + +rustPlus.Connected += async (_, _) => +{ + var message = await rustPlus.SendTeamMessageLegacyAsync(teamMessage); + + Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); + + rustPlus.Dispose(); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/SendTeamMessageLegacy/SendTeamMessageLegacy.csproj b/RustPlusApi/Examples/Legacy/SendTeamMessageLegacy/SendTeamMessageLegacy.csproj new file mode 100644 index 0000000..476e35a --- /dev/null +++ b/RustPlusApi/Examples/Legacy/SendTeamMessageLegacy/SendTeamMessageLegacy.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/RustPlusApi/Examples/Legacy/SetEntityValueLegacy/Program.cs b/RustPlusApi/Examples/Legacy/SetEntityValueLegacy/Program.cs new file mode 100644 index 0000000..99acdbc --- /dev/null +++ b/RustPlusApi/Examples/Legacy/SetEntityValueLegacy/Program.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; + +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); +const uint entityId = 0; +const bool value = true; + +rustPlus.Connected += async (_, _) => +{ + var message = await rustPlus.SetEntityValueLegacyAsync(entityId, value); + + Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}"); + + rustPlus.Dispose(); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/SetEntityValueLegacy/SetEntityValueLegacy.csproj b/RustPlusApi/Examples/Legacy/SetEntityValueLegacy/SetEntityValueLegacy.csproj new file mode 100644 index 0000000..cb85ff3 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/SetEntityValueLegacy/SetEntityValueLegacy.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + diff --git a/RustPlusApi/Examples/Legacy/StrobeEntityLegacy/Program.cs b/RustPlusApi/Examples/Legacy/StrobeEntityLegacy/Program.cs new file mode 100644 index 0000000..8b16622 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/StrobeEntityLegacy/Program.cs @@ -0,0 +1,17 @@ +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); +const uint entityId = 0; + +rustPlus.Connected += async (_, _) => +{ + await rustPlus.StrobeEntityLegacyAsync(entityId); + + Console.WriteLine($"Strobed entity: {entityId}"); + + rustPlus.Dispose(); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/StrobeEntityLegacy/StrobeEntityLegacy.csproj b/RustPlusApi/Examples/Legacy/StrobeEntityLegacy/StrobeEntityLegacy.csproj new file mode 100644 index 0000000..cb85ff3 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/StrobeEntityLegacy/StrobeEntityLegacy.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + diff --git a/RustPlusApi/Examples/Legacy/ToggleEntityLegacy/Program.cs b/RustPlusApi/Examples/Legacy/ToggleEntityLegacy/Program.cs new file mode 100644 index 0000000..a104522 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/ToggleEntityLegacy/Program.cs @@ -0,0 +1,17 @@ +using RustPlusApi; + +using static __Constants.ExamplesConst; + +var rustPlus = new RustPlusLegacy(Ip, Port, PlayerId, PlayerToken); +const uint entityId = 85942; + +rustPlus.Connected += async (_, _) => +{ + await rustPlus.ToogleEntityValueLegacyAsync(entityId); + + Console.WriteLine($"Toggled entity: {entityId}"); + + rustPlus.Dispose(); +}; + +await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/Legacy/ToggleEntityLegacy/ToggleEntityLegacy.csproj b/RustPlusApi/Examples/Legacy/ToggleEntityLegacy/ToggleEntityLegacy.csproj new file mode 100644 index 0000000..cb85ff3 --- /dev/null +++ b/RustPlusApi/Examples/Legacy/ToggleEntityLegacy/ToggleEntityLegacy.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + diff --git a/RustPlusApi/Examples/StrobeEntity/Program.cs b/RustPlusApi/Examples/StrobeEntity/Program.cs deleted file mode 100644 index 987dec8..0000000 --- a/RustPlusApi/Examples/StrobeEntity/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using RustPlusApi; - -using static __Constants.ExamplesConst; - -var rustPlus = new RustPlus(Ip, Port, PlayerId, PlayerToken); -var entityId = 0; - -rustPlus.Connected += async (_, _) => -{ - //await rustPlus.StrobeAsync(entityId); - //rustPlus.Dispose(); -}; - -await rustPlus.ConnectAsync(); \ No newline at end of file diff --git a/RustPlusApi/Examples/StrobeEntity/StrobeEntity.csproj b/RustPlusApi/Examples/StrobeEntity/StrobeEntity.csproj deleted file mode 100644 index 0aa3ca6..0000000 --- a/RustPlusApi/Examples/StrobeEntity/StrobeEntity.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - - - - - - diff --git a/RustPlusApi/Examples/__Constants/ExamplesConst.cs b/RustPlusApi/Examples/__Constants/ExamplesConst.cs index b69f0ff..b74e5f9 100644 --- a/RustPlusApi/Examples/__Constants/ExamplesConst.cs +++ b/RustPlusApi/Examples/__Constants/ExamplesConst.cs @@ -11,7 +11,7 @@ public record ExamplesConst public const ulong PlayerId = 0; public const int PlayerToken = 0; - public static JsonSerializerSettings JsonSettings = new() + public static readonly JsonSerializerSettings JsonSettings = new() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented, diff --git a/RustPlusApi/RustPlusApi/RustPlusLegacy.cs b/RustPlusApi/RustPlusApi/RustPlusLegacy.cs index 293b1a6..6150cb8 100644 --- a/RustPlusApi/RustPlusApi/RustPlusLegacy.cs +++ b/RustPlusApi/RustPlusApi/RustPlusLegacy.cs @@ -11,9 +11,22 @@ namespace RustPlusApi /// Your Steam ID. /// Your player token acquired with FCM. /// Specifies whether to use the Facepunch proxy. - public class RustPlusLegacy(string server, int port, ulong playerId, int playerToken, bool useFacepunchProxy = false) + public class RustPlusLegacy(string server, int port, ulong playerId, int playerToken, bool useFacepunchProxy = false) : RustPlusBase(server, port, playerId, playerToken, useFacepunchProxy) { + /// + /// Retrieves the clan chat from the Rust+ server asynchronously. + /// + /// The clan chat. + public async Task GetClanChatLegacyAsync() + { + var request = new AppRequest + { + GetClanChat = new AppEmpty() + }; + return await SendRequestAsync(request); + } + /// /// Retrieves information about an entity from the Rust+ server asynchronously. /// @@ -67,7 +80,7 @@ public async Task GetMapMarkersLegacyAsync() }; return await SendRequestAsync(request); } - + /// /// Retrieves the team chat from the Rust+ server asynchronously. /// @@ -76,7 +89,7 @@ public async Task GetTeamChatLegacyAsync() { var request = new AppRequest { - GetTeamChat = new AppEmpty(), + GetTeamChat = new AppEmpty() }; return await SendRequestAsync(request); } @@ -166,11 +179,23 @@ public async Task SetEntityValueLegacyAsync(uint entityId, bool valu /// The ID of the entity. /// The timeout in milliseconds. /// The value to set. - public async void StrobeLegacyAsync(uint entityId, int timeoutMilliseconds = 1000, bool value = true) + public async Task StrobeEntityLegacyAsync(uint entityId, int timeoutMilliseconds = 1000, bool value = true) { await SetEntityValueLegacyAsync(entityId, value); await Task.Delay(timeoutMilliseconds); await SetEntityValueLegacyAsync(entityId, !value); } + + /// + /// Toggles the value of an entity in the Rust+ server asynchronously. + /// + /// The ID of the entity. + /// A task representing the asynchronous operation. + public async Task ToogleEntityValueLegacyAsync(uint entityId) + { + var entityInfo = await GetEntityInfoLegacyAsync(entityId); + var value = entityInfo.Response.EntityInfo.Payload.Value; + await SetEntityValueLegacyAsync(entityId, !value); + } } }