-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
81 lines (77 loc) · 2.84 KB
/
Main.cs
File metadata and controls
81 lines (77 loc) · 2.84 KB
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
using HintServiceMeow.Core.Enum;
using HintServiceMeow.Core.Extension;
using HintServiceMeow.Core.Models.Hints;
using LabApi.Events.Arguments.PlayerEvents;
using LabApi.Features.Console;
using LabApi.Loader.Features.Plugins;
using LabTextChat.API;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LabTextChat
{
public class Main : Plugin<Config>
{
public override string Name => "打字插件";
public override string Description => "基于LabApi以及HSM";
public override string Author => "灰";
public override Version Version => new Version(1,0);
public static Main MainP;
public override Version RequiredApiVersion => new Version(LabApi.Features.LabApiProperties.CompiledVersion);
public override void Enable()
{
MainP = this;
string Paths = Path.Combine(LabApi.Loader.Features.Paths.PathManager.LabApi.ToString(), "TextLog");
if (!Directory.Exists(Paths)) { Directory.CreateDirectory(Paths); }
LogPath = Path.Combine(Paths, $"{Today}.txt");
if (!File.Exists(LogPath)) { File.WriteAllText(LogPath, ""); }
Logger.Debug($"==============");
Logger.Debug($"打字插件已启动");
Logger.Debug($"作者: 灰");
Logger.Debug($"聊天记录目录: {Paths}");
Logger.Debug($"==============");
LabApi.Events.Handlers.PlayerEvents.Joined += OnJoined;
}
public override void Disable()
{
MainP = null;
LabApi.Events.Handlers.PlayerEvents.Joined -= OnJoined;
}
public HintAlignment GetAlignment()
{
string t = Config.ShowAlignment.ToLower();
switch(t)
{
case "right":
return HintAlignment.Right;
case "left":
return HintAlignment.Left;
default:
return HintAlignment.Center;
}
}
public void OnJoined(PlayerJoinedEventArgs ev)
{
if (ev.Player!=null)
{
Hint hint = new Hint()
{
YCoordinate = Config.YCoordinate,
Alignment = GetAlignment(),
FontSize = Config.TextSize,
AutoText = text =>
{
return "====><color=blue>聊天栏</color><====\n" + TextManager.GetText(ev.Player);
}
};
ev.Player.AddHint(hint);
}
}
public static string LogPath { get; set; }
public static string Today => DateTime.Now.ToString("yyyy-MM-dd");
public static string NowTime => DateTime.Now.ToString("F");
}
}