Skip to content

Commit 0bfd6be

Browse files
committed
NeedSystem v1.1.3
- Added a configuration option that allows the plugin to obtain the maximum player capacity automatically.
1 parent 95e872d commit 0bfd6be

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

NeedSystem.cs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ public class BaseConfigs : BasePluginConfig
1717
[JsonPropertyName("IPandPORT")]
1818
public string IPandPORT { get; set; } = "45.235.99.18:27025";
1919

20+
[JsonPropertyName("GetIPandPORTautomatic")]
21+
public bool GetIPandPORTautomatic { get; set; } = true;
22+
23+
[JsonPropertyName("UseHostname")]
24+
public bool UseHostname { get; set; } = true;
25+
2026
[JsonPropertyName("CustomDomain")]
2127
public string CustomDomain { get; set; } = "https://crisisgamer.com/redirect/connect.php";
2228

@@ -29,6 +35,9 @@ public class BaseConfigs : BasePluginConfig
2935
[JsonPropertyName("MaxServerPlayers")]
3036
public int MaxServerPlayers { get; set; } = 12;
3137

38+
[JsonPropertyName("GetMaxServerPlayers")]
39+
public bool GetMaxServerPlayers { get; set; } = true;
40+
3241
[JsonPropertyName("MinPlayers")]
3342
public int MinPlayers { get; set; } = 10;
3443

@@ -71,12 +80,6 @@ public class BaseConfigs : BasePluginConfig
7180
[JsonPropertyName("EmbedThumbnailImage")]
7281
public string EmbedThumbnailImage { get; set; } = "https://avatars.githubusercontent.com/u/61034981?v=4";
7382

74-
[JsonPropertyName("UseHostname")]
75-
public bool UseHostname { get; set; } = true;
76-
77-
[JsonPropertyName("GetIPandPORTautomatic")]
78-
public bool GetIPandPORTautomatic { get; set; } = true;
79-
8083
}
8184

8285
public class NeedSystemBase : BasePlugin, IPluginConfig<BaseConfigs>
@@ -86,7 +89,7 @@ public class NeedSystemBase : BasePlugin, IPluginConfig<BaseConfigs>
8689
private Translator _translator;
8790

8891
public override string ModuleName => "NeedSystem";
89-
public override string ModuleVersion => "1.1.2";
92+
public override string ModuleVersion => "1.1.3";
9093
public override string ModuleAuthor => "luca.uy";
9194
public override string ModuleDescription => "Allows players to send a message to discord requesting players.";
9295

@@ -366,16 +369,6 @@ private async Task SendEmbedToDiscord(object embed)
366369
}
367370
}
368371

369-
private string GetHostname()
370-
{
371-
string hostname = ConVar.Find("hostname")?.StringValue ?? _translator["NeedInServerMessage"];
372-
if (string.IsNullOrEmpty(hostname) || hostname.Length <= 3)
373-
{
374-
hostname = _translator["NeedInServerMessage"];
375-
}
376-
return hostname;
377-
}
378-
379372
private string GetWebhook()
380373
{
381374
return Config.WebhookUrl;
@@ -409,10 +402,19 @@ private string MentionRoleID()
409402
{
410403
return Config.MentionRoleID;
411404
}
412-
private int MaxServerPlayers()
405+
406+
private string MaxServerPlayers()
413407
{
414-
return Config.MaxServerPlayers;
408+
if (Config.GetMaxServerPlayers)
409+
{
410+
return Server.MaxPlayers.ToString();
411+
}
412+
else
413+
{
414+
return Config.MaxServerPlayers.ToString();
415+
}
415416
}
417+
416418
private int MinPlayers()
417419
{
418420
return Config.MinPlayers;

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ https://github.com/user-attachments/assets/fca8fed1-c07c-4546-9972-dc1cd49ab769
1919
| :------- | :------- | :------- |
2020
| `WebhookUrl` | You must create it in the channel where you will send the notices. |**YES** |
2121
| `IPandPORT` | Replace with the IP address of your server. |**YES** |
22+
| `GetIPandPORTautomatic` | When you activate this option the plugin will try to get the IP:PORT of your server automatically, in case it is not possible use the IPandPORT configuration. | **YES** |
23+
| `UseHostname` | If you set this configuration to true, the “EmbedTitle” of the translation will be replaced by the hostname you have configured in your server.cfg file. | **YES** |
2224
| `CustomDomain` | You can replace it with your domain if you want, the connect.php file is available in the main branch |**YES** |
2325
| `MentionRoleID` | You must have the discord developer mode activated, right click on the role and copy its ID. |**NO** |
2426
| `MentionMessage` | You can use this option to deactivate the mention message completely, with this deactivated only the embed will be sent. |**YES** |
2527
| `MaxServerPlayers` | Maximum number of slots your server has. |**YES** |
28+
| `GetMaxServerPlayers` | When you activate this option the plugin will try to get the maximum number of players on the server automatically, in case it is not possible use the MaxServerPlayers configuration. |**YES** |
2629
| `MinPlayers` | In this case if there are ten or more players connected the command cannot be used. | **YES** |
2730
| `CommandCooldownSeconds` | Command cooldown time in seconds. | **YES** |
2831
| `Command` | You can change the command to be used by the players or add extra commands. | **YES** |
@@ -37,18 +40,19 @@ https://github.com/user-attachments/assets/fca8fed1-c07c-4546-9972-dc1cd49ab769
3740
| `EmbedAuthorImage` | It will be the image (logo) that will appear as the author of the embed. | **YES** |
3841
| `EmbedThumbnail` | You can use this option to disable or enable the embed thumbnail. | **YES** |
3942
| `EmbedThumbnailImage` | It will be the image (logo) that will appear as the author of the embed. | **YES** |
40-
| `UseHostname` | If you set this configuration to true, the “EmbedTitle” of the translation will be replaced by the hostname you have configured in your server.cfg file. | **YES** |
41-
| `GetIPandPORTautomatic` | When you activate this option the plugin will try to get the IP:PORT of your server automatically, in case it is not possible use the IPandPORT configuration. | **YES** |
4243

4344
## Configuration example
4445
```
4546
{
4647
"WebhookUrl": "https://discord.com/api/webhooks/xxxxx/xxxxxxxxx,
4748
"IPandPORT": "45.235.99.18:27025",
49+
"GetIPandPORTautomatic": true,
50+
"UseHostname": true,
4851
"CustomDomain": "https://crisisgamer.com/redirect/connect.php",
4952
"MentionRoleID": "1111767358881681519",
5053
"MentionMessage": true,
5154
"MaxServerPlayers": 12,
55+
"GetMaxServerPlayers": true,
5256
"MinPlayers": 10,
5357
"CommandCooldownSeconds": 120,
5458
"Command": [ "css_need", ".need" ],
@@ -63,8 +67,6 @@ https://github.com/user-attachments/assets/fca8fed1-c07c-4546-9972-dc1cd49ab769
6367
"EmbedAuthorImage": "https://avatars.githubusercontent.com/u/61034981?v=4",
6468
"EmbedThumbnail": true,
6569
"EmbedThumbnailImage": "https://avatars.githubusercontent.com/u/61034981?v=4",
66-
"UseHostname": true,
67-
"GetIPandPORTautomatic": true,
6870
}
6971
```
7072

0 commit comments

Comments
 (0)