Skip to content

Commit d8d869b

Browse files
authored
1.0.0-alpha.8 (#8)
* 音频系统的小改,部分注释补充 * 注释补充 * 问题的修复 (#6) * add BDNT(Bypass Do Not Track) * add GetAllProperties * 修复功能 * 修复错版 (#10)
1 parent d927248 commit d8d869b

File tree

7 files changed

+147
-91
lines changed

7 files changed

+147
-91
lines changed

Commands/PlayerCommand.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using CommandSystem;
2+
using Exiled.API.Features;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using YongAnFrame.Players;
9+
10+
namespace YongAnFrame.Commands
11+
{
12+
[CommandHandler(typeof(ClientCommandHandler))]
13+
public class PlayerCommand : ICommand
14+
{
15+
public string Command => "player";
16+
17+
public string[] Aliases => ["play", "pl", "pr"];
18+
19+
public string Description => "用于管理自己的用户";
20+
21+
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
22+
{
23+
response = "NULL";
24+
if (arguments.Count < 2)
25+
{
26+
switch (arguments.Array[1])
27+
{
28+
case "BDNT":
29+
if (Player.TryGet(sender, out Player player))
30+
{
31+
FramePlayer fPlayer = FramePlayer.Get(player);
32+
fPlayer.HintManager.Clean();
33+
string[] text = new string[36];
34+
35+
fPlayer.ExPlayer.ShowHint($"<size=20>{string.Join("\n", text)}\n\n\n\n\n\n\n\n\n\n\n\n\n\n</size>", 10000f);
36+
}
37+
38+
return true;
39+
}
40+
41+
}
42+
return false;
43+
}
44+
}
45+
}

Components/CapacityList.cs

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,33 @@
88

99
namespace YongAnFrame.Components
1010
{
11-
public class CapacityList<T>(int capacity) : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
11+
public class CapacityList<T>(int capacity)
1212
{
1313
private readonly List<T> list = new(capacity);
14+
1415
public int Capacity { get; set; } = capacity;
1516

1617
public int Count => list.Count;
1718

18-
public bool IsReadOnly => ((ICollection<T>)list).IsReadOnly;
19-
2019
public T this[int index]
2120
{
22-
get => list[index];
23-
set => list[index] = value;
24-
}
25-
26-
public int IndexOf(T item)
27-
{
28-
return list.IndexOf(item);
29-
}
30-
31-
public void Insert(int index, T item)
32-
{
33-
list.Insert(index, item);
34-
}
21+
get
22+
{
23+
if (Count > index)
24+
{
25+
return list[index];
26+
}
27+
return default;
28+
}
29+
set
30+
{
3531

36-
public void RemoveAt(int index)
37-
{
38-
list.RemoveAt(index);
32+
}
3933
}
4034

4135
public void Add(T item)
4236
{
43-
if (Capacity <= list.Count)
37+
if (Capacity > list.Count)
4438
{
4539
list.Add(item);
4640
}
@@ -51,34 +45,9 @@ public void Add(T item)
5145
}
5246
}
5347

54-
public void Clear()
55-
{
56-
list.Clear();
57-
}
58-
59-
public bool Contains(T item)
60-
{
61-
return list.Contains(item);
62-
}
63-
64-
public void CopyTo(T[] array, int arrayIndex)
65-
{
66-
list.CopyTo(array, arrayIndex);
67-
}
68-
6948
public bool Remove(T item)
7049
{
7150
return list.Remove(item);
7251
}
73-
74-
IEnumerator IEnumerable.GetEnumerator()
75-
{
76-
return list.GetEnumerator();
77-
}
78-
79-
IEnumerator<T> IEnumerable<T>.GetEnumerator()
80-
{
81-
return ((IEnumerable<T>)list).GetEnumerator();
82-
}
8352
}
8453
}

Players/FramePlayer.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Exiled.API.Features;
2+
using Exiled.CustomRoles.API;
23
using Exiled.Events.EventArgs.Player;
34
using Exiled.Events.Features;
45
using MEC;
@@ -30,7 +31,16 @@ public sealed class FramePlayer
3031
/// <summary>
3132
/// 实例拥有的自定义角色
3233
/// </summary>
33-
public CustomRolePlus CustomRolePlus { get; internal set; }
34+
public CustomRolePlus CustomRolePlus {
35+
get
36+
{
37+
if (ExPlayer.GetCustomRoles().Count != 0)
38+
{
39+
return (CustomRolePlus)ExPlayer.GetCustomRoles()[0];
40+
}
41+
return null;
42+
}
43+
}
3444
/// <summary>
3545
/// 提示系统管理器
3646
/// </summary>
@@ -39,7 +49,10 @@ public sealed class FramePlayer
3949
/// 玩家等级
4050
/// </summary>
4151
public ulong Level { get; set; }
42-
52+
/// <summary>
53+
/// 玩家批准绕过DNT
54+
/// </summary>
55+
public bool IsBDNT { get; set; }
4356
/// <summary>
4457
/// 正在使用的名称称号
4558
/// </summary>
@@ -72,7 +85,8 @@ private static void OnStaticVerified(VerifiedEventArgs args)
7285
}
7386
private static void OnStaticDestroying(DestroyingEventArgs args)
7487
{
75-
args.Player.ToFPlayer().Invalid();
88+
FramePlayer fPlayer = args.Player.ToFPlayer();
89+
fPlayer.Invalid();
7690
}
7791
//private static void OnStaticWaitingForPlayers()
7892
//{
@@ -175,6 +189,11 @@ internal void UpdateShowInfoList()
175189
ExPlayer.RankName = CustomRolePlus.Name;
176190
ExPlayer.RankColor = CustomRolePlus.NameColor;
177191
}
192+
else
193+
{
194+
ExPlayer.RankName = string.Empty;
195+
ExPlayer.RankColor = string.Empty;
196+
}
178197
}
179198

180199
if (usingTitles == null) ExPlayer.CustomName = $"[LV:{Level}]{ExPlayer.Nickname}";

Players/HintManager.cs

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using MEC;
1+
using Exiled.API.Features;
2+
using MEC;
23
using System.Collections.Generic;
34
using System.Reflection;
45
using YongAnFrame.Components;
@@ -17,7 +18,6 @@ public sealed class HintManager
1718

1819
private readonly CoroutineHandle coroutine;
1920

20-
2121
public Text[] CustomText = new Text[20];
2222
public CapacityList<Text> MessageTexts { get; } = new(7);
2323
public CapacityList<Text> ChatTexts { get; } = new(6);
@@ -33,25 +33,36 @@ public IEnumerator<float> Update()
3333
{
3434
string[] text = new string[36];
3535

36-
int usedMex = text.Length - 1;
3736
int used = 0;
3837
text[used] = $"YongAnFrame 1.0.0-alpha7";
38+
39+
if (fPlayer.ExPlayer.DoNotTrack && !fPlayer.IsBDNT)
40+
{
41+
text[used] = "[注意]已开启DoNotTrack(DNT),游戏数据不会被保存,想保存数据请控制台输入pl BDNT查看详情";
42+
}
43+
3944
used = 1;
4045
text[used] = "<align=left>";
4146

42-
for (int i = 0; i < ChatTexts.Count; i++)
47+
for (int i = 0; i < ChatTexts.Capacity; i++)
4348
{
44-
Text textData = ChatTexts[i];
45-
46-
text[used] += textData;
47-
used++;
48-
49-
textData.Duration--;
50-
if (textData.Duration <= 0)
49+
Text chatText = ChatTexts[i];
50+
if(chatText != null)
51+
{
52+
text[used] += chatText;
53+
chatText.Duration--;
54+
55+
if (chatText.Duration <= 0)
56+
{
57+
ChatTexts.Remove(chatText);
58+
i--;
59+
}
60+
}
61+
else
5162
{
52-
ChatTexts.Remove(textData);
53-
i--;
63+
text[used] = string.Empty;
5464
}
65+
used++;
5566
}
5667

5768
foreach (Text data in CustomText)
@@ -60,28 +71,34 @@ public IEnumerator<float> Update()
6071
used++;
6172
}
6273

63-
64-
for (int i = 0; i < MessageTexts.Count; i++)
74+
for (int i = 0; i < MessageTexts.Capacity; i++)
6575
{
6676
Text messageText = MessageTexts[i];
67-
text[used] = $"[{messageText.Duration}]{messageText}";
68-
69-
messageText.Duration--;
70-
if (messageText.Duration <= 0)
77+
if (messageText != null)
78+
{
79+
text[used] = $"[{messageText.Duration}]{messageText}";
80+
81+
messageText.Duration--;
82+
if (messageText.Duration <= 0)
83+
{
84+
MessageTexts.Remove(messageText);
85+
i--;
86+
}
87+
}
88+
else
7189
{
72-
MessageTexts.Remove(messageText);
73-
i--;
90+
text[used] = string.Empty;
7491
}
92+
used++;
7593
}
76-
7794
text[used] += "</align>";
7895

7996
if (fPlayer.CustomRolePlus != null)
8097
{
8198
text[34] = fPlayer.CustomRolePlus.Name;
8299
text[35] = fPlayer.CustomRolePlus.Description;
83100
}
84-
101+
85102
fPlayer.ExPlayer.ShowHint($"<size=20>{string.Join("\n", text)}\n\n\n\n\n\n\n\n\n\n\n\n\n\n</size>", 2f);
86103
yield return Timing.WaitForSeconds(1f);
87104
}

0 commit comments

Comments
 (0)