mirror of
https://github.com/zs-yg/MCSJ.git
synced 2025-12-06 10:50:42 +08:00
Compare commits
5 Commits
v0.0.3
...
ddc0d1d9e0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddc0d1d9e0 | ||
|
|
adaa360265 | ||
|
|
e2219d5042 | ||
|
|
8982aa9bcc | ||
|
|
0b6f66304b |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
bin/
|
||||
obj/
|
||||
logs/
|
||||
profiles/
|
||||
14
Program.cs
14
Program.cs
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MCSJ.Tools;
|
||||
using MCSJ.Tools.LogSystem;
|
||||
|
||||
namespace MCSJ
|
||||
{
|
||||
@@ -8,8 +9,15 @@ namespace MCSJ
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// 验证日志目录
|
||||
string logDir = LogCreator.GetLogDirectory();
|
||||
Console.WriteLine($"日志目录: {logDir}");
|
||||
LogMain.Debug($"日志文件: {LogCreator.GetLogFilePath()}");
|
||||
|
||||
LogMain.Info("MC服务器下载工具启动");
|
||||
var versionManager = new VersionManager();
|
||||
var downloadService = new DownloadService(versionManager);
|
||||
LogMain.Debug("服务初始化完成");
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -20,21 +28,27 @@ namespace MCSJ
|
||||
Console.Write("请选择操作: ");
|
||||
|
||||
var input = Console.ReadLine();
|
||||
LogMain.Debug($"用户选择操作: {input}");
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case "1":
|
||||
versionManager.DisplayAllVersions();
|
||||
LogMain.Info("显示所有版本列表");
|
||||
break;
|
||||
case "2":
|
||||
Console.Write("请输入要下载的版本名称: ");
|
||||
var version = Console.ReadLine();
|
||||
LogMain.Info($"开始下载版本: {version}");
|
||||
await downloadService.DownloadVersion(version);
|
||||
LogMain.Info($"版本下载完成: {version}");
|
||||
break;
|
||||
case "3":
|
||||
LogMain.Info("程序正常退出");
|
||||
return;
|
||||
default:
|
||||
Console.WriteLine("无效输入,请重新选择");
|
||||
LogMain.Warn($"无效的用户输入: {input}");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,17 @@ MCSJ 项目由 [zs-yg](https://github.com/zs-yg) 开发,欢迎提交 issue 和
|
||||
|
||||
qq群:1043867176
|
||||
|
||||
[b站号]:(https://space.bilibili.com/1698250734)
|
||||
b站号:https://space.bilibili.com/1698250734
|
||||
|
||||
|
||||
## 开源协议
|
||||
|
||||
MIT协议
|
||||
本项目已在 GitHub 开源,欢迎贡献代码与建议。
|
||||
|
||||
# 恰饭awa
|
||||
|
||||
不用捐款,使用这个链接注册服务器就行了awa
|
||||
性能不错,可以免费白嫖
|
||||
|
||||
服务器:https://www.rainyun.com/Nzk2NDEy_
|
||||
|
||||
29
Tools/log_systeam/log_creator.cs
Normal file
29
Tools/log_systeam/log_creator.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MCSJ.Tools.LogSystem
|
||||
{
|
||||
public static class LogCreator
|
||||
{
|
||||
public static string GenerateLogFileName()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
return $"{now:yyyy-MM-dd-HH-mm-ss}.log";
|
||||
}
|
||||
|
||||
public static string GetLogDirectory()
|
||||
{
|
||||
string logDir = Path.Combine(Directory.GetCurrentDirectory(), "logs");
|
||||
if (!Directory.Exists(logDir))
|
||||
{
|
||||
Directory.CreateDirectory(logDir);
|
||||
}
|
||||
return logDir;
|
||||
}
|
||||
|
||||
public static string GetLogFilePath()
|
||||
{
|
||||
return Path.Combine(GetLogDirectory(), GenerateLogFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Tools/log_systeam/log_main.cs
Normal file
37
Tools/log_systeam/log_main.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace MCSJ.Tools.LogSystem
|
||||
{
|
||||
public static class LogMain
|
||||
{
|
||||
private static readonly object _lock = new object();
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARN,
|
||||
ERROR,
|
||||
FATAL
|
||||
}
|
||||
|
||||
public static void Log(LogLevel level, string message)
|
||||
{
|
||||
string logEntry = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{level}] {message}";
|
||||
string logPath = LogCreator.GetLogFilePath();
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
File.AppendAllText(logPath, logEntry + Environment.NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Debug(string message) => Log(LogLevel.DEBUG, message);
|
||||
public static void Info(string message) => Log(LogLevel.INFO, message);
|
||||
public static void Warn(string message) => Log(LogLevel.WARN, message);
|
||||
public static void Error(string message) => Log(LogLevel.ERROR, message);
|
||||
public static void Fatal(string message) => Log(LogLevel.FATAL, message);
|
||||
}
|
||||
}
|
||||
7
build.bat
Normal file
7
build.bat
Normal file
@@ -0,0 +1,7 @@
|
||||
dotnet publish MCSJ.csproj -c Release -r win-x86 --self-contained false /p:Optimize=true /p:DebugType=None
|
||||
dotnet publish MCSJ.csproj -c Release -r win-x64 --self-contained false /p:Optimize=true /p:DebugType=None
|
||||
cd bin\Release\net8.0
|
||||
ren win-x64 MCSJ-x64
|
||||
ren win-x86 MCSJ-x86
|
||||
rmdir /s /q MCSJ-x64\publish
|
||||
rmdir /s /q MCSJ-x86\publish
|
||||
Reference in New Issue
Block a user