This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Server.cs
89 lines (72 loc) · 2.43 KB
/
Server.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using AstroModIntegrator;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AstroModLoader
{
public class Server
{
[JsonProperty("LobbyID")]
public ulong LobbyID;
[JsonProperty("BuildVersion")]
public int BuildVersion; // unsure what this is
[JsonProperty("RunTime")]
public int RunTime;
[JsonProperty("LastHeartbeat")]
public string LastHeartbeat;
[JsonProperty("Tags")]
public DetailedServerInfo DetailedServerInfo { get; set; }
}
public class DetailedServerInfo
{
[JsonProperty("maxPlayers")]
public int MaxPlayers;
[JsonProperty("numPlayers")]
public int NumPlayers;
[JsonProperty("gameId")]
public string Address;
[JsonProperty("gameBuild")]
[JsonConverter(typeof(VersionConverter))]
public Version GameBuild;
[JsonProperty("serverName")]
public string ServerData; // AstroLauncher servers have JSON here, vanilla servers a random hex string
[JsonProperty("category")]
public string ServerType;
[JsonProperty("requiresPassword")]
public bool RequiresPassword;
}
public class AstroLauncherServerInfo
{
[JsonProperty("ServerName")]
public string ServerName;
[JsonProperty("ServerType")]
public string ServerType;
[JsonProperty("ServerPaks")]
public List<Dictionary<string, string>> ServerPaks; // [{NameOnDisk: MetadataString}, {NameOnDisk: MetadataString}]
public List<Mod> GetAllMods()
{
List<Mod> finalRes = new List<Mod>();
if (ServerPaks == null) return finalRes;
foreach (Dictionary<string, string> keyValuePairs in ServerPaks)
{
foreach (KeyValuePair<string, string> keyValuePair in keyValuePairs)
{
try
{
Mod thisMod = new Mod(JsonConvert.DeserializeObject<Metadata>(keyValuePair.Value), keyValuePair.Key);
if (thisMod.Priority < 999) finalRes.Add(thisMod);
}
catch
{
continue;
}
}
}
return finalRes;
}
}
}