Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
CommunityServerManager.cs
浏览该文件的文档.
1namespace Game {
2 public static class CommunityServerManager {
3 public enum Type {
6 }
7
8 public class Info : IEquatable<Info> {
9 public Type Type;
10 public string Name;
11 public string ApiUrl;
12 public string WebsiteUrl;
13
14 public Info(Type type, string name, string apiUrl, string websiteUrl = null) {
15 Type = type;
16 Name = name;
17 ApiUrl = apiUrl;
18 WebsiteUrl = websiteUrl;
19 }
20
21 public bool Equals(Info other) {
22 if (other is null) {
23 return false;
24 }
25 if (ReferenceEquals(this, other)) {
26 return true;
27 }
28 return Type == other.Type && Name == other.Name && ApiUrl == other.ApiUrl && WebsiteUrl == other.WebsiteUrl;
29 }
30
31 public override string ToString() {
32 return $"{(int)Type}^^{Name}^^{ApiUrl}^^{WebsiteUrl}";
33 }
34
35 public static Info FromString(string str) {
36 string[] parts = str.Split("^^");
37 if (parts.Length == 4 && int.TryParse(parts[0], out int type)) {
38 return new Info((Type)type, parts[1], parts[2], parts[3]);
39 }
40 return null;
41 }
42
43 public Info Clone() => new(Type, Name, ApiUrl, WebsiteUrl);
44 }
45#if BROWSER
46 public static Info DefaultOriginalInfo = new(Type.Original, string.Empty, "https://cloudflare-cors-anywhere.weathered-shadow-6c41.workers.dev/?https://scresdir.appspot.com/resource");
47 public static Info DefaultChineseInfo = new(Type.Chinese, string.Empty, "https://cloudflare-cors-anywhere.weathered-shadow-6c41.workers.dev/?https://m.schub.top/", "https://test.suancaixianyu.cn/#/modList/0");
48#else
49 public static Info DefaultOriginalInfo = new(Type.Original, string.Empty, "https://scresdir.appspot.com/resource");
50 public static Info DefaultChineseInfo = new(Type.Chinese, string.Empty, "https://m.schub.top/", "https://test.suancaixianyu.cn/#/modList/0");
51#endif
52
53 public static List<Info> UserInfos = [];
56
57 public static IEnumerable<Info> GetAllInfos() {
60 yield return DefaultChineseInfo;
61 }
62 }
64 yield return DefaultOriginalInfo;
65 }
66 else {
67 yield return DefaultOriginalInfo;
68 yield return DefaultChineseInfo;
69 }
70 foreach (Info info in UserInfos) {
71 yield return info;
72 }
73 }
74
75 public static void ChangeOriginalInfo(Info info) {
76 if (CurrentOriginalInfo != info && info.Type == Type.Original) {
80 }
81 }
82
83 public static void ChangeChineseInfo(Info info) {
84 if (CurrentChineseInfo != info && info.Type == Type.Chinese) {
88 if (provider is SchubExternalContentProvider schubProvider) {
89 provider.Logout();
90 }
91 }
92 CurrentChineseInfo = info;
93 }
94 }
95 }
96}
static Dictionary< string, string > m_idToAddressMap
static Dictionary< string, bool > m_feedbackCache
Info(Type type, string name, string apiUrl, string websiteUrl=null)
static IEnumerable< Info > GetAllInfos()
static List< IExternalContentProvider > m_providers
static CommunityContentMode CommunityContentMode
static CommunityContentMode OriginalCommunityContentMode
static Dictionary< string, string > m_idToAddressMap
static Dictionary< string, bool > m_feedbackCache