Skip to content

Commit

Permalink
Merge pull request #495 from THEXN/master
Browse files Browse the repository at this point in the history
更新:多项内容
  • Loading branch information
ACaiCat authored Oct 1, 2024
2 parents 59c641b + 189cadb commit ee0f69f
Show file tree
Hide file tree
Showing 26 changed files with 612 additions and 456 deletions.
12 changes: 11 additions & 1 deletion Plugin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JourneyUnlock", "src\Journe
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DumpPluginsList", "src\DumpPluginsList\DumpPluginsList.csproj", "{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatusTextManager", "src\StatusTextManager\StatusTextManager.csproj", "{139C13CE-6E45-44E4-AD7B-B28B3CE51D55}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StatusTextManager", "src\StatusTextManager\StatusTextManager.csproj", "{139C13CE-6E45-44E4-AD7B-B28B3CE51D55}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DonotFuck", "src\DonotFuck\DonotFuck.csproj", "{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -1116,6 +1118,14 @@ Global
{139C13CE-6E45-44E4-AD7B-B28B3CE51D55}.Release|Any CPU.Build.0 = Release|Any CPU
{139C13CE-6E45-44E4-AD7B-B28B3CE51D55}.Release|x64.ActiveCfg = Release|Any CPU
{139C13CE-6E45-44E4-AD7B-B28B3CE51D55}.Release|x64.Build.0 = Release|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Debug|x64.ActiveCfg = Debug|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Debug|x64.Build.0 = Debug|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Release|Any CPU.Build.0 = Release|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Release|x64.ActiveCfg = Release|Any CPU
{C8B882AE-D82E-4AA6-BAFF-17E9E1A04100}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
225 changes: 112 additions & 113 deletions README.md

Large diffs are not rendered by default.

227 changes: 116 additions & 111 deletions README_en.md

Large diffs are not rendered by default.

36 changes: 8 additions & 28 deletions src/AutoTeam/AutoTeamPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
using TShockAPI.Hooks;
using static TShockAPI.GetDataHandlers;

namespace autoteam;
namespace AutoTeam;

[ApiVersion(2, 1)]
public class Autoteam : TerrariaPlugin
public class AutoTeam : TerrariaPlugin
{
public override string Author => "十七改,肝帝熙恩改";
public override Version Version => new Version(2, 4, 3);
public override Version Version => new Version(2, 4, 4);
public override string Description => "AutoTeamPlus";
public override string Name => "更好的自动队伍";
public static Configuration Config;

public Autoteam(Main game) : base(game)
public AutoTeam(Main game) : base(game)
{
}

Expand Down Expand Up @@ -56,30 +56,10 @@ protected override void Dispose(bool disposing)

private void TogglePlugin(CommandArgs args)
{
var player = args.Player;
var parameters = args.Parameters;

if (parameters.Count < 1)
{
player.SendErrorMessage(GetString("用法: /autoteam <on|off>"));
return;
}

var action = parameters[0].ToLower();
switch (action)
{
case "on":
Config.Enabled = true;
player.SendSuccessMessage(GetString("AutoTeamPlus 插件已启用."));
break;
case "off":
Config.Enabled = false;
player.SendSuccessMessage(GetString("AutoTeamPlus 插件已禁用."));
break;
default:
player.SendErrorMessage(GetString("无效的操作。请使用 'on' 或 'off'。"));
break;
}
// 切换插件的状态
Config.Enabled = !Config.Enabled;
string status = Config.Enabled ? GetString("启用") : GetString("禁用");
args.Player.SendSuccessMessage(GetString("AutoTeamPlus 插件已") + status + GetString(""));
}


Expand Down
84 changes: 48 additions & 36 deletions src/AutoTeam/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,66 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using TShockAPI;

namespace autoteam;

public class Configuration
namespace AutoTeam
{
public static readonly string FilePath = Path.Combine(TShock.SavePath, "AutoTeam.json");

[JsonProperty("组的队伍")]
public Dictionary<string, string> GroupTeamMap { get; set; } = new Dictionary<string, string>
{
{ "组名字/groupname", "队伍名称teamname中文或English" },
{ "default", "red" },
{ "某个组", "红队" },
};
[JsonProperty("开启插件")]
public bool Enabled = true;

public string GetTeamForGroup(string groupName)
public class Configuration
{
// 检查映射关系中是否包含给定的组名
return this.GroupTeamMap.ContainsKey(groupName) ? this.GroupTeamMap[groupName] : "无队伍";
}
public static readonly string FilePath = Path.Combine(TShock.SavePath, "AutoTeam.json");

[JsonProperty("开启插件")]
public bool Enabled { get; set; } = true;

public void Write(string path)
{
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
[JsonProperty("组对应的队伍")]
public Dictionary<string, string> GroupTeamMap { get; set; } = new Dictionary<string, string>();


public string GetTeamForGroup(string groupName)
{
var str = JsonConvert.SerializeObject(this, Formatting.Indented);
using (var sw = new StreamWriter(fs))
{
sw.Write(str);
}
return this.GroupTeamMap.TryGetValue(groupName, out var team) ? team : GetString("无队伍");
}
}

public static Configuration Read(string path)
{
if (!File.Exists(path))
public void Write(string path)
{
return new Configuration();
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
{
var str = JsonConvert.SerializeObject(this, Formatting.Indented);
using (var sw = new StreamWriter(fs))
{
sw.Write(str);
}
}
}

using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
public static Configuration Read(string path)
{
using (var sr = new StreamReader(fs))
if (!File.Exists(path))
{
// 创建默认配置
var defaultConfig = new Configuration
{
Enabled = true,
GroupTeamMap = new Dictionary<string, string>
{
{ "default", "red" },
{ "owner", "红队" }
}
};

// 保存默认配置到文件
defaultConfig.Write(path);

return defaultConfig;
}

using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var cf = JsonConvert.DeserializeObject<Configuration>(sr.ReadToEnd());
return cf;
using (var sr = new StreamReader(fs))
{
var cf = JsonConvert.DeserializeObject<Configuration>(sr.ReadToEnd());
return cf;
}
}
}
}
Expand Down
28 changes: 22 additions & 6 deletions src/AutoTeam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
## 更新日志

```
v2.4.3
修复了默认会横插一脚的问题,顺带把指令逻辑改简单了
v2.4.2
添加英文翻译
v2.4.1
Expand All @@ -22,14 +24,28 @@ v2.4.1

## 配置
> 配置文件位置:tshock/AutoTeamPlus.json
- 中文英文队伍名字参考如下:

| 中文 | English |
|-------|---------|
| 无队伍 | none |
| 红队 | red |
| 绿队 | green |
| 蓝队 | blue |
| 黄队 | yellow |
| 粉队 | pink |

- 配置示例
```json
{
"组的队伍": {
"组名字": "队伍名称中文或English",//本行和下面两行均可改
"default": "red",
"亲爱的": "红队"
},
"开启插件": true
"开启插件": true,
"组对应的队伍": {
"guest": "pink",
"default": "蓝队",
"owner": "红队",
"admin": "green",
"vip": "none"
}
}
```
## 反馈
Expand Down
32 changes: 23 additions & 9 deletions src/AutoTeam/README_EN.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
# AutoTeamPlus

- Authors: 十七,肝帝熙恩
- Source: No
- 自动分配一个组的玩家到特定队伍
- Source: None
- Automatically assign players from a group to a specific team

## Commands

| Command | Permission | Details |
|------------------|:---------------:| :------: |
| /autoteam or /at | autoteam.toggle | Toggle the automatic team assignment feature. |
| No | noautoteam | Having this permission will not automatically assign you to a team. |
| None | noautoteam | Having this permission will not automatically assign you to a team. |

## Config
> Configuration file location:tshock/AutoTeamPlus.json
- Team Name Reference:

| 中文 | English |
|-------|---------|
| 无队伍 | none |
| 红队 | red |
| 绿队 | green |
| 蓝队 | blue |
| 黄队 | yellow |
| 粉队 | pink |

- Configuration Example
```json
{
"组的队伍": { //Group -> Team
"组名字": "队伍名称中文或English",//本行和下面两行均可改
"default": "red",
"admin": "green"
},
"开启插件": true //Enable
"开启插件": true, // Enable Plugin
"组对应的队伍": { ////Group -> Team
"guest": "pink",
"default": "蓝队",
"owner": "红队",
"admin": "green",
"vip": "none"
}
}
```
## FeedBack
Expand Down
40 changes: 22 additions & 18 deletions src/AutoTeam/i18n/en-US.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: AutoTeam\n"
"POT-Creation-Date: 2024-09-07 23:45:12+0800\n"
"PO-Revision-Date: 2024-09-01 11:23+0800\n"
"POT-Creation-Date: 2024-10-01 00:21:20+0800\n"
"PO-Revision-Date: 2024-10-01 00:28+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en_US\n"
Expand All @@ -11,33 +11,37 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.5\n"

#: ..\..\AutoTeamPlus.cs:62
msgid "。"
msgstr "."

#: ..\..\AutoTeamPlus.cs:31
#, fuzzy
#| msgid "[AutoTeam] 重新加载配置完毕。"
msgid "[自动队伍] 重新加载配置完毕。"
msgstr "[AutoTeam] Configuration reloaded successfully."

#: ..\..\AutoTeamPlus.cs:130
#: ..\..\AutoTeamPlus.cs:61
msgid "禁用"
msgstr "disabled"

#: ..\..\AutoTeamPlus.cs:110
#, csharp-format
msgid "你的队伍已切换为 {0}."
msgstr "Your team has been switched to {0}."

#: ..\..\AutoTeamPlus.cs:134
#: ..\..\AutoTeamPlus.cs:61
msgid "启用"
msgstr "enabled"

#: ..\..\AutoTeamPlus.cs:114
msgid "未配置,可随意切换."
msgstr "Not configured, can freely switch teams."

#: ..\..\AutoTeamPlus.cs:80
msgid "无效的操作。请使用 'on' 或 'off'。"
msgstr "Invalid operation. Please use ‘on’ or ‘off’."

#: ..\..\AutoTeamPlus.cs:64
msgid "用法: /autoteam <on|off>"
msgstr "Usage: /autoteam <on|off>"

#: ..\..\AutoTeamPlus.cs:77
msgid "AutoTeamPlus 插件已禁用."
msgstr "The AutoTeamPlus plugin has been disabled."
#: ..\..\Configuration.cs:21
msgid "无队伍"
msgstr "None"

#: ..\..\AutoTeamPlus.cs:73
msgid "AutoTeamPlus 插件已启用."
msgstr "The AutoTeamPlus plugin has been enabled."
#: ..\..\AutoTeamPlus.cs:62
msgid "AutoTeamPlus 插件已"
msgstr "AutoTeamPlus plugin is now"
Loading

0 comments on commit ee0f69f

Please sign in to comment.