Jump to content

The cooldown (CD) does not work after a restart.

Pending 1.3.4

Stormo
Stormo

Posted (edited)

We have discovered an issue with the cooldown: if the plugin is not restarted, everything works correctly and it shows the countdown until the next time the item can be crafted. However, as soon as the plugin is restarted, the cooldown disappears.
image.png.c941d1eba8c15e5cd975c7b5debdf6ad.pngimage.png.7ee632e0bee144513dac263a75509b2e.png

Edited by Stormo
MTriper

Posted

Hi, I can't reproduce this issue. I still have a timer after restarting the plugin.

Stormo

Posted

14 minutes ago, MTriper said:

Hi, I can't reproduce this issue. I still have a timer after restarting the plugin.

Got it. Could you tell me which plugin this might be related to or what could be causing this in general? Maybe I misconfigured something in the config — it just happens on all items in the panel.

CraftingPanel.json

MTriper

Posted

Does the plugin load on the server at all?

MTriper

Posted

I'm getting an error with your config.

 

Stormo

Posted

2 minutes ago, MTriper said:

I'm getting an error with your config.

 

Everything runs without errors.
image.png.a7f58eb44b5b5126bbb08b0811bfed6e.png

Stormo

Posted

Yeah, I have an error too, but the plugin works. I just have 3 servers, so I got a bit mixed up with the console.

image.png.206b3068d91fd895a97a7aec68fdde47.png

MTriper

Posted

What is this "plumbus_nefrut" item?

Stormo

Posted

I deleted all plugins completely, removed the config, and downloaded a default one — but nothing changed, the issue still persists.

I’m attaching a video. Also, something very strange: nothing gets written to the CraftingPanel.json file.

To emphasize — I removed all plugins and left only CraftingPanel and ImageLibrary, and still nothing changes.

This is being done on a test server. I restarted it several times to clear the cache and so on, but the problem remains exactly the same.
 

Stormo

Posted

I found an issue in CraftingPanel v1.3.4 related to cooldown persistence.

Cooldowns were not being saved in the data file, which caused them to reset after plugin reload or server restart. After investigating the code, I found that cooldowns are actually added to the data dictionary correctly, but then player data gets removed in OnPlayerDisconnected if the player has no favorite items.

Specifically, this block removes all player data:

if (data.ContainsKey(player.UserIDString) && data[player.UserIDString].favoriteItems.Count != 0) data[player.UserIDString].lastSeenTime = DateTime.Now.ToString("d", CultureInfo.InvariantCulture); else data.Remove(player.UserIDString);

This ignores cooldownItems, so if a player has cooldowns but no favorites, their data is deleted, and cooldowns are lost.

I fixed it by updating the condition to also keep players who have cooldowns:

if (data.ContainsKey(player.UserIDString)) { UserData userData = data[player.UserIDString]; if (userData.favoriteItems.Count != 0 || userData.cooldownItems.Count != 0 || userData.dlcUnlocked) { userData.lastSeenTime = DateTime.Now.ToString("d", CultureInfo.InvariantCulture); } else { data.Remove(player.UserIDString); } }

Additionally, I forced saving after adding cooldowns:

ins.data[player.UserIDString].cooldownItems[key] = dateEnd; ins.SaveData();

After these changes, cooldowns are correctly stored in the data file and persist after reload/restart.

It looks like the issue is purely logical and not config-related.

This fix was identified with the help of ChatGPT.

Thanks!

 

About Us

Codefling is the largest marketplace for plugins, maps, tools, and more, making it easy for customers to discover new content and for creators to monetize their work.

Downloads
2.3m
Total downloads
Customers
10.7k
Customers served
Files Sold
155k
Marketplace sales
Payments
3.3m
Processed total
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.