-
Notifications
You must be signed in to change notification settings - Fork 24
add:TrCDK #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
THEXN
wants to merge
27
commits into
UnrealMultiple:master
Choose a base branch
from
THEXN:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
add:TrCDK #992
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b9ce36e
update:TPallow默认允许
THEXN d85cb33
add:TrCDK
THEXN b77b025
doc
THEXN c2645a5
doc:en
THEXN dfa44f5
fix:补药灌注我
THEXN 0b8532a
fix:waring
THEXN f11d46d
重构
Controllerdestiny 74ed183
LazyAPI命令系统支持可选参数
Controllerdestiny 91cd490
docs(TrCDK): 修正更新日志格式
ACaiCat deb410b
refactor(EssentialsPlus): 用`REPLACE`替代`INSERT OR REPLACE`以兼容MySQL
ACaiCat c5a0a34
Merge branch 'UnrealMultiple:master' into master
THEXN e1420a5
Merge branch 'UnrealMultiple:master' into master
THEXN 62b10ba
docs(TrCDK): 删除多余日志
ACaiCat 8b72411
自动更新子模块 [skip ci]
actions-user 1c19f73
自动更新子模块 [skip ci]
actions-user 7c7c89b
Merge branch 'UnrealMultiple:master' into master
THEXN 7987f58
update:作为基础插件,不再依赖LazyAPI
THEXN 86786e1
Merge branch 'master' into master
ACaiCat d36efa7
feat(LazyAPI): add `HelpText` support
ACaiCat b102e4a
fix(LazyAPI): remove method target for `HelpTextAttribute`
ACaiCat 89ee85a
feat(LazyAPI): add `UsageAttribute` to set custom usage
ACaiCat c3aaff2
Merge branch 'UnrealMultiple:master' into master
THEXN c065ae0
chore: 自动更新子模块
actions-user d2530c0
chore: 自动更新子模块
actions-user 3bf350e
chore: 自动更新子模块
actions-user b30626f
Merge branch 'UnrealMultiple:master' into master
THEXN 2ab5eff
Merge branch 'UnrealMultiple:master' into master
THEXN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,8 @@ | |
| ``` | ||
|
|
||
| ## 更新日志 | ||
| ### v1.1.0 | ||
| - Tpallow默认允许传送 | ||
| ### v1.0.9 | ||
| - 数据库记录玩家tpallow状态 | ||
| ### v1.0.7 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| using System.Data; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using Microsoft.Data.Sqlite; | ||
|
|
||
| namespace TrCDK; | ||
|
|
||
| public class CDK | ||
| { | ||
| public string Cdkname { get; set; } = ""; | ||
| public int Usetime { get; set; } | ||
| public long Utiltime { get; set; } | ||
| public string Grouplimit { get; set; } = ""; | ||
| public string Playerlimit { get; set; } = ""; | ||
| public string Used { get; set; } = ""; | ||
| public string Cmds { get; set; } = ""; | ||
| } | ||
|
|
||
| internal class Data | ||
| { | ||
| public static SqliteConnection? DB; | ||
| const string path = "tshock/TrCDK.sqlite"; | ||
|
|
||
| public static void Init() | ||
ACaiCat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
ACaiCat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| DB = new SqliteConnection($"Data Source={path};"); | ||
| DB.Open(); | ||
|
|
||
| // 使用参数化命令创建表 | ||
| using var cmd = new SqliteCommand( | ||
| "CREATE TABLE IF NOT EXISTS Data(" + | ||
| "CDKname TEXT PRIMARY KEY, " + | ||
| "Usetime INTEGER, " + | ||
| "Utiltime INTEGER, " + | ||
| "Grouplimit TEXT, " + | ||
| "Playerlimit TEXT, " + | ||
| "Used TEXT, " + | ||
| "Cmds TEXT)", DB); | ||
| cmd.ExecuteNonQuery(); | ||
| } | ||
|
|
||
| public static bool Insert(string CDKname, int Usetime, long Utiltime, string Grouplimit, string Playerlimit, string Cmds) | ||
| { | ||
| if (DB == null) | ||
| { | ||
| throw new InvalidOperationException(GetString("数据库未初始化")); | ||
| } | ||
|
|
||
ACaiCat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // 使用参数化查询检查CDK是否已存在 | ||
| using (var checkCmd = new SqliteCommand("SELECT COUNT(*) FROM Data WHERE CDKname = @cdkname", DB)) | ||
| { | ||
| checkCmd.Parameters.AddWithValue("@cdkname", CDKname); | ||
| var count = Convert.ToInt32(checkCmd.ExecuteScalar()); | ||
| if (count > 0) | ||
| { | ||
| return false; // CDK已存在 | ||
| } | ||
| } | ||
|
|
||
| // 使用参数化查询插入新CDK | ||
| using var insertCmd = new SqliteCommand( | ||
| "INSERT INTO Data (CDKname, Usetime, Utiltime, Grouplimit, Playerlimit, Used, Cmds) " + | ||
| "VALUES (@cdkname, @usetime, @utiltime, @grouplimit, @playerlimit, @used, @cmds)", DB); | ||
|
|
||
| insertCmd.Parameters.AddWithValue("@cdkname", CDKname); | ||
| insertCmd.Parameters.AddWithValue("@usetime", Usetime); | ||
| insertCmd.Parameters.AddWithValue("@utiltime", Utiltime); | ||
| insertCmd.Parameters.AddWithValue("@grouplimit", Grouplimit); | ||
| insertCmd.Parameters.AddWithValue("@playerlimit", Playerlimit); | ||
| insertCmd.Parameters.AddWithValue("@used", ""); | ||
| insertCmd.Parameters.AddWithValue("@cmds", Cmds); | ||
|
|
||
| insertCmd.ExecuteNonQuery(); | ||
| return true; | ||
| } | ||
|
|
||
| public static void Update(string CDKname, int Usetime, long Utiltime, string Grouplimit, string Playerlimit, string Used, string Cmds) | ||
| { | ||
| if (DB == null) | ||
| { | ||
| throw new InvalidOperationException(GetString("数据库未初始化")); | ||
| } | ||
|
|
||
| using var updateCmd = new SqliteCommand( | ||
| "UPDATE Data SET Usetime = @usetime, Utiltime = @utiltime, Grouplimit = @grouplimit, " + | ||
| "Playerlimit = @playerlimit, Used = @used, Cmds = @cmds WHERE CDKname = @cdkname", DB); | ||
|
|
||
| updateCmd.Parameters.AddWithValue("@usetime", Usetime); | ||
| updateCmd.Parameters.AddWithValue("@utiltime", Utiltime); | ||
| updateCmd.Parameters.AddWithValue("@grouplimit", Grouplimit); | ||
| updateCmd.Parameters.AddWithValue("@playerlimit", Playerlimit); | ||
| updateCmd.Parameters.AddWithValue("@used", Used); | ||
| updateCmd.Parameters.AddWithValue("@cmds", Cmds); | ||
| updateCmd.Parameters.AddWithValue("@cdkname", CDKname); | ||
|
|
||
| updateCmd.ExecuteNonQuery(); | ||
| } | ||
|
|
||
| public static CDK GetData(string name) | ||
| { | ||
| if (DB == null) | ||
| { | ||
| throw new InvalidOperationException(GetString("数据库未初始化")); | ||
| } | ||
|
|
||
| var result = new CDK(); | ||
| using var cmd = new SqliteCommand("SELECT * FROM Data WHERE CDKname = @name", DB); | ||
| cmd.Parameters.AddWithValue("@name", name); | ||
|
|
||
| using var reader = cmd.ExecuteReader(); | ||
| if (reader.Read()) | ||
| { | ||
| result = new CDK() | ||
| { | ||
| Cdkname = reader.GetString(0), | ||
| Usetime = reader.GetInt32(1), | ||
| Utiltime = reader.GetInt64(2), | ||
| Grouplimit = reader.GetString(3), | ||
| Playerlimit = reader.GetString(4), | ||
| Used = reader.GetString(5), | ||
| Cmds = reader.GetString(6) | ||
| }; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| public static CDK[] GetAllData() | ||
| { | ||
| if (DB == null) | ||
| { | ||
| throw new InvalidOperationException(GetString("数据库未初始化")); | ||
| } | ||
|
|
||
| var result = new List<CDK>(); | ||
| using var cmd = new SqliteCommand("SELECT * FROM Data", DB); | ||
| using var reader = cmd.ExecuteReader(); | ||
|
|
||
| while (reader.Read()) | ||
| { | ||
| result.Add(new CDK() | ||
| { | ||
| Cdkname = reader.GetString(0), | ||
| Usetime = reader.GetInt32(1), | ||
| Utiltime = reader.GetInt64(2), | ||
| Grouplimit = reader.GetString(3), | ||
| Playerlimit = reader.GetString(4), | ||
| Used = reader.GetString(5), | ||
| Cmds = reader.GetString(6) | ||
| }); | ||
| } | ||
| return result.ToArray(); | ||
| } | ||
|
|
||
| public static bool DelCDK(string name) | ||
| { | ||
| if (DB == null) | ||
| { | ||
| throw new InvalidOperationException(GetString("数据库未初始化")); | ||
| } | ||
|
|
||
| using var cmd = new SqliteCommand("DELETE FROM Data WHERE CDKname = @name", DB); | ||
| cmd.Parameters.AddWithValue("@name", name); | ||
| cmd.ExecuteNonQuery(); | ||
| return true; | ||
| } | ||
|
|
||
| // 关闭数据库连接的 | ||
| public static void Close() | ||
| { | ||
| DB?.Close(); | ||
| DB?.Dispose(); | ||
| DB = null; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.