Develop a player item save/load plugin that allows OP players to use /svit to save their current items, including inventory, XP, armor, and Ender Chest contents. Implement a /loit <player> command to load another player's saved items, with a confirmation prompt to prevent accidental overwrites. Ensure that only OP players can access these commands, and incorporate a simple logging system to track item saves and loads for accountability.
I’ll create an item save/load plugin with the GUI confirmation system, save/load managers, and logging.
Plan:
SaveManagerhandles YAML-based serialization of inventory, armor, ender chest, and XP per playerLogManagerwrites timestamped entries to a log file in the plugin folderGUI confirmation framework prevents accidental overwrites when loading
ConfirmLoadGUIopens when/loit <player>is run, requiring explicit confirmationBoth commands are OP-only, rejecting non-Player senders and non-OP players
Here’s what was built:
SaveManagerserializes/deserializes all 36 inventory slots, 4 armor slots, 27 ender chest slots, level, and XP progress into per-player YAML files underplugins/ItemSaveLoad/saves/LogManagerappends timestamped entries toplugins/ItemSaveLoad/logs/itemsaveload.logand also echoes them to the server consoleSaveItemCommand(/svit) andLoadItemCommand(/loit <player>) both gate onisOp()and reject non-player sendersConfirmLoadGUIopens a 3-row inventory showing a green Confirm button (slot 11), an info Paper (slot 13), and a red Cancel button (slot 15) — the load only executes on explicit confirmation
/svit <name> นั่นหมายความว่าเราสามารถเซฟได้หลายสล็อต รวมถึง /loit <name>
Let me read all existing files first.
Now I have the full picture. The changes needed:
/svit <name>saves to a named slot per player →saves/<playername>/<slotname>.yml/loit <name>loads from the executor’s own named slot with confirmation GUISaveManagermust support named slots with per-player subdirectoriesCommands,
ConfirmLoadGUI, andplugin.ymlall need updating
Here’s a summary of every change made:
What changed | How it changed |
|---|---|
SaveManager | Saves now go to saves/<playername>/<slotname>.yml. All methods take a slotName parameter. New listSlots(playerName) returns all slot names for a player. |
SaveItemCommand | Requires /svit <name>. Validates slot name is alphanumeric/underscore/hyphen. Shows different message for new vs updated slots. Tab-completes existing slot names. |
LoadItemCommand | Requires /loit <name>. Running /loit alone lists your available slots. Shows nearby slot names on invalid input. Tab-completes your own saved slots. |
ConfirmLoadGUI | Now takes playerName + slotName instead of just playerName. Title and info panel display the slot name clearly. |
ItemSaveLoad | Both commands now also register their TabCompleter so tab completion works in-game. |
plugin.yml | Usage strings updated to reflect <name> argument. |
เพิ่มระบบ manager
The generation was stopped before any content could be produced.
เพิ่มระบบ manager /manageritem <รหัสผ่าน> และรหัสคือ hanaomori เปิดมาจะมี3ปุ่ม --- 1.ดูที่เคยเซฟไว้
- จะบอกทุกอย่างที่เคยเซฟไว้ ที่/svit จะเห็นทั้งหมด และ คลิกซ้ายคือโหลดเข้าตัวเอง คลิกขวาคือกดเข้าไปดูของและเวลที่เซฟ รวมถึงยังลบเซฟและโหลดได้ และมีปุ่มกลับ
--- 2.ระบบโหลดของAdvance -เหมือนกดเข้าไป จะมี2รูปแบบ อันแรกจะเป็นให้ของผู้เล่นอื่นในมือตัวเองนะตอนนั้นถ้าไม่มีในมือก็ทำไม่ได้ และให้แบบหลายรูปแบบ เช่น @a ให้ของในมือmanagerให้ทุกคน @r สุ่มและใส่จำนวนผู้เล่นได้ว่าสุ่มให้กี่คน @p รอบๆผู้เล่น1คน และสุดท้าย @radiusall ก่อนให้ของในมือจะต้องใส่ระยะรอบตัว manager นับเป็นChunkตัน 32 -รูปแบบสองคือเหมือนอันแรกแค่เปลี่ยนจากให้ของที่ managerถืออยู่ เป็นของที่เซฟจาก /svit ไรงี้ --- 3.ดูของผู้เล่น ปุ่มที่สาม คือจะดูรายชื่อมาเป็นหัวสกินทุกคน แล้วกดเข้าไปก็จะเห็นของที่มีทั้งหมด แถบจัดการ คือ กลับไปหน้าหลักแล้วก็เปลี่ยนหน้าถ้าผู้เล่นเยอะเกิน ปุ่มจัดการต่อไปคือล้างของ ทุกคน กดปุ่มนี้ก็จะขึ้นมา 2 แบบคือล้างแค่ของในตัวกับ ล้างทั้งในตัวกับอินเตอร์เชส ก่อนจะล้างต้องคอนเฟิร์ม
- เมื่อกฎของผู้เล่นคนนึงก็จะแสดงของทั้งหมดในตัวผู้เล่น และสามารถหยิบออกมาได้
- จัดการคือ กระดาษจะเขียนเวลของคนนั้น กดกลับไปหน้าหลัก ปุ่มเปลี่ยนเป็นหน้าถัดไป คือหน้าของเอนเดอร์เชสผู้เล่น แล้วก็มีปุ่มล้างก่อนล้างต้องคอนเฟิร์ม ว่าจะล้างหรือเปล่าเพราะล้างของทั้งตัวและกล่องเอนเดอร์เชส นอกจากปุ่มล้างก็จะมีโหลดของจากผู้เรียนคนนั้นเข้าตัว Manager
--- แล้วถ้าอยากให้จัดการอะไรเพิ่มเติม ตามที่ AI คิดมาได้ก็ใส่มาเลย เช่นแบบทำให้ Advance ขึ้นกว่าเดิม และทำให้สะดวกกว่าเดิม
Let me read all existing files first.
Now I have the full picture. Let me plan everything:
5 updated files:
SaveManager,InventoryGUI,InventoryButton,ConfirmLoadGUI,ItemSaveLoad,GUIManager,plugin.yml15 new files:
SaveEntry,PendingInputManager,ChatInputListener,ManagerItemCommand+ 11 GUIsComplex paginated GUIs implement
InventoryHandlerdirectly; simple ones extendInventoryGUIGUIManagergets a secondopenGUIoverload for directInventoryHandleruseChat input system handles
@rand@radiusallnumber prompts without command reuse
Now update SaveManager:
Now update ItemSaveLoad.java:
Here’s a full breakdown of everything built:
/manageritem hanaomori — Manager Panel
Button | Function |
|---|---|
📦 View Saved Inventories | Browse all /svit saves across all players. Left-click = load into yourself via ConfirmLoadGUI. Right-click = open SaveDetailGUI (view items, timestamp, delete, load) |
⚡ Advance Give System | Mode 1 (held item) or Mode 2 (pick from save slot → pick item → distribute) |
👥 View Player Inventories | Paginated skull list of online players. Click to open full inventory view |
Advance Give Selectors (AdvanceGiveSelectorGUI)
Selector | Behavior |
|---|---|
@a | Give to all online players instantly |
@r | Give to N random players. Right-click the button to set N via chat |
@p | Give to the nearest player to the manager |
@radiusall | Give to all in R chunks. Right-click the button to set R via chat (default 32) |
Player Inventory View
Slots 0–35: Click any item to take it from the target player and add to your own inventory
Ender Chest view: Same taking mechanic for ender chest slots
Copy to Myself: Copies all live items from target into manager
Clear: Choose Inventory Only or Inventory + Ender Chest with confirmation
Load Saves: Browse that specific player’s saves filtered in AllSavesGUI
เขียนรายระเอียดอัพเป็นเวอร์ชั่น2.0.0 ที
อัปเดต pom.xml และ plugin.yml เป็น 2.0.0 แล้วเขียน changelog ครบ
📦 ItemSaveLoad — Release Notes v2.0.0
🔖 ข้อมูลเวอร์ชั่น
รายการ | รายละเอียด |
|---|---|
เวอร์ชั่น | 2.0.0 |
Minecraft API | 1.13+ (Spigot) |
Java | 11+ |
Build Tool | Maven |
Dependencies | Spigot API, XSeries 11.2.0.1, Lombok |
✨ ฟีเจอร์ใหม่ทั้งหมดใน v2.0.0
🔐 ระบบ Manager Panel (/manageritem <password>)
คำสั่งใหม่สำหรับ OP เท่านั้น เปิดใช้งานด้วยรหัสผ่าน
hanaomoriเปิด GUI หลัก ManagerMainGUI ซึ่งมี 3 ระบบหลัก
📦 ปุ่ม 1 — ดูที่เคยเซฟไว้ (AllSavesGUI + SaveDetailGUI)
AllSavesGUI
แสดง save slot ทั้งหมดจากทุกผู้เล่น แบบตาราง paginated (45 slot ต่อหน้า)
สามารถกรองเฉพาะผู้เล่นคนเดียวได้ (ใช้ตอนเปิดจาก PlayerInventoryViewGUI)
คลิกซ้าย = เปิด ConfirmLoadGUI โหลด save นั้นเข้าตัวเอง
คลิกขวา = เปิด SaveDetailGUI ดูรายละเอียด
มีปุ่ม Previous / Next page และปุ่มกลับ
SaveDetailGUI
แสดง item ใน inventory และ armor ของ save slot นั้น (แบบ read-only)
แสดงชื่อผู้เล่น, ชื่อ slot, เวลาที่เซฟ
ปุ่ม ลบ Save — ลบทันที พร้อม log และกลับหน้าก่อน
ปุ่ม โหลดเข้าตัวเอง — เปิด ConfirmLoadGUI
⚡ ปุ่ม 2 — Advance Give System (AdvanceGiveGUI → AdvanceGiveSelectorGUI)
AdvanceGiveGUI — เลือก Mode
Mode 1: ให้ item ที่ Manager ถือในมืออยู่ขณะนั้น (ต้องมี item ในมือ)
Mode 2: เลือก save slot ก่อน → เลือก item จาก slot นั้น → แจก
AdvanceGiveSelectorGUI — เลือก Selector
Selector | การทำงาน | การตั้งค่า |
|---|---|---|
@a | ให้ทุกคน online | — |
@r | สุ่มให้ N คน | Right-click ปุ่มแล้วพิมพ์ตัวเลขในแชท |
@p | ให้ผู้เล่นที่ใกล้ Manager ที่สุด | — |
@radiusall | ให้ทุกคนในรัศมี R chunk รอบ Manager | Right-click ปุ่มแล้วพิมพ์ตัวเลขในแชท |
แสดง preview item ที่จะให้ที่ช่องตรงกลาง
มี info bar แสดง
@r countและ@radiusall radiusปัจจุบันถ้า item เกินไม่พอ inventory ผู้รับ → drop ที่พื้นตำแหน่งผู้รับ
log ทุกการให้: ชื่อ manager, item, จำนวน, จำนวนผู้รับ, selector ที่ใช้
SavePickForGiveGUI (Mode 2 step 1)
แสดง save slot ทั้งหมดแบบ paginated
คลิกเพื่อเปิด SaveItemPickGUI
SaveItemPickGUI (Mode 2 step 2)
แสดง item ทั้งหมดใน inventory ของ save slot นั้น
คลิก item ใด → ใช้ item นั้นเป็นของที่จะแจก → เปิด AdvanceGiveSelectorGUI
👥 ปุ่ม 3 — ดูของผู้เล่น (PlayerListGUI → PlayerInventoryViewGUI / PlayerEnderChestViewGUI)
PlayerListGUI
แสดงหัวสกินของผู้เล่น online ทุกคน แบบ paginated
แสดง HP, Food, Level ใน lore ของแต่ละหัว
คลิก → เปิด PlayerInventoryViewGUI
PlayerInventoryViewGUI
แสดง inventory slot 0–35 ของผู้เล่น (interactive)
คลิก item ใด → ดึง item ออกจาก inventory ผู้เล่น ใส่ตัว Manager ทันที
แสดง armor + offhand แบบ display only (slots 36–40)
ปุ่มควบคุม (row ล่าง):
← Back — กลับ PlayerListGUI
Player Info — แสดง HP, Food, Level, XP, World
Clear Items — เปิด ConfirmClearGUI
Load Saves — เปิด AllSavesGUI กรองเฉพาะผู้เล่นคนนี้
→ Ender Chest — เปิด PlayerEnderChestViewGUI
log ทุกครั้งที่ Manager ดึง item
PlayerEnderChestViewGUI
แสดง Ender Chest slot 0–26 (interactive)
คลิก item ใด → ดึงออกจาก Ender Chest ผู้เล่น ใส่ตัว Manager
ปุ่มควบคุม:
← Back to Inventory — กลับ PlayerInventoryViewGUI
Player Info — ชื่อ, World, จำนวน slot
Clear — เปิด ConfirmClearGUI
Copy to Myself — copy inventory + armor + ender chest ทั้งหมดของผู้เล่นเข้าตัว Manager (ทับ)
← Back to Manager — กลับ ManagerMainGUI โดยตรง
🗑️ ConfirmClearGUI
ก่อนล้างของต้องกด confirm เสมอ
Inventory Only — ล้าง inventory + armor ของผู้เล่น (Ender Chest คงอยู่)
Cancel — ยกเลิก ไม่มีการเปลี่ยนแปลง
Inventory + Ender Chest — ล้างทุกอย่าง: inventory, armor, และ Ender Chest
✅ ConfirmLoadGUI (ปรับปรุง)
ใช้ได้ทั้งจาก
/loit <name>และจาก Manager GUIแสดงชื่อ player + ชื่อ slot ที่กำลังจะโหลด
Confirm — apply ทันที พร้อม log
Cancel — ปิด GUI เฉยๆ ไม่ทำอะไร
🔧 ระบบสนับสนุน
💬 PendingInputManager
จัดการ chat input แบบ async-safe
ใช้สำหรับตั้งค่า
@r countและ@radiusall radiusผ่านแชทplayer พิมพ์ตัวเลข → input ถูก cancel จาก chat → process บน main thread
📝 LogManager
บันทึก log ทุก action สำคัญลงไฟล์
plugins/ItemSaveLoad/logs/itemsaveload.logformat:
[yyyy-MM-dd HH:mm:ss] <message>actions ที่ถูก log:
/svitsave / update/loitloadManager: load save, delete save, take item, take ender chest item, clear inventory, clear all, copy live, give items
💾 SaveManager
เซฟข้อมูลเป็น YAML ไฟล์ใน
plugins/ItemSaveLoad/saves/<playerName>/<slotName>.ymlเก็บ: inventory (36 slot), armor (4 slot), ender chest (27 slot), level, exp, timestamp
method สำคัญ:
savePlayer()— บันทึกapplyToPlayer()— โหลดใส่ผู้เล่นgetAllSaves()— ดึง save ทั้งหมดพร้อม timestampgetSavesForPlayer()— ดึง save ของผู้เล่นคนเดียวgetSaveData()— อ่าน YAML กลับมาเป็น PlayerSaveDatadeleteSave()— ลบไฟล์ YAML
📁 โครงสร้างไฟล์
src/main/java/com/example/itemsaveload/
├── ItemSaveLoad.java (Main plugin class)
├── commands/
│ ├── SaveItemCommand.java (/svit)
│ ├── LoadItemCommand.java (/loit)
│ └── ManagerItemCommand.java (/manageritem)
├── data/
│ ├── PlayerSaveData.java (Lombok @Getter @Setter)
│ └── SaveEntry.java (Lombok @Getter)
├── inventory/
│ ├── InventoryGUI.java (Abstract base)
│ ├── InventoryButton.java (Builder pattern)
│ ├── InventoryHandler.java (Interface)
│ └── gui/
│ │ ├── GUIListener.java
│ │ └── GUIManager.java
│ └── impl/
│ ├── ManagerMainGUI.java
│ ├── AllSavesGUI.java
│ ├── SaveDetailGUI.java
│ ├── AdvanceGiveGUI.java
│ ├── AdvanceGiveSelectorGUI.java
│ ├── SavePickForGiveGUI.java
│ ├── SaveItemPickGUI.java
│ ├── PlayerListGUI.java
│ ├── PlayerInventoryViewGUI.java
│ ├── PlayerEnderChestViewGUI.java
│ ├── ConfirmClearGUI.java
│ └── ConfirmLoadGUI.java
├── listeners/
│ └── ChatInputListener.java
└── managers/
├── SaveManager.java
├── LogManager.java
└── PendingInputManager.java
src/main/resources/
└── plugin.yml
pom.xml
📋 Commands
คำสั่ง | สิทธิ์ | คำอธิบาย |
|---|---|---|
/svit <name> | OP | บันทึก inventory ปัจจุบันลง slot ที่ตั้งชื่อ |
/loit <name> | OP | โหลด save slot กลับเข้า inventory (มี confirm) |
/manageritem <password> | OP | เปิด Manager Panel (รหัส: hanaomori) |
🔄 เปรียบเทียบ v1.0.0 → v2.0.0
ฟีเจอร์ | v1.0.0 | v2.0.0 |
|---|---|---|
บันทึก inventory | ✅ | ✅ |
โหลด inventory | ✅ | ✅ |
Confirm GUI | ✅ | ✅ (ปรับปรุง) |
Manager Panel | ❌ | ✅ ใหม่ |
ดู saves ทั้งหมด | ❌ | ✅ ใหม่ |
ลบ save | ❌ | ✅ ใหม่ |
Advance Give (@a/@r/@p/@radiusall) | ❌ | ✅ ใหม่ |
Give จาก save slot | ❌ | ✅ ใหม่ |
ดู inventory ผู้เล่น live | ❌ | ✅ ใหม่ |
ดึง item จากผู้เล่น | ❌ | ✅ ใหม่ |
ดู Ender Chest ผู้เล่น | ❌ | ✅ ใหม่ |
ล้างของผู้เล่น (confirm) | ❌ | ✅ ใหม่ |
Copy live inventory | ❌ | ✅ ใหม่ |
Chat input (radius/count) | ❌ | ✅ ใหม่ |
Log ไฟล์ | ✅ | ✅ (ขยาย) |
Pagination GUI | ❌ | ✅ ใหม่ |
Player skull list | ❌ | ✅ ใหม่ |
ใน Manager Panel แก้ คือเขียนทั้งหมดในตัวไม่ใช่แค่ไอเทมเดียว
- ทำให้เซิฟทั้งหมดรวมถึงเวล
เซิฟของหมายถึงทั้งหมด ทั้ง ชุด มือขวา เวล และ Ender Chest
- เหมือนเวลาเซฟ มันไม่หมด ทั้ง ชุด มือขวา เวล และ Ender Chest ไม่มาด้วย
- แก้ไขเรื่องระยะ ปรับแก้ไม่ได้
mode 2 ที่ให้ของคนไม่ใช่แค่ของอันเดียวหมายถึงทั้ง slot เวล ชุด บลาๆ
package com.example.itemsaveload;
import com.example.itemsaveload.commands.LoadItemCommand;
import com.example.itemsaveload.commands.ManagerItemCommand;
import com.example.itemsaveload.commands.SaveItemCommand;
import com.example.itemsaveload.inventory.gui.GUIListener;
import com.example.itemsaveload.inventory.gui.GUIManager;
import com.example.itemsaveload.listeners.ChatInputListener;
import com.example.itemsaveload.managers.LogManager;
import com.example.itemsaveload.managers.PendingInputManager;
import com.example.itemsaveload.managers.SaveManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
public class ItemSaveLoad extends JavaPlugin {
@Getter private SaveManager saveManager;
@Getter private LogManager logManager;
@Getter private GUIManager guiManager;
@Getter private PendingInputManager pendingInputManager;
@Override
public void onEnable() {
this.saveManager = new SaveManager(this);
this.logManager = new LogManager(this);
this.guiManager = new GUIManager();
this.pendingInputManager = new PendingInputManager();
getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
getServer().getPluginManager().registerEvents(new ChatInputListener(this), this);
SaveItemCommand saveCmd = new SaveItemCommand(this);
LoadItemCommand loadCmd = new LoadItemCommand(this);
getCommand("svit").setExecutor(saveCmd);
getCommand("svit").setTabCompleter(saveCmd);
getCommand("loit").setExecutor(loadCmd);
getCommand("loit").setTabCompleter(loadCmd);
getCommand("manageritem").setExecutor(new ManagerItemCommand(this));
getLogger().info("ItemSaveLoad enabled.");
}
@Override
public void onDisable() {
getLogger().info("ItemSaveLoad disabled.");
}
}