跳到正文

FabricSharedInventory

作者:Block1215

Share inventory across multiple servers

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

🎒 Shared Inventory — Cross-Server Inventory, Ender Chest & XP Sync

Share your inventory, ender chest, and experience points across multiple Fabric servers in real time.

💾 Powered by PostgreSQL — data is permanently written to disk. Even if the server crashes, your items are safe.


✨ Features

  • 🔄 Real-time sync — Changes are detected within 1 tick (50ms) and instantly saved
  • 🌐 Cross-server — Works across servers running on completely different PCs
  • 💾 Persistent storage — PostgreSQL writes to disk immediately. No data loss on power failure
  • 📴 Offline sync — Players automatically receive the latest data when logging into a server that was offline
  • 🛡️ Startup protection — Server refuses to start if the database is unreachable, with a detailed error log
  • ⚙️ Per-feature toggle — Inventory / Ender Chest / XP can each be enabled or disabled individually per server

📋 Requirements

  • Minecraft 1.20.1
  • Fabric Loader 0.15.0+
  • Fabric API
  • PostgreSQL (free, self-hosted — setup guide below)

🚀 Installation

📦 Step 1 — Install PostgreSQL (click to expand)

PostgreSQL is a free, open-source database that runs as a background service and saves data safely to disk.

Windows

  1. Download the installer from https://www.postgresql.org/download/windows/ → Click “Download the installer” → Select the latest Windows x86-64
  1. Run the installer
  • Keep all defaults
  • Set a password — you will need this later
  • Leave the port as 5432
  • After installation, PostgreSQL starts automatically as a Windows service ✅
  • pgAdmin 4 (a GUI tool) is also installed automatically
  1. Open pgAdmin 4 from the Start Menu
  1. In the left sidebar, click the terminal icon (PSQL Tool)
  1. Enter your password to log in → you will see the postgres=# prompt
  1. Run the following command:
   CREATE DATABASE sharedinventory;

→ If you see CREATE DATABASE, you are done! ✅

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl enable postgresql
sudo systemctl start postgresql
sudo -u postgres psql -c "CREATE DATABASE sharedinventory;"
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'yourpassword';"

🗂️ Step 2 — Install the Mod (click to expand)
  1. Download shared-inventory-2.0.0.jar
  2. Place it in your server’s mods/ folder
  3. Make sure Fabric API is also in your mods/ folder
  4. The PostgreSQL JDBC driver is bundled inside the mod — no extra files needed ✅

⚙️ Step 3 — Configure (click to expand)

Start the server once — the config file will be auto-generated at:

config/shared-inventory.json

Edit it with your PostgreSQL connection info:

{
  "database": {
    "host": "localhost",
    "port": 5432,
    "name": "sharedinventory",
    "user": "postgres",
    "password": "YOUR_PASSWORD_HERE"
  },
  "sync": {
    "inventory": true,
    "ender_chest": true,
    "experience": true
  },
  "behavior": {
    "save_interval_ticks": 200
  }
}

Restart the server. If you see this in the log, everything is working:

[SharedInventory] PostgreSQL connection successful!
[SharedInventory] Initialization complete! Ready to sync.

🖥️ Multi-PC Setup — Different Computers (click to expand)

If your servers run on different PCs, all of them must point to the same single PostgreSQL instance.

On the PC running PostgreSQL:

  1. Edit postgresql.conf:
   listen_addresses = '*'

Location: C:\Program Files\PostgreSQL\18\data\postgresql.conf

  1. Edit pg_hba.conf and add at the bottom:
   host    all    all    0.0.0.0/0    md5
  1. Restart PostgreSQL and open port 5432 in your firewall
  • Windows Firewall → allow inbound on port 5432

On each Minecraft server’s config:

Minecraftserver/config/shared-inventory.json

Set host to the IP address of the PC running PostgreSQL:

"host": "PostgreSQL IP"

📊 Config Reference (click to expand)

| Key | Default | Description |
|—–|———|————-|
| database.host | localhost | PostgreSQL server address |
| database.port | 5432 | PostgreSQL port |
| database.name | sharedinventory | Database name |
| database.user | postgres | Username |
| database.password | password | Password |
| sync.inventory | true | Sync main inventory |
| sync.ender_chest | true | Sync ender chest |
| sync.experience | true | Sync experience (level & XP bar) |
| behavior.save_interval_ticks | 200 | Periodic save interval (20 ticks = 1 sec) |

Changes are detected every tick. save_interval_ticks only controls the forced periodic save for players with no recent changes.


❗ Troubleshooting (click to expand)

Server won’t start — “Cannot connect to PostgreSQL”

  • Check that PostgreSQL is running
  • Windows: services.msc → postgresql-x64-18 should show “Running”
  • Linux: sudo systemctl status postgresql
  • Check the password in config/shared-inventory.json
  • Make sure the database sharedinventory has been created

Password authentication failed

  • The password field in your config does not match your PostgreSQL password
  • Open config/shared-inventory.json and correct the password field

📄 License — MIT




🎒 Shared Inventory — 複数サーバー間インベントリ・エンダーチェスト・経験値リアルタイム同期

複数のFabricサーバー間で、インベントリ・エンダーチェスト・経験値をリアルタイムに共有します。

💾 PostgreSQL を使用しているため、データはディスクに永続保存されます。サーバーがクラッシュしてもアイテムは失われません。


✨ 特徴

  • 🔄 リアルタイム同期 — 変化を1tick(50ms)以内に検出し、即座にDBへ保存
  • 🌐 クロスサーバー対応 — 別々のPCで動作している複数サーバー間でも同期可能
  • 💾 永続ストレージ — PostgreSQL は書き込みを即座にディスクに記録。突然の電源断でもデータは安全
  • 📴 オフライン同期 — サーバーがオフラインだった間の変化も、次回ログイン時に自動で最新データを適用
  • 🛡️ 起動時保護 — DBへの接続に失敗した場合、サーバーの起動を拒否して詳細なエラーをログに出力
  • ⚙️ 機能ごとのON/OFF — インベントリ・エンダーチェスト・経験値をサーバーごとに個別に有効/無効化可能

📋 動作要件

  • Minecraft 1.20.1
  • Fabric Loader 0.15.0+
  • Fabric API
  • PostgreSQL(無料・自己ホスト型DB、下記セットアップ参照)

🚀 導入方法

📦 STEP 1 — PostgreSQL のインストール(クリックで展開)

PostgreSQL は無料のオープンソースDBです。バックグラウンドサービスとして動作し、データをディスクに安全に保管します。

Windows の場合

  1. インストーラーをダウンロード https://www.postgresql.org/download/windows/ → 「Download the installer」 → 最新版の Windows x86-64 を選択
  1. インストーラーを実行
  • 全ての項目はデフォルトのままでOK
  • パスワードは必ず設定する(後でコンフィグに入力します)
  • ポートは 5432 のまま
  • インストール完了後、PostgreSQL はWindowsサービスとして自動起動します ✅
  • pgAdmin 4(GUI管理ツール)も同時に自動インストールされます
  1. スタートメニューから pgAdmin 4 を起動
  1. 左側のサイドバーにあるターミナルアイコン(PSQL Tool)をクリック
  1. パスワードを入力してログイン → postgres=# が表示される
  1. 以下を入力して Enter を押す
   CREATE DATABASE sharedinventory;

→ CREATE DATABASE と表示されれば成功 ✅

Linux(Ubuntu/Debian)の場合

# インストール
sudo apt update
sudo apt install postgresql postgresql-contrib

# 自動起動の設定
sudo systemctl enable postgresql
sudo systemctl start postgresql

# データベースの作成
sudo -u postgres psql -c "CREATE DATABASE sharedinventory;"

# パスワードの設定(yourpassword を変更してください)
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'yourpassword';"

🗂️ STEP 2 — Mod のインストール(クリックで展開)
  1. shared-inventory-2.0.0.jar をダウンロード
  2. サーバーの mods/ フォルダに入れる
  3. Fabric API も mods/ フォルダに入っていることを確認
  4. PostgreSQL の JDBC ドライバは Mod内にバンドル済み のため、追加ファイルは不要 ✅

⚙️ STEP 3 — コンフィグの設定(クリックで展開)

サーバーを一度起動すると、以下のパスにコンフィグファイルが自動生成されます:

config/shared-inventory.json

テキストエディタで開き、PostgreSQLの接続情報を入力します:

{
  "database": {
    "host": "localhost",
    "port": 5432,
    "name": "sharedinventory",
    "user": "postgres",
    "password": "STEP1で設定したパスワード"
  },
  "sync": {
    "inventory": true,
    "ender_chest": true,
    "experience": true
  },
  "behavior": {
    "save_interval_ticks": 200
  }
}

保存してサーバーを再起動します。ログに以下が表示されれば成功です:

[SharedInventory] PostgreSQL への接続成功!
[SharedInventory] 初期化完了! 同期の準備ができました。

🖥️ 複数PCでサーバーを動かす場合の追加設定(クリックで展開)

異なるPCでサーバーを動かす場合、すべてのサーバーが同じ1台のPostgreSQLを参照するよう設定します。

PostgreSQL がインストールされているPC側の設定:

  1. postgresql.conf を編集:
   listen_addresses = '*'

ファイルの場所(Windows): C:\Program Files\PostgreSQL\18\data\postgresql.conf
ファイルの場所(Linux): /etc/postgresql/*/main/postgresql.conf

  1. pg_hba.conf の末尾に以下を追加:
   host    all    all    0.0.0.0/0    md5
  1. PostgreSQL を再起動し、ファイアウォールでポート 5432 を開放
  • Windows: Windowsファイアウォール → ポート5432を受信許可

各Minecraftサーバーのコンフィグ:

Minecraftserver/config/shared-inventory.json

host を PostgreSQL が動いているPCのIPアドレスに変更:

"host": "PostgreSQL IP"

📊 コンフィグ項目一覧(クリックで展開)

| 項目 | デフォルト値 | 説明 |
|——|————-|——|
| database.host | localhost | PostgreSQLサーバーのアドレス |
| database.port | 5432 | ポート番号 |
| database.name | sharedinventory | データベース名 |
| database.user | postgres | ユーザー名 |
| database.password | password | パスワード |
| sync.inventory | true | メインインベントリの同期 |
| sync.ender_chest | true | エンダーチェストの同期 |
| sync.experience | true | 経験値(レベル・XPバー)の同期 |
| behavior.save_interval_ticks | 200 | 定期保存の間隔(20tick = 1秒) |

変化の検出は毎tick行われます。save_interval_ticks は変化がなかった場合の強制保存間隔です。


❗ トラブルシューティング(クリックで展開)

「PostgreSQL に接続できません」と出てサーバーが起動しない

  • PostgreSQL が起動しているか確認
  • Windows: services.msc → postgresql-x64-18 が「実行中」か確認
  • Linux: sudo systemctl status postgresql
  • config/shared-inventory.json のパスワードを確認
  • データベース sharedinventory が作成されているか確認

「パスワード認証に失敗しました」というエラーが出る

  • config/shared-inventory.json の password が間違っています
  • PostgreSQL のインストール時に設定したパスワードを正確に入力してください

📄 ライセンス — MIT

常见问题

FabricSharedInventory 支持哪些 Minecraft 版本?

FabricSharedInventory 支持 Minecraft Java 版 1.20.1,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

FabricSharedInventory 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:仅服务端。

评论

登录后评论和评分

Block1215 的其他作品

查看全部 →