COWMODSКаталог модов

InventoryBackup

A Minecraft Spigot plugin that automatically saves player inventories on death and provides comprehensive restore functionality.

Автор: zfzfg4810обновлён 1 окт. 2026 г.
СнаряжениеХранение

Описание

InventoryBackup Plugin Description

Overview

InventoryBackup is a powerful, robust, and secure Minecraft Spigot/Paper plugin designed to automatically archive player inventories upon death and provide comprehensive, flexible restore functionality. Built with server administrators and developers in mind, it offers a complete, production-ready solution featuring a rich Developer API, offline player restores, UUID-based storage, multi-language support (English and German), and dupe-proof inventory previews.

  • Modrinth Project: https://modrinth.com/project/rpKY25cW
  • Developer API Artifact: com.zfzfg:InventoryBackup-API:0.1.0
  • Supported Platforms: Minecraft 1.20+ (Spigot / Paper / Purpur) & Java 17+

Why Use InventoryBackup?

🛡️ Protect Your Players' Progress

Players invest countless hours gathering gear, rare enchantments, and building resources. Unexpected deaths, void falls, server glitches, or accidental despawns can wipe out hours of hard work. InventoryBackup ensures that no player permanently loses their inventory.

⚡ Offline Restores Made Effortless

Targeting an offline player with a restore or missing items command queues it automatically into pending-restores.yml. The items are safely restored the very next time the player joins the server — surviving server restarts and network disconnects without any manual follow-up required.

🌐 Native Multi-Language Support (i18n)

All player and console messages are fully localized in English (en) and German (de). Switch languages on the fly at runtime with /inv lang de or /inv lang en without restarting the server. Custom translations use dedicated message files with automatic fallback to English for any missing keys.

🧩 First-Class Developer API & Events

Integrate directly into quests, minigames, arenas, or custom death systems. The clean API module provides asynchronous futures that complete directly on the main thread, accompanied by five custom Bukkit events (including cancellable pre-events) to customize or veto any backup and restore operation.

🔒 Enterprise-Grade Security & Performance

Protected against path traversal attacks, race conditions, memory leaks, and GUI item-duplication exploits. Backup timestamps are parsed directly from filenames to optimize cleanup loops, and file I/O operations run asynchronously to guarantee zero server tick lag.


Key Features

1. Automatic Death Backups (Two-Stage Caching)

The plugin captures player state through an intelligent two-stage mechanism:

  1. Damage Detection: When a player takes damage that brings them to 4 hearts or less, their current inventory is cached synchronously on the main thread.
  2. Death Event: When the player dies, the cached inventory snapshot is saved to disk asynchronously.

This guarantees accurate inventory capture even during instantaneous, one-shot deaths (such as high falls, void damage, or instant-kill effects).

2. Offline Player Restores & Join Queue

  • Restores targeted at offline players are automatically queued in pending-restores.yml.
  • When the player joins, the queued restore is applied with a 1-tick delay to prevent other login listeners from overriding the restored inventory.
  • Inspect queued restores with /inv <player> pending and cancel them with /inv <player> cancelpending.
  • Configurable expiry (pending-restore-expiry-days, default 30 days) automatically purges stale pending entries.

3. Flexible Restore & Inspection Modes

  • Full Restore: Completely replaces the player's current inventory, armor, offhand, level, and experience with the archived backup (/inv <player> restore <filename>).
  • Missing Items Only: Compares the backup against what the player currently holds and gives back only the items they are lacking without wiping their current inventory (/inv <player> givemissing <filename>).
  • Protected GUI Preview: Inspect the exact contents of any backup in an interactive GUI window (/inv <player> show <filename>). Viewers cannot drag, click, or duplicate items out of the preview GUI.

4. UUID-Based Storage & Instant Name Index

  • Backups are stored in plugins/InventoryBackup/inventories/<UUID>/ to ensure player history is never lost or orphaned when a player changes their Minecraft name.
  • File names follow the format <yyyy-MM-dd_HH-mm-ss>_<type>.yml (e.g. 2026-08-11_15-30-45_death.yml).
  • Fast, local name-to-UUID lookups via names.yml eliminate blocking web requests to Mojang APIs during commands and tab completion.
  • Seamless automatic migration from legacy folder structures on server startup.

5. Multi-Language & Translation Bundles

  • Complete translations for all player messages, GUI titles, list entries, and console logs.
  • Message bundles: messages_en.yml (English fallback master) and messages_de.yml (German).
  • Switch languages on the fly: /inv lang de or /inv lang en.
  • Reload configuration and bundles at any time: /inv reload.
  • Color codes (&) and dynamic placeholders ({player}, {file}, {count}, {level}, {type}, etc.) supported throughout.

6. Developer API & Custom Events

  • Standalone API artifact com.zfzfg:InventoryBackup-API for third-party plugin integration via InventoryBackupProvider.get().
  • Non-blocking CompletableFutures completing on the Bukkit main thread.
  • Custom Bukkit events included in the plugin JAR:
    • BackupCreateEvent (Cancellable; modify type or attach custom metadata)
    • BackupCreatedEvent (Fired after backup is saved)
    • InventoryRestoreEvent (Cancellable; inspect or filter restored items)
    • InventoryRestoredEvent (Fired after restore is applied)
    • BackupDeletedEvent (Fired with reason API, COMMAND, or EXPIRED)
  • Free-form backup types (e.g., quest, pvp, admin, checkpoint) and arbitrary string key/value metadata.

7. Automated Maintenance & Cleanup

  • Automatic deletion of backups older than a configurable number of days (auto-delete-days: 30).
  • Background cleanup task runs at configurable intervals (cleanup-interval-hours: 24).
  • Fast timestamp extraction directly from filenames without heavy YAML parsing.

8. Modrinth Update Checker

  • Background update check on server startup via Modrinth v2 API (rpKY25cW).
  • Cached update notifications for administrators upon joining (zero login network lag).
  • Manual on-demand check via /inv version with live feedback and direct download links.

Command Reference

The base command is /inv, with aliases /inventory and /invbackup.

CommandDescriptionPermission
/inv backup allCreate a manual backup for all online playersinventorybackup.backup
/inv backup <player>Create a manual backup for a specific online playerinventorybackup.backup
/inv <player> restore <filename>Restore inventory (applies immediately or queues if offline)inventorybackup.restore
/inv <player> show <filename>Open read-only GUI preview of a saved backupinventorybackup.show
/inv <player> givemissing <filename>Give only missing items to an online playerinventorybackup.givemissing
/inv <player> listList all backups and their types for a playerinventorybackup.show
/inv <player> delete <filename>Delete a specific backup fileinventorybackup.restore
/inv <player> delete allDelete all backups for a specific playerinventorybackup.restore
/inv <player> pendingView the restore queued for an offline playerinventorybackup.pending
/inv <player> cancelpendingCancel a queued offline restoreinventorybackup.pending
/inv versionCheck Modrinth for updates and display version infoinventorybackup.use
/inv langDisplay the currently active languageinventorybackup.lang
/inv lang <en|de>Switch language and reload message bundles instantlyinventorybackup.lang
/inv reloadReload config.yml and active message bundleinventorybackup.reload

ℹ️ Tab Completion: Full tab completion is supported for subcommands, actions, online and known offline players, language codes, and existing backup filenames.


Permissions

All permissions default to server operators (op):

PermissionDescriptionDefault
inventorybackup.useAccess to base /inv command and /inv versionOP
inventorybackup.restoreRestore backups and delete individual or all backupsOP
inventorybackup.showOpen GUI preview (show) and view backup list (list)OP
inventorybackup.givemissingHand over only missing items to a playerOP
inventorybackup.backupCreate manual backups for single players or all online playersOP
inventorybackup.pendingView and cancel queued restores for offline playersOP
inventorybackup.notifyReceive chat notifications when a backup is savedOP
inventorybackup.update.notifyReceive update notification messages upon joiningOP
inventorybackup.langView and switch the message languageOP
inventorybackup.reloadReload plugin configuration and message bundlesOP

Configuration

The default config.yml provides clean, granular control over all features:

# Language for all plugin and console messages: "en" (English) or "de" (German).
# Message texts live in messages_<language>.yml next to this file.
language: "en"

# How many days to keep inventory files before auto-deletion (0 = disabled)
auto-delete-days: 30

# Check interval for file cleanup (in hours)
cleanup-interval-hours: 24

# Save inventory automatically on player death
save-on-death: true

# Performance settings: damage cache cleanup interval (in seconds)
cache-cleanup-interval: 30

# Retention period for unapplied offline restores in days (0 = forever)
pending-restore-expiry-days: 30

# Notification settings
notify-on-backup: true
notify-ops-only: true

# Update check (Modrinth)
update-check:
  enabled: true               # Master switch
  check-on-startup: true      # Fetch on server start
  notify-admins-on-join: true # Notice in chat when an admin joins
  modrinth-project-id: "rpKY25cW"
  contact: "zfzfg@sterra.online" # Included in User-Agent header
  stable-only: true           # Ignore pre-releases
  startup-delay-ticks: 20     # Startup check delay (20 ticks = 1 second)

Language Bundles (messages_en.yml, messages_de.yml)

Message texts are decoupled from config.yml. Customizing messages is as simple as editing messages_en.yml or messages_de.yml and running /inv reload. Any missing translation keys automatically fall back to the English defaults without breaking plugin execution.


File Structure

plugins/InventoryBackup/
├── config.yml                                      <- Main plugin settings
├── messages_en.yml                                 <- English message bundle
├── messages_de.yml                                 <- German message bundle
├── names.yml                                       <- Player Name <-> UUID index cache
├── pending-restores.yml                            <- Offline restores queue
└── inventories/
    └── <owner-uuid>/
        ├── 2026-08-11_14-00-00_death.yml           <- Automatic death backup
        ├── 2026-08-11_15-30-00_manual.yml          <- Manual /inv backup
        └── 2026-08-11_16-45-00_quest.yml           <- API backup with custom type

Common Administrator Scenarios

Scenario 1: Player Died in Lava / Void

  1. Check the player's backups: /inv Steve list
  2. Preview the backup items in the GUI: /inv Steve show 2026-08-11_14-00-00_death.yml
  3. Restore the full inventory: /inv Steve restore 2026-08-11_14-00-00_death.yml

Scenario 2: Player Lost Specific Items but Kept Some Gear

  1. List the player's backups: /inv Alex list
  2. Hand over only the missing items: /inv Alex givemissing 2026-08-11_14-00-00_death.yml
  3. Alex receives all missing item stacks in their inventory without overwriting their currently equipped gear.

Scenario 3: Restoring an Offline Player

  1. A player reports item loss on Discord while offline.
  2. An admin executes: /inv Steve restore 2026-08-11_14-00-00_death.yml
  3. The plugin queues the restore: Steve is offline - the restore will run on their next join.
  4. Verify the queue: /inv Steve pending
  5. As soon as Steve logs into the server, their inventory is restored automatically.

Scenario 4: Server Maintenance / Pre-Event Snapshot

  1. Before running a risky server event or maintenance: /inv backup all
  2. All online players have their exact inventories snapshotted.
  3. If an issue occurs, any player can be restored to this exact pre-event state.

Developer Integration

Add the API dependency to your pom.xml:

<dependency>
    <groupId>com.zfzfg</groupId>
    <artifactId>InventoryBackup-API</artifactId>
    <version>0.1.0</version>
    <scope>provided</scope>
</dependency>

Quick Code Example

import com.zfzfg.inventorybackup.api.*;

// Obtain API instance
InventoryBackupAPI api = InventoryBackupProvider.get();

// Create a snapshot before a custom minigame / quest
api.createBackup(player, BackupRequest.builder()
        .type("dungeon")
        .sourcePlugin(this)
        .metadata("dungeon-id", "shadow-crypt")
        .build())
   .thenAccept(optHandle -> optHandle.ifPresent(handle -> {
       getLogger().info("Saved backup " + handle.id() + " for " + player.getName());
   }));

See API.md for full developer documentation, event listener guides, and threading specifications.


Author & Support

Последние версии

Все версии →
release

InventoryBackup 0.2.0

0.2.0
1 окт. 2026 г.189Minecraft: 1.21.8, 1.21.9, 1.21.10, 1.21.11, 26.1, 26.1.1, 26.1.2, 26.2, 26.3paper, purpur, spigot
Скачать
Что нового
## [0.2.0] - 2026-10-01 ### New Features - **Spigot NBT storage**: One plugin JAR selects Paper/Purpur's native item byte API or an internal CraftBukkit codec. New backups stay on `format-version: 3` with compressed Minecraft item NBT and `data-version`. - **Cross-platform archives**: Backups move between tested Spigot, Paper and Purpur servers on the same Minecraft version and upgrade to a newer tested version. Newer data versions are rejected instead of being applied. - **Historical backups stay readable**: Unmodified 0.0.7 and 0.1.0 archives, including multiline Base64 and 41-slot inventories, load through the original ObjectStream path. Existing files are not rewritten. Legacy shulker and other block-entity contents are upgraded before metadata decoding. - **Safe startup**: The NBT adapter runs a round trip before configuration, the pre-upgrade ZIP, or inventory migration. An unsupported server, Folia, or a failed self-test disables the plugin and leaves the archive untouched. - **Update checks follow the detected loader**: Modrinth results are matched to Spigot, Paper, or Purpur instead of accepting every loader. ### Compatibility - Tested on Minecraft 1.21.8, 1.21.10, 1.21.11, 26.1.2, 26.2 and 26.3 for Spigot, Paper and Purpur. Paper and Purpur 1.21.9 are included. No exact Spigot 1.21.9 build exists. Minecraft 26.3 is experimental. Details and limits are in [COMPATIBILITY.md](COMPATIBILITY.md). - Java 21 for Minecraft 1.21.x and Java 25 for Minecraft 26.1+. - The public backup and restore API, events, and `InventoryBackupAPI.API_VERSION` (`2`) are unchanged. The API artifact coordinate is `com.zfzfg:InventoryBackup-API:0.2.0`. ### Behavior - A `pre-nbt-upgrade-<timestamp>.zip` of the plugin data is created once before new-format writes. - The public legacy serializer helpers are ObjectStream pairs again. New backups use the explicit NBT codec. Legacy and NBT payloads cannot be read as each other. - The running Minecraft data version comes from the server itself. The adapters no longer call `Bukkit.getUnsafe()`. - Player-name folders still migrate to UUID folders (`storage-version: 2`) after the pre-upgrade ZIP.
release

InventoryBackup 0.1.0

0.1.0
11 авг. 2026 г.208Minecraft: 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6, 1.21, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.7, 1.21.8, 1.21.9, 1.21.10, 1.21.11, 26.1, 26.1.1, 26.1.2, 26.2, 26.3bukkit, paper, purpur, spigot
Скачать
Что нового
## [0.1.0] - 2026-08-11 ### New Features - **Public Developer API** (`com.zfzfg:InventoryBackup-API`): - Standalone API module allowing other plugins to create, list, load, restore, and delete backups, open the preview GUI, and resolve names to UUIDs. - Retrieved via `InventoryBackupProvider.get()` or `getOptional()`, backed by Bukkit's `ServicesManager` (`softdepend: [InventoryBackup]` is sufficient). - All `CompletableFuture`s complete directly on the Bukkit main thread, allowing callers to interact with Bukkit methods safely without manual scheduler hops. - Detailed documentation and integration examples in [API.md](API.md). - **Custom Bukkit Events**: - Five custom events shipped inside the plugin JAR, usable with or without compiling against the API module: - `BackupCreateEvent` (cancellable, allows retyping backups and attaching custom metadata). - `BackupCreatedEvent` (fired after a backup is successfully saved to disk). - `InventoryRestoreEvent` (cancellable, allows inspecting or modifying snapshot items before applying). - `InventoryRestoredEvent` (fired after a restore is successfully applied). - `BackupDeletedEvent` (fired with reason `API`, `COMMAND`, or `EXPIRED`). - The plugin's internal death handler and admin commands route through the same service, ensuring uniform event dispatching. - **Offline Player Restores**: - Aiming a restore or missing items command at an offline player automatically queues it in `pending-restores.yml`. - Automatically applied on the player's next join with a 1-tick delay to prevent overwriting by other login listeners; persists across server restarts. - Added `/inv <player> pending` to inspect queued restores and `/inv <player> cancelpending` to discard them (permission `inventorybackup.pending`). - Added `pending-restore-expiry-days` configuration setting (default: 30 days) to automatically purge expired pending entries. - **Native Multi-Language Support (i18n)**: - Complete English (`en`) and German (`de`) translations for all player messages, GUI titles, list headers, and console logs. - Message texts decoupled into dedicated bundles: `messages_en.yml` (master fallback) and `messages_de.yml`. - Added `/inv lang [en|de]` to view or change language on the fly (rewrites `config.yml` and reloads immediately without a server restart; permission `inventorybackup.lang`). - Added `/inv reload` to reload configuration and message bundles on demand (permission `inventorybackup.reload`). - Layered fallback system: missing keys in custom translations seamlessly fall back to English defaults without breaking plugin execution. - **UUID-Based Storage & Player Index**: - Backups are stored in `inventories/<owner-uuid>/` rather than player names, preventing orphaned backups when players change their username. - Implemented `names.yml` index cache populated on player join and backup operations, eliminating blocking Mojang API requests during commands and tab completion. - Automatic migration on first startup (`StorageMigrator`) moves legacy player-name folders to UUIDs; unrecognized folders are safely parked in `inventories/_unmigrated/` with zero data loss. - **Free-Form Backup Types & Key-Value Metadata**: - Backup types are no longer restricted to `death` and `manual`. Custom types (e.g. `quest`, `dungeon`, `pvp`) are normalized to `[a-z0-9-]` for filename safety. - Arbitrary string metadata stored alongside backups in the YAML header and accessible via `BackupHandle.metadata(key)`. - **Dupe-Proof Preview GUI**: - Implemented `PreviewHolder` and `PreviewGuiListener` to block all inventory clicks, drags, and hotbar swaps in `/inv <player> show`, preventing item duplication exploits regardless of window titles or translations. ### Bugfixes & Improvements - **Fixed `restoreInventory` reporting false positives**: Previously returned `true` as soon as the task was scheduled; storage operations are now fully blocking internally with completion handled asynchronously. - **Fixed corrupted backup handling**: A failed Base64 decode previously produced an empty item array that wiped player inventories upon restore. Unreadable backups are now safely logged, skipped, and left untouched. - **Fixed armor & offhand overwrite during partial restores**: Contents array slot bounds are strictly enforced so that restoring main inventory items does not inadvertently alter armor or offhand slots. - **Fixed same-second backup filename collisions**: When multiple backups are created for a player within the same second, an incremental numeric suffix (e.g. `-2`) is appended to prevent overwrites. - **Fixed custom backup type timestamp parsing**: The cleanup parser now matches fixed-width timestamp prefixes rather than cutting at the last underscore. - **Fixed unbounded lock map memory leak**: `InventoryManager` releases player write locks upon player disconnect (`PlayerQuitEvent`). - **Fixed mixed-language outputs**: Eliminated remaining hardcoded German and English strings across console logging, update checking, list headers, GUI titles, and missing-key indicators (`&c[missing: messages.<key>]`). - **Enhanced tab completion**: Now completes subcommands (`backup`, `version`, `lang`, `reload`), actions (`restore`, `show`, `givemissing`, `list`, `delete`, `pending`, `cancelpending`), online players, known offline players from the local index, and backup filenames. ### Breaking Changes - **Storage Layout Migration**: Backup directory changed from `inventories/<PlayerName>/` to `inventories/<owner-uuid>/`. Existing directories are migrated automatically on first startup. - **`InventoryManager` Refactoring**: Deprecated name-keyed methods in favor of UUID-keyed methods returning `BackupHandle` / `BackupSnapshot`. External integrations must migrate to `InventoryBackupAPI`. ### Build & Testing - Multi-module Maven architecture: `InventoryBackup-parent` containing `api` (packaged as standalone JAR with sources and javadoc) and `plugin` (shading API classes without relocation). - Added comprehensive JUnit 5 test suite with 18 automated tests: - `BundleParityTest`: Verifies full translation parity, placeholder integrity, and missing key detection. - `StorageMigratorTest`: Tests folder migration, merging, and unmigrated folder parking against real temporary directories. - `BackupFileNameTest`: Tests timestamp formatting, UUID parsing, and suffix handling. - `BackupTypeTest`: Tests type normalization and validation. - `InventorySerializerTest`: Tests Base64 serialization and deserialization across Minecraft inventory structures. --- ## [0.0.7] - 2026-08-08 ### New Features - Added Modrinth Update Checker (`UpdateChecker.java`) - Asynchronous update checking with Modrinth v2 API integration (`https://modrinth.com/project/rpKY25cW`). - Added `/inv version` command - On-demand version check and update lookup with direct download links and live feedback. - Added `UpdateNotifyListener` - Notifies administrators with permission `inventorybackup.update.notify` on join using cached check results (zero HTTP requests during login). - Added tab completion support for `version` subcommand in `/inv`. ### Bugfixes & Improvements - **Fixed `NoClassDefFoundError: Base64Coder`**: Replaced deprecated `org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder` with standard `java.util.Base64` (`Base64.getEncoder()` and `Base64.getMimeDecoder()`) for full compatibility with modern Paper/Purpur/Spigot 1.20+ and SnakeYAML 2.x runtimes. - **Fixed URL formatting corruption in `colorize()`**: Switched from `message.replace("&", "§")` to `ChatColor.translateAlternateColorCodes('&', message)` to ensure URLs with query parameters remain intact. - **Fixed missing message fallback in `getMessage()`**: Missing keys in existing configurations return a fallback (`&c[fehlt: messages.<path>]`) instead of returning raw key strings. - **Unified version definition**: Switched `plugin.yml` to `${project.version}` so that Maven (`pom.xml`) is the single source of truth for the plugin version. - **Robust version comparison**: `UpdateChecker` handles numeric parts, pre-release suffixes, and numeric overflows safely. ### Configuration Updates - Added `update-check` configuration section in `config.yml` (`enabled`, `check-on-startup`, `notify-admins-on-join`, `modrinth-project-id`, `contact`, `stable-only`, `startup-delay-ticks`). - Added message templates for update checking (`update-available`, `update-download`, `update-current`, `update-up-to-date`, `update-checking`, `update-failed`, `update-disabled`). - Updated `plugin.yml` with `inventorybackup.update.notify` permission and updated command usage description.
release

InventoryBackup 0.0.6

0.0.6
24 мая 2026 г.84Minecraft: 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6, 1.21, 1.21.1, 1.21.2, 1.21.3, 1.21.4, 1.21.5, 1.21.6, 1.21.7, 1.21.8, 1.21.9, 1.21.10, 1.21.11, 26.1, 26.1.1, 26.1.2bukkit, paper, purpur, spigot
Скачать