Skip to content

Commit d7f526c

Browse files
committed
Fixed issue with kits and more
- Fixed issue with reload permissions - Fixed issue with cooldown timer not actually starting from the time it left off when you restart the server - Fixed ``InvalidOperationException`` when loading cooldown's for kits
1 parent e6b180b commit d7f526c

File tree

6 files changed

+41
-38
lines changed

6 files changed

+41
-38
lines changed

source/BP-Essentials/Chat/Commands/Admin/DebugCommands.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,20 @@ public static void Run(SvPlayer player, string message)
6262
if (arg2 == "item")
6363
{
6464
// Jesus o.O
65-
if (v.GetType() == typeof(ShPlaceable) || v.GetType() == typeof(ShPlaceable) || v.GetType() == typeof(ShGun) || v.GetType() == typeof(ShWeapon) || v.GetType() == typeof(ShFurniture) || v.GetType() == typeof(ShWearable) || v.GetType() == typeof(ShConsumable) || v.GetType() == typeof(ShDrugMaterial) || v.GetType() == typeof(ShExtinguisher) || v.GetType() == typeof(ShHealer) || v.GetType() == typeof(ShRestraint) || v.GetType() == typeof(ShSeed) || v.GetType() == typeof(ShProjectile))
65+
if (v.GetType() == typeof(ShPlaceable)
66+
|| v.GetType() == typeof(ShPlaceable)
67+
|| v.GetType() == typeof(ShGun)
68+
|| v.GetType() == typeof(ShWeapon)
69+
|| v.GetType() == typeof(ShFurniture)
70+
|| v.GetType() == typeof(ShWearable)
71+
|| v.GetType() == typeof(ShConsumable)
72+
|| v.GetType() == typeof(ShDrugMaterial)
73+
|| v.GetType() == typeof(ShExtinguisher)
74+
|| v.GetType() == typeof(ShHealer)
75+
|| v.GetType() == typeof(ShRestraint)
76+
|| v.GetType() == typeof(ShSeed)
77+
|| v.GetType() == typeof(ShProjectile)
78+
|| v.GetType() == typeof(ShDetonator))
6679
{
6780
sb.Append($"{{\"name\": \"{v.name}\",\"id\": {currIndex},\"gameid\": {v.index}}},\n");
6881
++currIndex;

source/BP-Essentials/Chat/Commands/Admin/Reload.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ class Reload : EssentialsChatPlugin
1212
{
1313
public static void Run(SvPlayer player)
1414
{
15-
if (player.player.admin)
16-
BP_Essentials.Reload.Run(false, player);
17-
else
18-
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
15+
BP_Essentials.Reload.Run(false, player);
1916
}
2017
}
2118
}

source/BP-Essentials/EssentialsVariables.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace BP_Essentials
77
{
88
public class EssentialsVariablesPlugin : EssentialsCorePlugin
99
{
10-
public const string Version = "2.5.4";
10+
public const string Version = "2.5.6";
1111
public static bool isPreRelease;
1212

1313
// Generic Constants

source/BP-Essentials/Methods/FileHandler/Kits.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public static void LoadAllKits(bool firstLoad = false)
2626
continue;
2727
}
2828
listKits.Add(obj);
29-
if (firstLoad)
30-
foreach (var player in obj.CurrentlyInCooldown)
31-
SvMan.StartCoroutine(KitCooldown(player.Key, obj));
29+
if (firstLoad && obj.CurrentlyInCooldown != null)
30+
foreach (var player in obj.CurrentlyInCooldown.ToList())
31+
SvMan.StartCoroutine(KitCooldown(player.Key, obj, player.Value));
3232
if (DebugLevel >= 1)
3333
Debug.Log($"{SetTimeStamp.Run()}[INFO] Loaded kit: {obj.Name}");
3434
}
@@ -69,13 +69,13 @@ public static void StartKitTimer()
6969
ErrorLogging.Run(ex);
7070
}
7171
}
72-
public static IEnumerator KitCooldown(string username, Kits_Json.Kits_RootObj kit)
72+
public static IEnumerator KitCooldown(string username, Kits_Json.Kits_RootObj kit, int PassedTime = 0)
7373
{
7474
if (!kit.CurrentlyInCooldown.ContainsKey(username))
7575
kit.CurrentlyInCooldown.Add(username, kit.Delay);
7676
var path = Path.Combine(KitDirectory, $"{kit.Name}.json");
7777
File.WriteAllText(path, JsonConvert.SerializeObject(kit, Formatting.Indented));
78-
var passedTime = 0;
78+
var passedTime = PassedTime;
7979
while (passedTime <= kit.Delay)
8080
{
8181
++passedTime;

source/BP-Essentials/Methods/GameMethods/SendToJail.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static bool Run(ShPlayer shPlayer, float time)
2020
shPlayer.StartCoroutine(shPlayer.svPlayer.JailTimer(time));
2121
shPlayer.svPlayer.SvClearCrimes();
2222
shPlayer.RemoveItemsJail();
23-
shPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.Timer, time);
23+
shPlayer.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ShowTimer, time);
2424
return true;
2525
}
2626
}

source/BP-Essentials/Methods/misc/Reload.cs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,25 @@ public static void Run(bool silentExecution, SvPlayer player = null, bool IsFirs
1717
{
1818
if (!silentExecution)
1919
{
20-
if (AdminsListPlayers.Contains(player.playerData.username))
21-
{
22-
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "[WAIT] Reloading all files..");
23-
CheckFiles.Run();
24-
ReadFile.Run(SettingsFile);
25-
ReadCustomCommands.Run();
26-
ReadGroups.Run();
27-
Kits.LoadAllKits();
28-
ReadStream.Run(LanguageBlockFile, LanguageBlockWords);
29-
ReadStream.Run(ChatBlockFile, ChatBlockWords);
30-
ReadStream.Run(AdminListFile, AdminsListPlayers);
31-
LanguageBlockWords = LanguageBlockWords.ConvertAll(d => d.ToLower());
32-
ChatBlockWords = ChatBlockWords.ConvertAll(d => d.ToLower());
33-
ReadFile.Run(IdListItemsFile);
34-
ReadFile.Run(IdListVehicleFile);
35-
ReadFile.Run(AnnouncementsFile);
36-
ReadFile.Run(GodListFile);
37-
ReadFile.Run(MuteListFile);
38-
ReadFile.Run(AfkListFile);
39-
ReadFile.Run(RulesFile);
40-
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "[OK] Critical .txt files reloaded");
41-
}
42-
else
43-
{
44-
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
45-
}
20+
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "[WAIT] Reloading all files..");
21+
CheckFiles.Run();
22+
ReadFile.Run(SettingsFile);
23+
ReadCustomCommands.Run();
24+
ReadGroups.Run();
25+
Kits.LoadAllKits();
26+
ReadStream.Run(LanguageBlockFile, LanguageBlockWords);
27+
ReadStream.Run(ChatBlockFile, ChatBlockWords);
28+
ReadStream.Run(AdminListFile, AdminsListPlayers);
29+
LanguageBlockWords = LanguageBlockWords.ConvertAll(d => d.ToLower());
30+
ChatBlockWords = ChatBlockWords.ConvertAll(d => d.ToLower());
31+
ReadFile.Run(IdListItemsFile);
32+
ReadFile.Run(IdListVehicleFile);
33+
ReadFile.Run(AnnouncementsFile);
34+
ReadFile.Run(GodListFile);
35+
ReadFile.Run(MuteListFile);
36+
ReadFile.Run(AfkListFile);
37+
ReadFile.Run(RulesFile);
38+
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, "[OK] Critical .txt files reloaded");
4639
}
4740
else
4841
{

0 commit comments

Comments
 (0)