Add some client API

This commit is contained in:
sardelka9515
2022-08-27 14:17:10 +08:00
parent accdbbcbc6
commit f44558cd3b
6 changed files with 60 additions and 78 deletions

View File

@ -4,6 +4,7 @@ using RageCoop.Core;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace RageCoop.Client.Scripting
{
@ -212,13 +213,12 @@ namespace RageCoop.Client.Scripting
/// Get a <see cref="Core.Logger"/> that RAGECOOP is currently using.
/// </summary>
/// <returns></returns>
public static Logger Logger
{
get
{
return Main.Logger;
}
}
public static Logger Logger => Main.Logger;
/// <summary>
/// Get all players indexed by their ID
/// </summary>
public static Dictionary<int,Player> Players => new Dictionary<int, Player>(PlayerList.Players);
#endregion
#region FUNCTIONS
@ -245,6 +245,15 @@ namespace RageCoop.Client.Scripting
Networking.ToggleConnection(null);
}
}
/// <summary>
/// List all servers from master server address
/// </summary>
/// <returns></returns>
public static List<ServerInfo> ListServers()
{
return JsonConvert.DeserializeObject<List<ServerInfo>>(HttpHelper.DownloadString(Main.Settings.MasterServer));
}
/// <summary>
/// Send a local chat message to this player