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!

 

  • Love 1
Stormo

Posted

Hello, I’m not sure whether this is related or not, but the server has recently started crashing quite often, specifically at the moment when a player crafts a large number of items at once.
In general, I am using console commands on items during crafting. Could this be the cause?

Before the server crash, the player saw the following messages in their console.
Can you help with this?

Could this be caused by the fact that I modified your plugin so that it stores cooldowns (CD) in the data file?image.png.359760955a64e58f52b6d08bf0ea8186.png

MTriper

Posted

On 3/31/2026 at 5:59 PM, Stormo said:

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!

 

Hi, thanks for finding a bug in the plugin. I am already working on the next update, where I will make corrections.

MTriper

Posted

6 hours ago, Stormo said:

Hello, I’m not sure whether this is related or not, but the server has recently started crashing quite often, specifically at the moment when a player crafts a large number of items at once.
In general, I am using console commands on items during crafting. Could this be the cause?

Before the server crash, the player saw the following messages in their console.
Can you help with this?

Could this be caused by the fact that I modified your plugin so that it stores cooldowns (CD) in the data file?image.png.359760955a64e58f52b6d08bf0ea8186.png

These errors have nothing to do with your plugin changes. They indicate that the graphical elements of the panel are not displayed correctly. This may be due to the player pressing the crafting button very quickly. And the panel just doesn't have time to display the changes. 
Could you find out exactly how the player crafts items? What is he doing? What is pressing?

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.4m
Total downloads
Customers
10.9k
Customers served
Files Sold
156.4k
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.