Skip to content

Commit

Permalink
Merge pull request #555 from UnrealMultiple/summon-limit
Browse files Browse the repository at this point in the history
update(servertools): Add summon Limit
  • Loading branch information
LaoSparrow authored Nov 7, 2024
2 parents ac77d10 + c33e87b commit a51418a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/ServerTools/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class Config
[JsonProperty("限制哨兵数量")]
public int sentryLimit = 10;

[JsonProperty("限制召唤物数量")]
public int summonLimit = 10;

[JsonProperty("仅允许软核进入")]
public bool OnlySoftCoresAreAllowed = false;

Expand Down
15 changes: 13 additions & 2 deletions src/ServerTools/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class Plugin : TerrariaPlugin

public override string Name => "ServerTools";// 插件名字

public override Version Version => new(1, 1, 7, 4);// 插件版本
public override Version Version => new(1, 1, 7, 5);// 插件版本

private static Config Config = new();

Expand Down Expand Up @@ -387,10 +387,21 @@ private void NewProj(object? sender, GetDataHandlers.NewProjectileEventArgs e)
{
if (Main.projectile[e.Index].sentry)
{
if (Main.projectile.Where(x => x.owner == e.Owner).Count() > Config.sentryLimit)
if (Main.projectile.Where(x => x != null && x.owner == e.Owner && x.sentry && x.active).Count() > Config.sentryLimit)
{
Main.projectile[e.Index].active = false;
e.Handled = true;
TSPlayer.All.SendData(PacketTypes.ProjectileNew, "", e.Index);
return;
}
}
if (Main.projectile[e.Index].minion)
{
if (Main.projectile.Where(x => x != null && x.owner == e.Owner && x.minion && x.active).Count() > Config.summonLimit)
{
Main.projectile[e.Index].active = false;
e.Handled = true;
TSPlayer.All.SendData(PacketTypes.ProjectileNew, "", e.Index);
return;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/ServerTools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
## 更新日志

```
V1.1.7.5
添加配置限制召唤物数量
v1.1.7.4
完善卸载函数
Expand Down

0 comments on commit a51418a

Please sign in to comment.