Skip to content
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

更新:a,b开头的所有卸载函数的补全 #354

Merged
merged 10 commits into from
Jul 29, 2024
6 changes: 4 additions & 2 deletions AutoStoreItems/AutoStoreItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public class AutoStoreItems : TerrariaPlugin
#endregion

#region 注册与释放
private GeneralHooks.ReloadEventD _reloadHandler;
public AutoStoreItems(Main game) : base(game) { }
public override void Initialize()
{
LoadConfig();
GeneralHooks.ReloadEvent += (_) => LoadConfig();
_reloadHandler = (_) => LoadConfig();
GeneralHooks.ReloadEvent += _reloadHandler;
GetDataHandlers.PlayerUpdate.Register(PlayerUpdate);
ServerApi.Hooks.GameUpdate.Register(this, OnGameUpdate);
}
Expand All @@ -31,7 +33,7 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
GeneralHooks.ReloadEvent -= (_) => LoadConfig();
GeneralHooks.ReloadEvent -= _reloadHandler;
GetDataHandlers.PlayerUpdate.UnRegister(PlayerUpdate);
ServerApi.Hooks.GameUpdate.Deregister(this, OnGameUpdate);
}
Expand Down
6 changes: 4 additions & 2 deletions BanNpc/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,23 @@ private void LoadConfig()
TShock.Log.ConsoleError("禁止怪物表读取错误:" + ex.ToString());
}
}
private GeneralHooks.ReloadEventD _reloadHandler;
public override void Initialize()
{
LoadConfig();
_reloadHandler = (_) => LoadConfig();
Commands.ChatCommands.Add(new Command("bannpc.use", BanCommand, "bm"));
ServerApi.Hooks.NpcSpawn.Register(this, OnSpawn);
ServerApi.Hooks.NpcTransform.Register(this, OnTransform);
GeneralHooks.ReloadEvent += (_) => LoadConfig();
GeneralHooks.ReloadEvent += _reloadHandler;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
ServerApi.Hooks.NpcSpawn.Deregister(this, OnSpawn);
ServerApi.Hooks.NpcTransform.Deregister(this, OnTransform);
GeneralHooks.ReloadEvent -= (_) => LoadConfig();
GeneralHooks.ReloadEvent -= _reloadHandler;

Commands.ChatCommands.RemoveAll(x => x.CommandDelegate == BanCommand);
}
Expand Down
29 changes: 17 additions & 12 deletions CaiRewardChest/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public CaiRewardChest(Main game)

public override string Name => "CaiRewardChest";

public override Version Version => new(2024, 7, 25, 1);
public override Version Version => new(2024, 7, 29, 1);


public override void Initialize()
Expand All @@ -34,6 +34,22 @@ public override void Initialize()
Commands.ChatCommands.Add(new Command("CaiRewardChest.Admin", EditChest, "编辑奖励箱"));
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
GetDataHandlers.ChestOpen.UnRegister(OnChestOpen);
Hooks.Chest.InvokeQuickStack -= ChestOnInvokeQuickStack;
Commands.ChatCommands.RemoveAll(x => x.CommandDelegate == InitChest ||
x.CommandDelegate == ClearChest ||
x.CommandDelegate == DeleteChest ||
x.CommandDelegate == AddChest ||
x.CommandDelegate == EditChest);
}

base.Dispose(disposing);
}

private bool ChestOnInvokeQuickStack(Hooks.Chest.orig_InvokeQuickStack orig, int playerid, Item item,
int chestindex)
{
Expand Down Expand Up @@ -153,15 +169,4 @@ private void InitChest(CommandArgs args)
args.Player.SendSuccessMessage($"[i:48]奖励箱初始化完成,共添加{count}个奖励箱~");
}


protected override void Dispose(bool disposing)
{
if (disposing)
{
GetDataHandlers.ChestOpen.UnRegister(OnChestOpen);
Hooks.Chest.InvokeQuickStack -= ChestOnInvokeQuickStack;
}

base.Dispose(disposing);
}
}
3 changes: 3 additions & 0 deletions CaiRewardChest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
## 更新日志

```
2024.7.29.1
补全卸载函数

1.0.0 添加插件
2024.7.24.1 禁止快速堆叠,修复快速堆叠刷物品
```
Expand Down
11 changes: 9 additions & 2 deletions Challenger/Challenger/Challenger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Challenger : TerrariaPlugin

public override string Name => "Challenger";

public override Version Version => new Version(1, 0, 1, 2);
public override Version Version => new Version(1, 0, 1, 3);

public Challenger(Main game)
: base(game)
Expand Down Expand Up @@ -76,10 +76,11 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
GeneralHooks.ReloadEvent -= new ReloadEventD(LoadConfig);
GeneralHooks.ReloadEvent -= new GeneralHooks.ReloadEventD(LoadConfig);
THEXN marked this conversation as resolved.
Show resolved Hide resolved
GetDataHandlers.TileEdit -= OnTileEdit!;
ServerApi.Hooks.GameUpdate.Deregister(this, OnGameUpdate);
GetDataHandlers.PlayerDamage.UnRegister(PlayerSufferDamage);
GetDataHandlers.NewProjectile.UnRegister(OnProjSpawn);
ServerApi.Hooks.ProjectileAIUpdate.Deregister(this, OnProjAIUpdate);
GetDataHandlers.ProjectileKill.UnRegister(OnProjKilled);
ServerApi.Hooks.NpcAIUpdate.Deregister(this, OnNPCAI);
Expand All @@ -88,6 +89,12 @@ protected override void Dispose(bool disposing)
GetDataHandlers.PlayerSlot.UnRegister(OnHoldItem);
ServerApi.Hooks.NetGreetPlayer.Deregister(this, OnGreetPlayer);
ServerApi.Hooks.ServerLeave.Deregister(this, OnServerLeave);

Commands.ChatCommands.RemoveAll(x =>
x.CommandDelegate == EnableModel ||
x.CommandDelegate == EnableTips ||
x.CommandDelegate == Function
);
}
base.Dispose(disposing);
}
Expand Down
3 changes: 3 additions & 0 deletions Challenger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@

```
更新日志
1.1.3
补全卸载函数

1.1.2 fix
尝试修复以下三个方法引起的空引用
OnGameUpdate/WormScarf/OnServerLeave
Expand Down
20 changes: 17 additions & 3 deletions ChattyBridge/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public override string Name => Assembly.GetExecutingAssembly().GetName().Name!;

public override Version Version => new(1, 0, 0, 1);
public override Version Version => new(1, 0, 0, 2);

private HttpClient Client { get; set; }

Expand All @@ -28,19 +28,33 @@

public const string RestAPI = "/chat";

public Plugin(Main game) : base(game)

Check warning on line 31 in ChattyBridge/Plugin.cs

View workflow job for this annotation

GitHub Actions / 构建插件

Non-nullable field '_reloadHandler' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
Client = new HttpClient();
}

private GeneralHooks.ReloadEventD _reloadHandler;
public override void Initialize()
{
LoadConfig();
_reloadHandler = (_) => LoadConfig();
TShock.RestApi.Register(RestAPI, Receive);
ServerApi.Hooks.ServerChat.Register(this, OnChat);
ServerApi.Hooks.NetGreetPlayer.Register(this, OnGreet);
ServerApi.Hooks.ServerLeave.Register(this, OnLeave);
GeneralHooks.ReloadEvent += (_) => LoadConfig();
GeneralHooks.ReloadEvent += _reloadHandler;
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
ServerApi.Hooks.ServerChat.Deregister(this, OnChat);
ServerApi.Hooks.NetGreetPlayer.Deregister(this, OnGreet);
ServerApi.Hooks.ServerLeave.Deregister(this, OnLeave);
GeneralHooks.ReloadEvent -= _reloadHandler;
}

base.Dispose(disposing);
}

public static void LoadConfig()
Expand Down
3 changes: 3 additions & 0 deletions ChattyBridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
## 更新日志

```
v1.0.0.2
补全卸载函数

v1.0.0.1
添加配置`是否转发指令`
```
Expand Down
6 changes: 4 additions & 2 deletions ConvertWorld/ConvertWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ public class Plugin : TerrariaPlugin
#endregion

#region 注册与释放
private GeneralHooks.ReloadEventD _reloadHandler;
public Plugin(Main game) : base(game) { }
public override void Initialize()
{
LoadConfig();
GeneralHooks.ReloadEvent += (_) => LoadConfig();
_reloadHandler = (_) => LoadConfig();
GeneralHooks.ReloadEvent += _reloadHandler;
ServerApi.Hooks.NpcKilled.Register(this, OnNPCKilled);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
GeneralHooks.ReloadEvent -= (_) => LoadConfig();
GeneralHooks.ReloadEvent -= _reloadHandler;
ServerApi.Hooks.NpcKilled.Deregister(this, OnNPCKilled);
}
base.Dispose(disposing);
Expand Down
37 changes: 28 additions & 9 deletions CreateSpawn/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Terraria;
using TerrariaApi.Server;
using TShockAPI;
using TShockAPI.Hooks;

namespace CreateSpawn;

Expand All @@ -13,7 +14,7 @@ public class Plugin : TerrariaPlugin

public override string Name => "CreateSpawn";

public override Version Version => new(1, 0, 0, 0);
public override Version Version => new(1, 0, 0, 1);


private readonly string SavePath = Path.Combine(TShock.SavePath, "Create.json");
Expand All @@ -25,19 +26,37 @@ public Plugin(Main game) : base(game)
{
}


public override void Initialize()
{
LoadConfig();
On.Terraria.WorldBuilding.GenerationProgress.End += (_, _) => create = true;
TShockAPI.Hooks.GeneralHooks.ReloadEvent += (_) => LoadConfig();
On.Terraria.WorldBuilding.GenerationProgress.End += GenerationProgress_End;
GeneralHooks.ReloadEvent += LoadConfig;
Commands.ChatCommands.Add(new Command("create.copy", copy, "cb"));
Commands.ChatCommands.Add(new Command("create.copy", CreateBuilding, "create"));
ServerApi.Hooks.GamePostInitialize.Register(this, (_) =>
ServerApi.Hooks.GamePostInitialize.Register(this, GamePost);
}

private void GamePost(EventArgs args)
{
if (create)
SpawnBuilding();
}


private void GenerationProgress_End(On.Terraria.WorldBuilding.GenerationProgress.orig_End orig, Terraria.WorldBuilding.GenerationProgress self) => create = true;


protected override void Dispose(bool disposing)
{
if (disposing)
{
if (create)
SpawnBuilding();
});
On.Terraria.WorldBuilding.GenerationProgress.End -= GenerationProgress_End;
GeneralHooks.ReloadEvent -= LoadConfig;
Commands.ChatCommands.RemoveAll(x => x.CommandDelegate == copy || x.CommandDelegate == CreateBuilding);
ServerApi.Hooks.GamePostInitialize.Deregister(this, GamePost);
}

base.Dispose(disposing);
}

private void CreateBuilding(CommandArgs args)
Expand Down Expand Up @@ -153,7 +172,7 @@ public void SpawnBuilding()
});
}

public void LoadConfig()
public void LoadConfig(ReloadEventArgs? args = null)
{
if (File.Exists(SavePath))
{
Expand Down
3 changes: 2 additions & 1 deletion CreateSpawn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
## 更新日志

```
暂无
v1.0.0.1
补全卸载函数
```

## 指令
Expand Down
3 changes: 2 additions & 1 deletion DTEntryBlock/DTEntryBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DTEntryBlock : TerrariaPlugin
public override string Author => "肝帝熙恩";
public override string Name => "阻止进入地牢或神庙";
public override string Description => "阻止玩家在击败骷髅王/世纪之花前进入地牢/神庙";
public override Version Version => new Version(1, 1, 3);
public override Version Version => new Version(1, 1, 4);
public static Configuration Config;
Color orangeColor = new Color(255, 165, 0);

Expand Down Expand Up @@ -41,6 +41,7 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
GeneralHooks.ReloadEvent -= ReloadConfig;
GetDataHandlers.PlayerUpdate.UnRegister(OnPlayerUpdatePhysics);
}
base.Dispose(disposing);
Expand Down
3 changes: 2 additions & 1 deletion DTEntryBlock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
## 更新日志

```
暂无
v1.1.4
补全卸载函数
```

## 指令
Expand Down
26 changes: 24 additions & 2 deletions DataSync/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ private static void EnsureTable()
}

private int _frameCount = 0;
private GeneralHooks.ReloadEventD _reloadHandler;
public override void Initialize()
{
Config.LoadConfig();
EnsureTable();

_reloadHandler = (_) => Reload();
ServerApi.Hooks.NpcKilled.Register(this, this.NpcKilled);
ServerApi.Hooks.GameUpdate.Register(this, args =>
{
Expand All @@ -108,13 +109,34 @@ public override void Initialize()
LoadProgress();
}
});
GeneralHooks.ReloadEvent += (_) => Reload();
GeneralHooks.ReloadEvent += _reloadHandler;
ServerApi.Hooks.GamePostInitialize.Register(this, args => LoadProgress());
Commands.ChatCommands.Add(new Command("DataSync", this.ClearProgress, "重置进度同步"));
TShock.RestApi.Register(new SecureRestCommand("/DataSync", ProgressRest, "DataSync"));
Commands.ChatCommands.Add(new Command("DataSync", ProgressCommand, "进度", "progress"));
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
ServerApi.Hooks.NpcKilled.Deregister(this, NpcKilled);
ServerApi.Hooks.GameUpdate.Deregister(this, args =>
{
_frameCount++;
if (_frameCount % 300 == 0)
{
LoadProgress();
}
});
GeneralHooks.ReloadEvent -= _reloadHandler;
ServerApi.Hooks.GamePostInitialize.Deregister(this, args => LoadProgress());
Commands.ChatCommands.RemoveAll(x => x.CommandDelegate == ClearProgress || x.CommandDelegate == ProgressCommand);
}

base.Dispose(disposing);
}

private static object ProgressRest(RestRequestArgs args)
{
return new RestObject {
Expand Down
3 changes: 2 additions & 1 deletion DataSync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
## 更新日志

```
暂无
20240729
咋没版本,补全卸载函数
```

## Rest APO
Expand Down
Loading
Loading