Skip to content

Commit

Permalink
v1.0.2 (#1)
Browse files Browse the repository at this point in the history
* update workflows

* move and improve examples

* update project

* remove useless nuget

* update readme

* v1.0.2
  • Loading branch information
HandyS11 authored Mar 29, 2024
1 parent 1a6cd4f commit 35b80c9
Show file tree
Hide file tree
Showing 28 changed files with 21,009 additions and 20,957 deletions.
30 changes: 16 additions & 14 deletions .github/workflows/dotnet.yml → .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
name: .NET
name: Continuous Deployment

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_run:
workflows: ["CI.yml Continuous Integration"]
types:
- completed

jobs:
check_branch:
runs-on: ubuntu-latest
outputs:
is_main: ${{ steps.check.outputs.is_main }}
steps:
- id: check
run: echo "::set-output name=is_main::${{ github.event.workflow_run.head_branch == 'main' }}"

build-and-deploy:
runs-on: ubuntu-latest

Expand All @@ -19,15 +27,6 @@ jobs:
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal

- name: Pack NuGet Package
run: cd ./RustPlusApi/RustPlusApi/ && dotnet pack --configuration Release

Expand All @@ -36,5 +35,8 @@ jobs:
with:
path: ./**/*.nupkg

- name: Publish NuGet Package to GitHub Packages
run: dotnet nuget push ./**/*.nupkg --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/${{github.repository_owner}}/index.json

- name: Publish NuGet Package
run: dotnet nuget push ./**/*.nupkg --api-key ${{secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
29 changes: 29 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Continuous Integration

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop"]

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Test
run: dotnet test --no-build --verbosity normal
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

## 📊 Features

This is a non exhaustive list of the features that the Rust+ API provides:
This is a list of the features that the Rust+ API provides:

- `sendTeamMessage` Send messages to Team Chat
- `getEntityInfo` Get current state of a Smart Device
- `setEntityValue` Set the value of a Smart Device
- `getMap` Fetch map info, which inclues a jpeg image
- `getMapMarkers` Get map markers, such as vending machines and cargo/heli
- `getTime` Get the current in game time
- `getInfo` Get info about the Rust Server
- `getTeamInfo` Get list of team members and positions on map
- `SetEntityValue` Set the value of a Smart Device
- `StrobeAsync` Strobe a Smart Device
- `SendTeamMessage` Send messages to Team Chat
- `GetEntityInfo` Get current state of a Smart Device
- `GetMap` Fetch map info, which inclues a jpg image
- `GetTime` Get the current in game time
- `GetInfo` Get info about the Rust Server
- `GetTeamInfo` Get list of team members and positions on map

Feel free to **explore** the `./RustPlusApi/Exemples/` folder to see how to **use** the API.

Expand All @@ -31,10 +31,10 @@ dotnet add package RustPlusApi

## ⚙️ Usage

First, instantiate the `RustPlusApi` class with the necessary parameters:
First, instantiate the `RustPlus` class with the necessary parameters:

```csharp
var rustPlusApi = new RustPlusApi(server, port, playerId, playerToken, useFacepunchProxy);
var rustPlusApi = new RustPlus(server, port, playerId, playerToken, useFacepunchProxy);
```

Parameters:
Expand All @@ -61,7 +61,7 @@ rustPlusApi.ErrorOccurred += (sender, e) => { /* handle error event */ };
rustPlusApi.MessageReceived += (sender, e) => { /* handle received message event */ };
```

Remember to dispose of the `RustPlusApi` instance when you're done:
Remember to dispose of the `RustPlus` instance when you're done:

## 🖼️ Credits

Expand Down
81 changes: 44 additions & 37 deletions RustPlusApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ VisualStudioVersion = 17.9.34701.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RustPlusApi", "RustPlusApi\RustPlusApi\RustPlusApi.csproj", "{2E744AA2-4D20-4B44-A79E-AC1CC56E848E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exemples", "Exemples", "{BC948ADE-1674-4955-B27C-F0E96100978E}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{BC948ADE-1674-4955-B27C-F0E96100978E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SendTeamChat", "RustPlusApi\Exemples\SendTeamChat\SendTeamChat.csproj", "{FC788BAA-BB25-48AD-BE3D-2046C111AD00}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetEntityInfo", "RustPlusApi\Examples\GetEntityInfo\GetEntityInfo.csproj", "{A53B0FAC-F59B-4021-9A67-997D1F5727D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTime", "RustPlusApi\Exemples\GetTime\GetTime.csproj", "{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "__Constants", "RustPlusApi\Examples\__Constants\__Constants.csproj", "{DF3F9213-6F6D-4832-8738-CA106BE49860}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetMap", "RustPlusApi\Exemples\GetMap\GetMap.csproj", "{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetInfo", "RustPlusApi\Examples\GetInfo\GetInfo.csproj", "{AB17A661-1D1D-496C-A39C-B31F3BAEADA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetTeamInfo", "RustPlusApi\Exemples\GetTeamInfo\GetTeamInfo.csproj", "{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetMap", "RustPlusApi\Examples\GetMap\GetMap.csproj", "{4E87360D-AC39-4475-957F-D49018DB2DC8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "__Constants", "RustPlusApi\Exemples\__Constants\__Constants.csproj", "{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTeamInfo", "RustPlusApi\Examples\GetTeamInfo\GetTeamInfo.csproj", "{70453D6E-9C19-41BC-8C96-0E20F919DB11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetInfo", "RustPlusApi\Exemples\GetInfo\GetInfo.csproj", "{50B6AABF-6BC2-4B7B-BB48-27200B05476F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetTime", "RustPlusApi\Examples\GetTime\GetTime.csproj", "{E9F90342-34DE-4166-9769-483A3FA1F144}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SendTeamChat", "RustPlusApi\Examples\SendTeamChat\SendTeamChat.csproj", "{D70DD514-081F-4055-8779-6626DA96D18D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -29,41 +31,46 @@ Global
{2E744AA2-4D20-4B44-A79E-AC1CC56E848E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E744AA2-4D20-4B44-A79E-AC1CC56E848E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E744AA2-4D20-4B44-A79E-AC1CC56E848E}.Release|Any CPU.Build.0 = Release|Any CPU
{FC788BAA-BB25-48AD-BE3D-2046C111AD00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC788BAA-BB25-48AD-BE3D-2046C111AD00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC788BAA-BB25-48AD-BE3D-2046C111AD00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC788BAA-BB25-48AD-BE3D-2046C111AD00}.Release|Any CPU.Build.0 = Release|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647}.Release|Any CPU.Build.0 = Release|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4}.Release|Any CPU.Build.0 = Release|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F}.Release|Any CPU.Build.0 = Release|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15}.Release|Any CPU.Build.0 = Release|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50B6AABF-6BC2-4B7B-BB48-27200B05476F}.Release|Any CPU.Build.0 = Release|Any CPU
{A53B0FAC-F59B-4021-9A67-997D1F5727D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A53B0FAC-F59B-4021-9A67-997D1F5727D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A53B0FAC-F59B-4021-9A67-997D1F5727D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A53B0FAC-F59B-4021-9A67-997D1F5727D7}.Release|Any CPU.Build.0 = Release|Any CPU
{DF3F9213-6F6D-4832-8738-CA106BE49860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF3F9213-6F6D-4832-8738-CA106BE49860}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF3F9213-6F6D-4832-8738-CA106BE49860}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF3F9213-6F6D-4832-8738-CA106BE49860}.Release|Any CPU.Build.0 = Release|Any CPU
{AB17A661-1D1D-496C-A39C-B31F3BAEADA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB17A661-1D1D-496C-A39C-B31F3BAEADA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB17A661-1D1D-496C-A39C-B31F3BAEADA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB17A661-1D1D-496C-A39C-B31F3BAEADA1}.Release|Any CPU.Build.0 = Release|Any CPU
{4E87360D-AC39-4475-957F-D49018DB2DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E87360D-AC39-4475-957F-D49018DB2DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E87360D-AC39-4475-957F-D49018DB2DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E87360D-AC39-4475-957F-D49018DB2DC8}.Release|Any CPU.Build.0 = Release|Any CPU
{70453D6E-9C19-41BC-8C96-0E20F919DB11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70453D6E-9C19-41BC-8C96-0E20F919DB11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70453D6E-9C19-41BC-8C96-0E20F919DB11}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70453D6E-9C19-41BC-8C96-0E20F919DB11}.Release|Any CPU.Build.0 = Release|Any CPU
{E9F90342-34DE-4166-9769-483A3FA1F144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9F90342-34DE-4166-9769-483A3FA1F144}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9F90342-34DE-4166-9769-483A3FA1F144}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9F90342-34DE-4166-9769-483A3FA1F144}.Release|Any CPU.Build.0 = Release|Any CPU
{D70DD514-081F-4055-8779-6626DA96D18D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D70DD514-081F-4055-8779-6626DA96D18D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D70DD514-081F-4055-8779-6626DA96D18D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D70DD514-081F-4055-8779-6626DA96D18D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FC788BAA-BB25-48AD-BE3D-2046C111AD00} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{C0EB15FC-CB79-4F37-9459-78E9CAEF3647} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{7F5365D9-7E71-452D-8534-4B3A69B5B7E4} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{D23BC4F3-47DF-4E31-96BE-9A4C730D308F} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{9CDFDCBE-7EC1-4951-B685-62D5EFB79D15} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{50B6AABF-6BC2-4B7B-BB48-27200B05476F} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{A53B0FAC-F59B-4021-9A67-997D1F5727D7} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{DF3F9213-6F6D-4832-8738-CA106BE49860} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{AB17A661-1D1D-496C-A39C-B31F3BAEADA1} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{4E87360D-AC39-4475-957F-D49018DB2DC8} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{70453D6E-9C19-41BC-8C96-0E20F919DB11} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{E9F90342-34DE-4166-9769-483A3FA1F144} = {BC948ADE-1674-4955-B27C-F0E96100978E}
{D70DD514-081F-4055-8779-6626DA96D18D} = {BC948ADE-1674-4955-B27C-F0E96100978E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A4B4251F-ADA4-418D-95B5-27BA99A307A3}
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions RustPlusApi/Examples/GetEntityInfo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Newtonsoft.Json;

using RustPlusApi;

using static __Constants.RustPlusConst;

const int entityId = 232773;
var rustPlus = new RustPlus(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
await rustPlus.GetEntityInfoAsync(entityId, message =>
{
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
rustPlus.Dispose();
return true;
});
};

await rustPlus.ConnectAsync();
File renamed without changes.
19 changes: 19 additions & 0 deletions RustPlusApi/Examples/GetInfo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Newtonsoft.Json;

using RustPlusApi;

using static __Constants.RustPlusConst;

var rustPlus = new RustPlus(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
await rustPlus.GetInfoAsync(message =>
{
Console.WriteLine($"Infos:\n{JsonConvert.SerializeObject(message, JsonSettings)}");
rustPlus.Dispose();
return true;
});
};

await rustPlus.ConnectAsync();
File renamed without changes.
19 changes: 19 additions & 0 deletions RustPlusApi/Examples/GetMap/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using RustPlusApi;

using static __Constants.RustPlusConst;

var rustPlus = new RustPlus(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
await rustPlus.GetMapAsync(message =>
{
var imageData = message.Response.Map.JpgImage.ToByteArray();
if (imageData == null) return false;
File.WriteAllBytes("map.jpg", imageData); // Save under RustPlusApi\RustPlusApi\Examples\GetMap\bin\Debug\net8.0
rustPlus.Dispose();
return true;
});
};

await rustPlus.ConnectAsync();
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using __Constants;
using RustPlusApi;

var rustPlus = new RustPlusApi.RustPlusApi(RustPlusConst.Ip, RustPlusConst.Port, RustPlusConst.PlayerId, RustPlusConst.PlayerToken);
using static __Constants.RustPlusConst;

rustPlus.Connected += async (sender, e) =>
var rustPlus = new RustPlus(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
await rustPlus.GetTeamInfoAsync(message =>
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using __Constants;
using RustPlusApi;

var rustPlus = new RustPlusApi.RustPlusApi(RustPlusConst.Ip, RustPlusConst.Port, RustPlusConst.PlayerId, RustPlusConst.PlayerToken);
using static __Constants.RustPlusConst;

rustPlus.Connected += async (sender, e) =>
var rustPlus = new RustPlus(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
await rustPlus.GetTimeAsync(message =>
{
Expand Down
13 changes: 13 additions & 0 deletions RustPlusApi/Examples/SendTeamChat/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using RustPlusApi;

using static __Constants.RustPlusConst;

var rustPlus = new RustPlus(Ip, Port, PlayerId, PlayerToken);

rustPlus.Connected += async (_, _) =>
{
await rustPlus.SendTeamMessageAsync("Hello from RustPlusApi!");
rustPlus.Dispose();
};

await rustPlus.ConnectAsync();
15 changes: 15 additions & 0 deletions RustPlusApi/Examples/SendTeamChat/SendTeamChat.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\RustPlusApi\RustPlusApi.csproj" />
<ProjectReference Include="..\__Constants\__Constants.csproj" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions RustPlusApi/Examples/__Constants/RustPlusConst.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace __Constants
{
public record RustPlusConst
{
public const string Ip = "138.201.18.133";
public const int Port = 28082;
public const ulong PlayerId = 76561198249527954;
public const int PlayerToken = 263698233;

public static JsonSerializerSettings JsonSettings = new()
{
NullValueHandling = NullValueHandling.Ignore,
Formatting = Formatting.Indented,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
Loading

0 comments on commit 35b80c9

Please sign in to comment.