Hi, I noticed that the default item despawn time is incorrect, this can be easily seen by the despawn time of keycard_red (5 minutes instead of 60) and smallbackpack (5 minutes instead of 20).
private void OnServerInitialized()
{
Subscribe(nameof(OnEntitySpawned));
int origDespawnTimes = config.ItemDespawnTimes.Count;
foreach (ItemDefinition item in ItemManager.itemList)
{
if (!config.ItemDespawnTimes.ContainsKey(item.shortname))
{
Rarity usedRarity = (item.despawnRarity != Rarity.None) ? item.despawnRarity : item.rarity;
int despawnMultiplier = Mathf.Clamp(((int)usedRarity - 1) * 4, 1, 100);
int despawnTimeSeconds = item.quickDespawn ?
(int)ConVar.Server.itemdespawn_quick :
(int)(despawnMultiplier * ConVar.Server.itemdespawn);
float despawnTimeMinutes = (float)Math.Round(despawnTimeSeconds / 60f, 2);
config.ItemDespawnTimes.Add(item.shortname, despawnTimeMinutes);
}
}
int newDespawnTimes = config.ItemDespawnTimes.Count;
if (!origDespawnTimes.Equals(newDespawnTimes))
{
Log($"Saved {newDespawnTimes - origDespawnTimes} new items to configuration");
SaveConfig();
}
foreach (BaseNetworkable networkable in BaseNetworkable.serverEntities)
{
SetDespawnTime(networkable);
}
if (config.GlobalDespawnTime > -1)
{
LogWarning($"Global respawn time is currently set to {config.GlobalDespawnTime}; individal item despawn times overridden");
}
}