Skip to content

Commit

Permalink
Merge pull request #212 from THEXN/master
Browse files Browse the repository at this point in the history
更新:switch插件
  • Loading branch information
Controllerdestiny authored Jun 16, 2024
2 parents 6b88beb + 780a258 commit 0d0a1e0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
32 changes: 18 additions & 14 deletions SwitchCommands/PluginCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SwitchCommands
public class PluginCommands
{
public static Database database = null!;
public static string switchParameters = "/开关 <添加/列表/删除/冷却/说明/权限忽略/取消/重绑/完成> (支持拼音)";
public static string switchParameters = "/开关 <添加/列表/删除/冷却/权限忽略/取消/重绑/完成>(拼音首字母也可以)\n/switch <add/list/del/cooldown/ignoreperms/cancel/rebind/done>";

public static void RegisterCommands()
{
Expand Down Expand Up @@ -82,18 +82,18 @@ private static void SwitchCmd(CommandArgs args)
case "冷却":
case "cooldown":
case "lq":
float 冷却 = 0;
float cooldown = 0;

if (args.Parameters.Count < 2 || !float.TryParse(args.Parameters[1], out 冷却))
if (args.Parameters.Count < 2 || !float.TryParse(args.Parameters[1], out cooldown))
{
player.SendErrorMessage("语法错误:/开关 冷却 <秒>");
SwitchCommands.database.Write(Database.databasePath);
return;
}

cmdInfo.cooldown = 冷却;
cmdInfo.cooldown = cooldown;

player.SendSuccessMessage("冷却时间已设置为 {0} 秒".SFormat(冷却));
player.SendSuccessMessage("冷却时间已设置为 {0} 秒".SFormat(cooldown));
SwitchCommands.database.Write(Database.databasePath);
break;

Expand All @@ -105,35 +105,39 @@ private static void SwitchCmd(CommandArgs args)
SwitchCommands.database.Write(Database.databasePath);
return;
}
string 说明 = args.Parameters[1];
string shows = args.Parameters[1];

cmdInfo.show = 说明;
cmdInfo.show = shows;

player.SendSuccessMessage($"开关说明已设置为:{说明}");
player.SendSuccessMessage($"开关说明已设置为:{shows}");
SwitchCommands.database.Write(Database.databasePath);
break;

case "权限忽略":
case "ignoreperms":
case "qxhl":
case "hl":
bool 权限忽略 = false;

bool ignoreperms = false;
if (!args.Player.HasPermission("switch.ignoreperms"))//权限控制
{
player.SendErrorMessage("你没有权限使用此命令");
return;
}
if (args.Parameters.Count < 2)
{
// 如果没有提供第二个参数,默认设置为true
权限忽略 = true;
ignoreperms = true;
}
else if (!bool.TryParse(args.Parameters[1], out 权限忽略))
else if (!bool.TryParse(args.Parameters[1], out ignoreperms))
{
player.SendErrorMessage("语法错误:/开关 权限忽略 <true/false>");
SwitchCommands.database.Write(Database.databasePath);
return;
}

cmdInfo.ignorePerms = 权限忽略;
cmdInfo.ignorePerms = ignoreperms;

string statusMessage = 权限忽略 ? "是" : "否";
string statusMessage = ignoreperms ? "是" : "否";
player.SendSuccessMessage("是否忽略玩家权限设置为: {0}.".SFormat(statusMessage));
SwitchCommands.database.Write(Database.databasePath);
break;
Expand Down
4 changes: 4 additions & 0 deletions SwitchCommands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
## 更新日志

```
1.2.2
修改中文变量为英文变量
添加权限,switch.ignoreperm,当有这个权限时,才可以赋予指令开关忽略权限的能力
1.2.1
汉化了配置文件,加入了新指令:/开关 说明
加入了只对指令开关的特殊保护,可通过配置项开启关闭
Expand All @@ -27,6 +30,7 @@
| -------------- | :-----------------: | :------: |
| /switch(开关) <添加/列表/删除/冷却/说明/权限忽略/取消/重绑/完成> | switch.admin | 使用开关指令 |
| /kg add list del lq sm qxhl qx cb wc | switch.admin | 使用开关指令 |
| /switch ignoreperm <true/false> | switch.ignoreperm | 独立权限,当有这个权限时,才可以赋予指令开关忽略权限的能力 |

## 配置

Expand Down
4 changes: 2 additions & 2 deletions SwitchCommands/SwitchCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class SwitchCommands : TerrariaPlugin
public static SwitchPos switchPos = null!;

public override string Name => "SwitchCommands";
public override string Author => "Johuan Cjx适配 羽学优化";
public override string Author => "Johuan Cjx适配 羽学,肝帝熙恩优化";
public override string Description => "触发开关可以执行指令";
public override Version Version => new Version(1, 2, 1, 0);
public override Version Version => new Version(1, 2, 2);

public SwitchCommands(Main game) : base(game) { }

Expand Down

0 comments on commit 0d0a1e0

Please sign in to comment.