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

update(servertools): Add summon Limit #555

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading