Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
TeamStash
One chest the whole server shares, opened at any workbench, so nobody hauls ore across the map.
By FlyingHose
| Date uploaded | 2 hours ago |
| Version | 1.0.0 |
| Download link | FlyingHose-TeamStash-1.0.0.zip |
| Downloads | 8 |
| Dependency string | FlyingHose-TeamStash-1.0.0 |
This mod requires the following mods to function
denikson-BepInExPack_Valheim
BepInEx pack for Valheim. Preconfigured with the correct entry point for mods and preferred defaults for the community.
Preferred version: 5.4.2360README
Team Stash
Part of FlyingHose's Modpack. Needs only BepInEx.
One chest the whole server shares, opened at any workbench. Nobody hauls ore across the map: put it in at one base, take it out at another.
How to open it
Stand at a workbench, look at it, and hold the game's alt place key while you press Use. On a keyboard that is left Shift by default; if you rebound it, use your key. On a gamepad with the default layout it is the alt place button plus Use, and with the alternative layout it is the alt keys button plus Use. The workbench's hover text shows the line for it with your keys.
A plain press of Use still opens crafting, as before. Holding Use does not open the stash.
The stash opens in the game's normal chest window next to your inventory. Drag, shift-click, take all, split stacks, and place stacks all work as they do on any chest. Walk away from the workbench and the window closes.
Two things do not work straight from the stash window: dropping an item on the ground and eating or equipping it. Drag it into your inventory first. This keeps every item either in the stash or in your hands, never in between.
It opens at any workbench, whether a ward covers it or not. The stash belongs to the whole server, not to the base the workbench stands in, so a ward does not guard it.
Turn on Stash.AnyStation to open it at any crafting station, not only the workbench.
One player at a time
Only one player can have the stash open. If someone else has it, you are told who. It frees itself when they close the window, when they disconnect, or when they have been away for 15 seconds without their game answering.
Size
The stash is 8 slots wide and 4 high by default. The server sets it with Stash.Width (1 to 8) and Stash.Height (1 to 20).
If the server makes it smaller than what is stored, nothing is deleted. The window grows extra rows to show everything, and the stash takes no new items until enough has been taken out for it to fit again. You can always take items out.
Ore and metals
The game does not let ore and metals go through portals. A stash that opens at any workbench would be a way around that rule, so by default it takes only items that can go through a portal. Ore and metals, and anything else the game marks "no teleport", are refused.
If you want the stash to take them anyway, the server owner sets Stash.AllowNonTeleportable to true in BepInEx/config/com.yesucs.yesubuildkit.teamstash.cfg. Everyone connected gets the new value. A world that already lets everything through portals allows it here too.
Turning the switch back off does not remove what is stored. It only stops new ore going in.
Where the stash is kept
The server keeps the stash for each world in a file:
BepInEx/config/YesuBuildKit.TeamStash/<world name>.stash
Back that file up and you have backed up the stash. The server saves the file for every change before it tells the player the change worked. If it cannot save, it refuses the change and nothing moves.
If the file is damaged, the server moves it aside to <world name>.stash.bad-<date> and starts with an empty stash. It never writes over a damaged file, so the items can still be recovered from the copy.
The file also holds, for each player, the number of their last withdrawal and the numbers of the deposits it stored, and the mailbox entries that are waiting to be confirmed. They are saved in the same write as the stash.
The server log records who put in or took out what, so an admin can restore items by hand if something goes wrong.
If you remove the mod
Your items stay in the .stash file. Nothing is deleted. Install the mod again and they are back.
Multiplayer
- Install on the server and on every client. The server refuses a client that does not have the mod or has a different version.
- The server's config wins. Values marked "Synced" in the config file are taken from the server while you are connected.
- The stash is kept by the server (or by the host in a hosted game). The host's game must be running for anyone to open it.
Settings
In BepInEx/config/com.yesucs.yesubuildkit.teamstash.cfg. "Server, enforced" means the server's value is used and the server checks it on every request. "Server, synced" means the server's value is sent to every player and each game applies it.
| Setting | Default | Range | Who decides |
|---|---|---|---|
General.Enabled |
true | Each machine. Needs a restart. A server with the mod on refuses clients that have it off. | |
General.DebugLogging |
false | Each machine | |
General.SaveCharacterAfterStashChange |
true | Each machine | |
Stash.Enabled |
true | Server, enforced | |
Stash.Width |
8 | 1 to 8 | Server, enforced |
Stash.Height |
4 | 1 to 20 | Server, enforced |
Stash.AllowNonTeleportable |
false | Server, enforced | |
Stash.UnclaimedReturnMinutes |
30 | 0 to 10080 (0 never) | Server, enforced |
Stash.AnyStation |
false | Server, synced |
About your items
An item is always somewhere you can find it, even when your connection drops. This is how.
Taking items out. The server moves the items from the stash into a mailbox entry for you, numbered 1, 2, 3 for you on this world, and saves the file. Your game puts the items in your inventory and writes that number into your character in the same step. The mailbox entry stays until your character has been saved to disk. The game saves your character on its own every 30 minutes and on exit, and this mod asks it to save a few seconds after you take something out (at most once every ten seconds; turn that off with SaveCharacterAfterStashChange in the local config if saves hitch on your machine).
Putting items in. The items leave your inventory and, in the same step, your character gets a record of them. The record is deleted only when the server says it stored them. If the server refuses, the items go back to you and the record is deleted.
When you connect. Before anything else, your game tells the server which withdrawal number your saved character holds and which deposit records it holds. The server then settles:
- Mailbox entries up to your number were received by your saved character. They are deleted.
- Mailbox entries above your number were not in your saved character, so their items go back into the stash. The server log names you and the items. The stash may end up over its size; it keeps everything and takes no new items until it fits.
- For each deposit record, the server says whether it stored that deposit. If it did, your record is deleted. If it did not, the items go back to you.
So a dropped connection, a crash of the server, or a restart cannot lose or duplicate an item. After you reconnect, every item that was on its way is in the stash or with you, exactly once.
If your inventory is full. The items that do not fit are kept on your character and handed to you as room appears. This holds for withdrawals, for deposits the server gives back, and for items you put in the window that come back to you. They are not dropped on the ground, except as a last resort if the character's record is damaged, because an item on the ground is saved with the world, and a game crash before your next character save would then leave a second copy.
The one exposure that remains. It is the one every chest in the base game has. If your own game crashes after the server stored a deposit and before your character was saved, the old save still has the items, so they exist in the stash and in your old save. The mod saves your character a few seconds after each deposit to keep that window short, but it cannot close it. The same applies to anything you do with withdrawn items before a save that the server keeps even though your character does not: put them in a chest or drop them and crash before your character is saved, and the mailbox will still return them to the stash. Nothing is ever lost; the worst case is a duplicate.
A player who does not come back. The server cannot know whether your character saved the items you took out, so it keeps your mailbox entries until you reconnect. It will not wait forever: if you stay disconnected longer than Stash.UnclaimedReturnMinutes (default 30, 0 to 10080, 0 means never), the server returns your entries to the stash on its own and logs your player id and the items. If your character did save those items after all, they now exist twice, once in the stash and once with you. When you reconnect and prove that, the server logs it as a duplicate the timer accepted. It cannot take anything back. Set the value to 0 to wait for the player no matter how long, and return entries by hand instead.
Console commands
Press F5 in the game to open the console.
teamstash mailbox(host or server only) lists the withdrawals nobody has confirmed yet, for each player.teamstash mailbox return <player id> confirm(host or server only) puts that player's mailbox items back into the stash now. Use it only if that player is never coming back: if their character did save the items, this duplicates them.teamstash pendingshows the deposit records on your character, the ones the server has not settled yet.teamstash pending reclaim confirmputs the items of those records back in your inventory. Use it only if that server is gone for good: if it did store the items, this duplicates them. It refuses while you are connected to a server that keeps the stash, or while a deposit or the check-in is waiting for an answer, because that server settles the records itself.
A dedicated server has no console. When it loads the stash file, its log names each unconfirmed withdrawal with its player and items. It logs again every time it returns items. A game that hosts can run the commands.
If you restore the stash file from a backup
The counters and mailbox entries are in the same file as the stash. A backup restores them together, and that is consistent. A backup that is older than your character's last save is not: your character may remember deposits or withdrawals the old file never saw. Items in flight at that moment can be duplicated or returned to the wrong place. Restore a backup only when nobody is connected.
CHANGELOG
1.0.0
- Items you put in the window that have to come back to you (the window closed under you, or the deposit could not be sent) now go to your inventory or, if it is full, wait on your character for room. They are no longer dropped on the ground.
teamstash pending reclaim confirmnow refuses while you are connected to a server that keeps the stash, or while a deposit or the check-in is still waiting for its answer. That server settles your records itself, and giving them back by hand could make a second copy.- The server log now names each unconfirmed withdrawal and its items when the stash file loads, not only the count.
Stash.Width,Stash.HeightandStash.UnclaimedReturnMinutesnow show their ranges in the config manager and in Althing.- An error in the per-frame update is logged once and then as a count every 30 seconds, not every frame.
- The workbench hover line is built once per key layout instead of every frame.
- Leaving a world now also resets the timers for owed items and the character save.
- The README now names the right key (the game's alt place key, left Shift by default), covers both gamepad layouts, and lists every setting.
0.2.0
- Settings can now be set per world, and the host or a server admin can change them in the game with the Althing mod.
- A dropped connection no longer loses an item in flight. An item taken out of the stash is held in a mailbox entry for that player until the player's saved character confirms it has the item, and goes back into the stash if it does not. A deposit the server never stored comes back to the player. Nothing in flight is lost or duplicated by a dropped connection or a server restart.
- Every connection now starts with a check-in. The player's game reports the withdrawal number its saved character holds and the deposit records it holds, and the server settles both before the stash can be opened.
- Items that do not fit in a full inventory are kept on the character and handed over as room appears, instead of dropped on the ground.
- The game is asked to save the character a few seconds after a deposit or withdrawal (
SaveCharacterAfterStashChange, on by default), so an item is unconfirmed for seconds and not for the 30 minute autosave. - New synced setting
Stash.UnclaimedReturnMinutes(default 30, 0 to 10080, 0 never): the server returns the mailbox entries of a player who stays disconnected that long. If the character did save the items, they exist twice, and the server log says so when the player returns. - New console commands:
teamstash mailbox,teamstash mailbox return <player id> confirm,teamstash pending,teamstash pending reclaim confirm. - The stash file is now version 2 and keeps each player's counters and the mailbox entries. A version 1 file still loads and is saved as version 2.
- The network protocol changed. Install this version on the server and on every client.
- The one exposure that remains is the one every chest in the game has: a game crash after the server stored a deposit and before the character was saved leaves the items in the stash and in the old character save.
0.1.0
- First release.
- A team stash that every player on the server shares. Hold Alt and press Use on a workbench to open it in the game's normal chest window.
- One player has it open at a time. Others are told who. It closes by itself if a player is away too long.
- The server keeps the stash for each world in a file and saves every change before it confirms it.
- Items the game keeps out of portals (ore and metals) stay out of the stash unless the server turns that on.
- Server-synced config and a version check on join.