Expert Java Plugin Developer for Minecraft 1.21.x (Paper/Spigot).
Task: Create a specialized utility plugin with two main modules: Bed Management and Permission-based Keep Inventory.
Technical Requirements:
Version: Minecraft 1.21.x (Use latest Paper/Spigot API).
Text: Use net.kyori.adventure (Component) for all messages.
No Errors: Ensure all events are properly registered and annotations are correct.
Module 1: Bed & Sleep System (No Permission Required)
- Auto Respawn Set:
Event: PlayerBedEnterEvent.
Logic: Jab bhi koi player bed par click kare/soye, uska respawn point (setBedSpawnLocation) usi bed ki location par set ho jana chahiye.
Message: Player ko ek action bar ya chat message bhejo: "&a✔ Your respawn point has been set!".
- One Player Sleep (Raat Skip):
Logic: Agar server par multiple players hain aur koi EK (1) player bed par sota hai, toh 3-4 seconds baad morning ho jani chahiye.
Weather Clear: Morning hote hi setStorm(false) aur setThundering(false) ho jana chahiye taaki mausam saaf ho jaye.
Broadcast: Chat mein announcement ho: "&b%player% &7ne so kar subah kar di aur mausam saaf ho gaya! ☀".
- Bed Break Logic:
Event: BlockBreakEvent.
Logic: Agar koi player wo bed todta hai jahan uska spawn set tha, toh uska respawn point clear ho jana chahiye (Vanilla behavior support).
Module 2: Permission-based Keep Inventory
- Conditional Keep Inventory:
Permission Needed: custom.keepinventory Event: PlayerDeathEvent.
Logic: - Check karo ki kya marne wale player ke paas custom.keepinventory permission hai?
If YES: setKeepInventory(true), getDrops().clear(), setKeepLevel(true), aur setDroppedExp(0). (Isse uska items aur XP nahi girega).
If NO: Normal vanilla death behavior (Items aur XP drop honge).
Message: Marne par player ko message dikhao (sirf agar permission ho): "&a✨ Kyunki aapke paas permission hai, aapki inventory bacha li gayi!".
Final Integration:
Ek Main class banao jo dono modules ko register kare.
Code ekdum clean hona chahiye taaki 1.21.x par bina kisi deprecation warning ke compile ho sake.