suman066940

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)

  1. 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!".

  1. 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! ☀".

  1. 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

  1. 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.

Kodari AI
KodariFeb 8 at 2:58 pm 6,206 (v2)

I’ll create a dual-module utility plugin with bed management and permission-based keep inventory for Minecraft 1.21.x.

BedUtilityPlus
A comprehensive utility plugin featuring intelligent bed management and permission-based keep inventory. The bed system allows automatic respawn point setting, one-player sleep to skip night with weather clearing, and spawn point management. The keep inventory module provides selective inventory protection on death based on configurable permissions. Designed for Paper 1.21.x with full Adventure API support.

Plugin created successfully! Here’s what I’ve implemented:

Module 1: Bed & Sleep System ✅

  • Auto Respawn: Sets respawn point on bed enter with green action bar message

  • One Player Sleep: After 3 seconds of any player sleeping, morning arrives and weather clears

  • Weather Clear: Automatically clears storm and thunder on morning

  • Broadcast: Announces which player skipped the night

  • Bed Break: Clears respawn point when a player’s spawn bed is broken

Module 2: Keep Inventory ✅

  • Permission Check: custom.keepinventory permission required

  • Full Protection: Keeps inventory, XP level, and prevents all drops

  • Confirmation Message: Sends message only to players with permission

Technical Features:

  • Paper 1.21.x compatible

  • Adventure API (Component) for all messages

  • Configurable messages and sleep delay

  • Handles both bed halves correctly

  • Priority event handling to prevent conflicts

All messages are configurable in config.yml and support MiniMessage formatting (colors, gradients, etc.).

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 256
src/main/java/com/bedutility/BedUtilityPlus.java
package com.bedutility;

import com.bedutility.listener.BedListener;
import com.bedutility.listener.DeathListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class BedUtilityPlus extends JavaPlugin {
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        Bukkit.getPluginManager().registerEvents(new BedListener(this), this);
        Bukkit.getPluginManager().registerEvents(new DeathListener(this), this);
        
        getLogger().info("BedUtilityPlus has been enabled!");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("BedUtilityPlus has been disabled!");
    }
}