Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions GoodNight/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using System.Text;
using TShockAPI;
using static Org.BouncyCastle.Math.EC.ECCurve;

public class TimeRange
{
Expand All @@ -24,7 +25,7 @@ internal class Configuration
[JsonProperty("踢出玩家断连消息", Order = -9)]
public string NewProjMessage = "到点了,晚安";
[JsonProperty("断连豁免玩家", Order = -9)]
public List<string> PlayersList { get; set; }
public List<string> PlayersList { get; set; } = new List<string>() { "羽学" };
Comment thread
ACaiCat marked this conversation as resolved.
Outdated

[JsonProperty("禁怪少于人数(设1为关闭禁怪)", Order = -8)]
public int MaxPlayers { get; set; } = 2;
Expand All @@ -36,14 +37,9 @@ internal class Configuration
};

[JsonProperty("禁止怪物生成表(NpcID)", Order = -6)]
public HashSet<int> Npcs = new();
Comment thread
ACaiCat marked this conversation as resolved.
public HashSet<int> Npcs = new HashSet<int>() { 4, 13, 14, 15, 35, 36, 37, 50, 113, 114, 125, 126, 127, 128, 129, 130, 131, 134, 135, 136, 222, 245, 246, 247, 248, 249, 262, 266, 370, 396, 397, 398, 400, 439, 440, 422, 493, 507, 517, 636, 657, 668 };

#region 读取与创建配置文件方法
public Configuration()
{
PlayersList = new List<string>();
}

public void Write()
{
using (var fs = new FileStream(FilePath, FileMode.Create, FileAccess.Write, FileShare.Write))
Expand Down Expand Up @@ -96,7 +92,7 @@ public bool Del(string name)
return true;
}
return false;
}
}
#endregion
}
}
13 changes: 8 additions & 5 deletions GoodNight/Goodnight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ protected override void Dispose(bool disposing)
#region 配置文件创建与重读加载方法
internal static void LoadConfig(ReloadEventArgs args = null!)
{
if (File.Exists(Configuration.FilePath))
Config = Configuration.Read();
if (!File.Exists(Configuration.FilePath))
{
Config = new Configuration();
Config.Write();
}

else
{
Config.PlayersList = new() { "羽学" };
Config.Npcs = new HashSet<int>() { 4, 13, 14, 15, 35, 36, 37, 50, 113, 114, 125, 126, 127, 128, 129, 130, 131, 134, 135, 136, 222, 245, 246, 247, 248, 249, 262, 266, 370, 396, 397, 398, 400, 439, 440, 422, 493, 507, 517, 636, 657, 668 };
Config = Configuration.Read();
}
Config.Write();

if (args != null && args.Player != null)
{
args.Player.SendSuccessMessage("[宵禁]重新加载配置完毕。");
Expand Down