Inventory Backup Overhaul (Full NBT, merge, force close GUIs, file types)#4
Open
jwidess wants to merge 14 commits intoYuWan-030:masterfrom
Open
Inventory Backup Overhaul (Full NBT, merge, force close GUIs, file types)#4jwidess wants to merge 14 commits intoYuWan-030:masterfrom
jwidess wants to merge 14 commits intoYuWan-030:masterfrom
Conversation
Changed the removeBackup method to attempt to delete the backup file up to 5 times. If backup removal fails during inventory restore, the player is disconnected to prevent an old inventory backup from being restored in the future.
Updated all references in OfflineAuthHandler to use '.dat' instead of '.json' for inventory backup files as these binary not json.
Fixed overwriting existing config file on every start of the mod. Now changes to the config will actually persist.
trueuuid library from 1.0.2 to 1.0.5 in build.gradle and changed mod_version to 1.0.3 in gradle.properties.
Changed inventory backup and restore to use full CompoundTag NBT instead of just ItemStack. This adds compatibility with mods that store extra data in player NBT, such as Curios. Also added container closing on login tick.
Added SLF4J logger and an error log when the server fails to delete a player's inventory backup during login alongside kicking the user.
Added '/reload' command for reloading configuration while running, available to users with permission level 2, and added success message.
Captures items received while unauthenticated and merges them back into the player's inventory after a full NBT restore. Drops items that wont fit if the inventory is full. This should alleviate potential issues with mods or plugins that give users items on login or the like.
Added an 'inventoryOnly' config option to allow backing up only player inventory instead of full NBT data. Updated backup, restore, and file logic to for both default full NBT, and inventory only backups, using different file extensions (.dat for full, .inv for inventory only).
Added 'mergeOnRestore' option to the config to control whether items received while unauthenticated are merged with the restored inventory or discarded. Updated README's as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR primarily overhauls the inventory backup system to, by default, backup the full player NBT data, which natively includes all mod data like Curious, Backpacks, etc. instead of just the player inventory. Backing up only the player inventory is still supported via the config option
inventoryOnlyif this is preferred.Additionally, this also fixes a potential bug where if a user joins the server and a mod or plugin gives them a "Starter Kit" or welcome items, etc. they could lose those when they login, and their player data is overwritten. Now the mod merges any items in their inventory with the backup so they keep both. This does have some potential for abuse and especially duplication glitches if
inventoryOnlyis set to true, but I think it's still worthwhile. There is an added config optionmergeOnRestoreto control this behavior.Another minor change is the file format the inventory backups are saved as. They were
.jsonand now they are stored as.datfor NBT and.invfor inventory only backups.Added a force close to
onPlayerTickwhen unauthenticated to prevent the user from opening mod inventories prior to logging in. I wanted to useplayer.containerMenu != nullhowever, this prevents opening chat and the escape menu, which doesn't work. As is, some mod menus and options can still be opened, but this is better than before.And finally, I added a check, player kick, and console log if the inventory backup does not get deleted properly to avoid issues with restoring an old inventory backup on player relog.
NOTE: This also includes #3 as I was using it for testing.
AI Overview Below: