A
📎 1 file 2,035 chars
đź“„
pasted-code-1785439385734.txt
txt 1 lines
â–¶
Create a PaperMC plugin for Minecraft 1.21.11 (Java 21) named ShulkerRoom that manages a secure single-player shulker room. The room region, entrance door block locations, and exit detection area must be fully configurable in config.yml. When a player enters the configured room and it is empty, set them as the current occupant and instantly replace the configured entrance blocks with bedrock, locking the room. Only one player may occupy the room at a time; if another player attempts to enter while it is occupied, prevent them from entering (push them back or teleport them outside) and send a configurable message such as "Someone is already using the Shulker Room." The plugin must automatically restore the original door blocks and free the room whenever the occupant leaves by any method, including walking out, standing near the configured inside exit area, /spawn, /home, /warp, /hub, /server, /rtp, Essentials or other plugin teleports, ender pearls, chorus fruit, portals, death, respawn, logout, kick, or disconnect. Do not rely on checking command names; instead detect whether the occupant is no longer inside the configured room region using Paper events such as PlayerMoveEvent, PlayerTeleportEvent, PlayerQuitEvent, PlayerKickEvent, PlayerDeathEvent, and any other necessary events. Save the original door block materials before replacing them with bedrock so they are restored exactly, not replaced with air. On plugin enable, disable, or server restart/crash recovery, always restore the original door blocks and clear the stored occupant so the room can never remain locked. Include admin commands /shulkerroom reload, /shulkerroom open, /shulkerroom close, /shulkerroom reset, and /shulkerroom status with permission shulkerroom.admin. The plugin should use clean OOP architecture with separate manager classes, Maven, Java 21, the latest Paper 1.21.11 API, efficient event-driven logic (no constant polling), configurable messages and sounds, proper logging, and production-quality code with no deprecated APIs.
Kodari AI
KodariJul 30 at 7:25 pm 8
ShulkerRoom
A secure Paper plugin that manages a configurable single-player Shulker Room. It locks configured entrance blocks with bedrock while occupied, restores their exact original block data on exit or recovery, and prevents other players from entering. Event-driven exit detection handles movement, teleports, portals, deaths, disconnects, and other departures. Admin commands provide room status, recovery, manual opening, closing, and configuration reload controls.
A

how to use it tho?

Kodari AI
KodariJul 30 at 7:26 pm 1

1. Install

  1. Build the project with Maven:

    Shell
    mvn clean package
    
  2. Put the generated JAR from target/ into your Paper server’s plugins/ folder.

  3. Start the server once to generate plugins/ShulkerRoom/config.yml.

  4. Stop the server before editing the configuration.


2. Configure the room

Edit plugins/ShulkerRoom/config.yml and set:

  • The room’s full cuboid region (min and max corners).

  • Every block that forms the entrance door.

  • An optional inside exit area.

  • Messages and sounds.

Example structure:

YAML
room:
  region:
    world: world
    min:
      x: 100
      y: 64
      z: 100
    max:
      x: 110
      y: 75
      z: 110

  entrance-blocks:
    - world: world
      x: 105
      y: 65
      z: 100
    - world: world
      x: 105
      y: 66
      z: 100

  inside-exit-area:
    world: world
    min:
      x: 104
      y: 64
      z: 108
    max:
      x: 106
      y: 67
      z: 110

messages:
  room-occupied: "&cSomeone is already using the Shulker Room."
  room-entered: "&aThe Shulker Room has been locked."
  room-released: "&aThe Shulker Room is now available."

sounds:
  enabled: true
  lock: BLOCK_IRON_DOOR_CLOSE
  unlock: BLOCK_IRON_DOOR_OPEN

Important:

  • The configured room region must include the entire interior players are allowed to stand in.

  • Add every entrance block that should turn into bedrock while the room is occupied.

  • The plugin saves the exact original block data before locking the door, then restores it when released. This includes doors, trapdoors, and block orientation/state.

  • The optional inside-exit-area is useful for a designated exit location inside the room. Reaching it releases the room.

After saving, run:

Plain Text
/shulkerroom reload

Or restart the server.


3. Normal player use

Players do not need a command.

  1. A player walks into the configured room.

  2. If it is empty, they become the occupant.

  3. The configured entrance blocks immediately become bedrock.

  4. Other players attempting to enter are blocked and receive the configured occupied message.

  5. When the occupant is no longer inside the configured room region, the original entrance blocks are restored and the room becomes available again.

The room is automatically released if the occupant leaves through normal movement, teleportation, portals, ender pearls, chorus fruit, death, respawn, logout, kick, or a plugin-provided teleport such as /spawn, /home, /warp, /hub, /server, or /rtp.


4. Admin commands

All commands require:

Plain Text
shulkerroom.admin
Command
Purpose
/shulkerroom status
Shows whether the room is open or locked and identifies the current occupant.
/shulkerroom reload
Reloads
config.yml
.
/shulkerroom open
Restores the saved original door blocks and frees the room.
/shulkerroom close
Manually locks the configured entrance blocks with bedrock.
/shulkerroom reset
Emergency recovery: clears the occupant and restores the original door blocks.

For example, if a player gets stuck or you need to forcibly unlock the room:

Plain Text
/shulkerroom reset

5. Restart safety

On plugin startup and shutdown, ShulkerRoom restores the entrance blocks and clears the current occupant. This prevents the room from remaining sealed with bedrock after a restart or reload.

A

i am having total 4 shulker rooms can it manage all them?

Kodari AI
KodariJul 30 at 7:27 pm 1

Not as currently structured—the plugin was designed around one configured Shulker Room.

To manage all 4 independently, it should be changed to use a rooms: config section, with each room having its own:

  • Region bounds

  • Entrance block locations

  • Optional inside exit area

  • Current occupant and locked state

  • Original door-block snapshots

Then players can use different rooms simultaneously, while each individual room remains limited to one occupant.

Example configuration layout:

YAML
rooms:
  room-1:
    region:
      world: world
      min: { x: 100, y: 64, z: 100 }
      max: { x: 110, y: 75, z: 110 }
    entrance-blocks:
      - { world: world, x: 105, y: 65, z: 100 }
      - { world: world, x: 105, y: 66, z: 100 }

  room-2:
    region:
      world: world
      min: { x: 120, y: 64, z: 100 }
      max: { x: 130, y: 75, z: 110 }

  room-3:
    # ...
    
  room-4:
    # ...

Admin commands can also support a room ID, for example:

Plain Text
/shulkerroom status room-2
/shulkerroom open room-3
/shulkerroom reset room-4

I can update it to support any number of independently managed rooms, including your 4-room setup.

A

so players have to open shulkerroom with command? cant it detact player and open and close?

Kodari AI
KodariJul 30 at 7:28 pm 1

Players do not need to use a command.

The intended behavior is automatic:

  1. Player walks into a configured Shulker Room region.

  2. If that room is empty, it detects them as the occupant and locks its configured entrance blocks with bedrock.

  3. If the room is already occupied, another player is prevented from entering.

  4. When the occupant leaves the configured room region—walking out, teleporting, dying, disconnecting, using an ender pearl/chorus fruit/portal, etc.—the room automatically unlocks and restores the original entrance blocks.

/shulkerroom open, /close, and /reset are admin emergency/management commands only.

For four rooms, each room would independently detect players this way; four different players could use four different rooms at the same time.

A

make it for 4 rooms.

Cordinates of all rooms are: Room 1) -4 52 39 , -7 48 39 Room 2) -22 51 18 , -21 48 16 Room 3) 12 51 16, 12 48 18 Room 4) -6 51 -4 , -5 48 -4

make it properly if there will be any kind of bug i will fuck your ass

4 images attached
Kodari AI
KodariJul 30 at 7:40 pm 11
  1. Convert the room model from one global room to independently managed named rooms.

  2. Apply your four coordinate pairs as the configured room regions.

  3. Preserve event-driven entry, exit, teleport, death, and disconnect handling per room.

  4. Update recovery, admin commands, and status reporting for individual rooms.

Implemented independent handling for room-1 through room-4 using the region coordinates you supplied.

  • Players enter and lock rooms automatically—no player command required.

  • Each room has its own occupant, lock state, recovery backup, and admin status.

  • Four players can use four separate rooms simultaneously.

  • /shulkerroom status [room-id], /open [room-id], /close [room-id], and /reset [room-id] now support individual rooms; omit the room ID to operate/report on all rooms where applicable.

  • Movement, teleports, death, logout, kicks, portals, pearls, and other departures release only the affected room.

One required detail cannot be safely guessed from screenshots or room-region corners: the exact blocks that form each entrance door. I left each doors: [] empty intentionally so the plugin never replaces the wrong wall, floor, or blocks inside a room.

For each room, add every block that must become bedrock while occupied:

YAML
rooms:
  room-1:
    doors:
      - world: world
        x: <door-block-x>
        y: <door-block-y>
        z: <door-block-z>
      - world: world
        x: <second-door-block-x>
        y: <second-door-block-y>
        z: <second-door-block-z>

Send the door-block coordinates for each of the four entrances—or two opposite corners for each rectangular doorway—and I can populate them precisely. Until doors is configured, the plugin deliberately disables protection rather than risking locking the wrong blocks.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
13 1,174
src/main/java/com/kodari/shulkerroom/ShulkerRoomPlugin.java
package com.kodari.shulkerroom;

import com.kodari.shulkerroom.command.ShulkerRoomCommand;
import com.kodari.shulkerroom.config.ConfigManager;
import com.kodari.shulkerroom.listener.RoomListener;
import com.kodari.shulkerroom.manager.DoorManager;
import com.kodari.shulkerroom.manager.RoomManager;
import com.kodari.shulkerroom.message.MessageService;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class ShulkerRoomPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private MessageService messageService;
    private DoorManager doorManager;
    private RoomManager roomManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        this.configManager = new ConfigManager(this);
        this.messageService = new MessageService(configManager);
        this.doorManager = new DoorManager(this);
        this.roomManager = new RoomManager(this, configManager, doorManager, messageService);

        doorManager.recover();

        getServer().getPluginManager().registerEvents(
                new RoomListener(roomManager, doorManager),
                this
        );

        PluginCommand command = getCommand("shulkerroom");
        if (command == null) {
            getLogger().severe("Unable to register /shulkerroom from plugin.yml.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        ShulkerRoomCommand executor = new ShulkerRoomCommand(roomManager, configManager, messageService);
        command.setExecutor(executor);
        command.setTabCompleter(executor);

        if (!configManager.isValid()) {
            getLogger().warning("Shulker Room protection is disabled until every room has valid region and door-block coordinates.");
        } else {
            getLogger().info("ShulkerRoom enabled successfully with " + configManager.getRooms().size() + " rooms.");
        }
    }

    @Override
    public void onDisable() {
        if (roomManager != null) {
            roomManager.shutdown();
        } else if (doorManager != null) {
            doorManager.restoreAll();
        }
    }
}