From 058a1e9dbe8affe2c2f6e94a4ac0ffb89eb4a38d Mon Sep 17 00:00:00 2001 From: xien <2383759126@qq.com> Date: Sat, 3 Aug 2024 22:05:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9AjourneyUnlock=20?= =?UTF-8?q?=E8=A7=A3=E9=94=81=E6=97=85=E9=80=94=E7=89=A9=E5=93=81=E7=9A=84?= =?UTF-8?q?=E5=8D=B8=E8=BD=BD=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- journeyUnlock/README.md | 3 ++- journeyUnlock/journeyUnlock.cs | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/journeyUnlock/README.md b/journeyUnlock/README.md index e79bac3e1..2e946b93c 100644 --- a/journeyUnlock/README.md +++ b/journeyUnlock/README.md @@ -7,7 +7,8 @@ ## 更新日志 ``` -暂无 +v1.0.1.1 +完善卸载函数 ``` ## 指令 diff --git a/journeyUnlock/journeyUnlock.cs b/journeyUnlock/journeyUnlock.cs index d1d89b72e..f7bbf68a2 100644 --- a/journeyUnlock/journeyUnlock.cs +++ b/journeyUnlock/journeyUnlock.cs @@ -4,6 +4,7 @@ using Terraria.Net; using TerrariaApi.Server; using TShockAPI; +using TShockAPI.Hooks; namespace journeyUnlock { @@ -16,7 +17,7 @@ public class journeyUnlock : TerrariaPlugin public override string Name => "journeyUnlock"; - public override Version Version => new(1, 0, 1, 0); + public override Version Version => new(1, 0, 1, 1); public journeyUnlock(Main game) : base(game) { @@ -24,16 +25,19 @@ public journeyUnlock(Main game) : base(game) public override void Initialize() { - Commands.ChatCommands.Add(new Command( - permissions: new List { "journeyunlock.unlock" }, - cmd: this.unlockCommand, - "journeyunlock", "junlock", "i解锁") + Commands.ChatCommands.Add(new Command("journeyunlock.unlock" ,unlockCommand,"journeyunlock", "junlock", "i解锁") { AllowServer = false }); - Commands.ChatCommands.Add(new Command( - permissions: new List { "journeyunlock.unlockfor" }, - cmd: this.unlockForCommand, - "unlockfor", "unlockf", "g解锁玩家")); + Commands.ChatCommands.Add(new Command("journeyunlock.unlockfor",unlockForCommand,"unlockfor", "unlockf", "g解锁玩家")); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + Commands.ChatCommands.RemoveAll(x => x.CommandDelegate == unlockCommand || x.CommandDelegate == unlockForCommand); + } + base.Dispose(disposing); } private void unlock(Player tplayer, TSPlayer sender, string parameter, bool isSelf)