Samarth Guptaa
📎 1 file 2,570 chars
📄
pasted-code-1794209713895.txt
txt 35 lines
▶
Act as an expert Minecraft Java plugin developer specializing in the modern Paper API (targeting Paper 1.20+ through modern 2026 Paper releases like Paper 26.2). 

Please write a complete, robust, and well-commented Paper plugin in Java (using Maven or Gradle structure, preferably Gradle with Kotlin DSL or modern Java 17+) that fulfills the following requirements:

### 1. Core World Restrictions
- Allowed Worlds: The plugin functionality must ONLY work if the player is currently in either "survivalspawn" or "survival" (managed via Multiverse-Core).
- If a player attempts to use the commands in any other world (e.g., world_nether, world_the_end, or custom worlds), deny the action and send a clean, configurable message stating that the command cannot be used in this world.

### 2. Commands & Functionality
- Command 1: /spawn
  - Description: Teleports the player to the designated spawn location.
  - World Check: Works anywhere as long as the player is currently standing in either "survivalspawn" or "survival".
  - Unset Check: If the spawn location has not been set yet, send a message to the player: "Spawn Location has not been set." (configurable).
  - Teleportation: Safely teleport the player to the saved coordinates, matching their world, pitch, and yaw.

- Command 2: /setspawn
  - Description: Sets the global spawn location for the server/plugin.
  - Permission: Requires an administrative permission node (e.g., `survialspawn.admin` or `customspawn.setspawn`).
  - World Check: Can be set from either "survivalspawn" or "survival". Save the exact world name, X, Y, Z, yaw, and pitch.
  - Persistence: Save the spawn location persistently to a configuration file (like `config.yml` or a dedicated `spawn.yml`) so it survives server reboots.
  - Confirmation: Send a success message to the admin when the spawn is successfully updated.

### 3. Configuration & Quality Standards
- Include a well-structured `config.yml` that handles:
  - Allowed worlds list (defaulting to "survivalspawn" and "survival").
  - Customizable messages (using MiniMessage or legacy color codes) for:
    - Spawn location not set.
    - Successful teleport to spawn.
    - Spawn successfully updated (/setspawn).
    - World restriction error message.
- Ensure proper error handling, safe player handling, and clean code structure (e.g., separating command executors, config managers, and event listeners if needed).

Please provide:
1. The project file structure (Gradle build file and plugin.yml).
2. All necessary Java classes cleanly separated and fully implemented.
Kodari AI
KodariNov 9 at 7:36 am 1
SurvivalSpawnManager
A Paper plugin managing spawn teleportation with world restrictions. Features /spawn and /setspawn commands that only function in configured allowed worlds (defaulting to survivalspawn and survival). Stores spawn location persistently in config.yml with exact coordinates, yaw, and pitch. Includes configurable MiniMessage-based messages for teleport success, spawn not set, world restriction errors, and admin confirmation. Uses clean separation with dedicated command executors and config manager classes.
  • Create a Gradle Java 17 Paper plugin skeleton and configurable defaults.

  • Add spawn persistence plus separate /spawn and /setspawn command handlers.

  • Register both commands and permissions in plugin.yml.

Created the Gradle Paper plugin with /spawn and permission-protected /setspawn. It restricts both commands to the configured worlds, saves the spawn’s world and exact coordinates/rotation in config.yml, and uses configurable MiniMessage messages.

The project targets the Paper 1.20.4 API with Java 17.

Samarth Guptaa

Now add a Teleporting in 3... then 2,1 action bar message in blue colour and when player tps successfully add in action bar Teleported to spawn in green colour and when player moves left right jump forward or backward say Teleport Cancelled! You moved in yellow colour all in action bar nothing in chat

Kodari AI
KodariNov 9 at 7:43 am 1
  1. Add a cancellable three-second countdown that watches for player movement.

  2. Send countdown, cancellation, and teleport-result messages only through the action bar.

  3. Register and clean up the teleport listener/tasks with the plugin lifecycle.

/spawn now shows Teleporting in 3…, then 2… and 1… in the blue action bar, and teleports after three seconds. Any positional movement—including walking, jumping, or changing worlds—cancels the teleport and shows the yellow cancellation message; successful teleports show the green action-bar confirmation.

These countdown, cancellation, and teleport-result messages are action-bar only. Existing validation messages, such as “spawn not set” and world restrictions, remain chat messages.

Samarth Guptaa

what? Teleporting in 3... 2... 1... doesnt show in blue colour action bar. Wait it doesnt even show! I want it to be shown

Kodari AI
KodariNov 9 at 7:48 am 1

I’ll keep the configured blue messages, but refresh each countdown message every tick for its full second so it stays visible, then teleport after the three-second countdown.

Fixed the countdown: the configured blue action-bar message is now refreshed every tick for each full second—3, 2, then 1—before teleporting. The action bar remains the only place these countdown messages are shown.

Samarth Guptaa

BRO JUST FIX IT Teleporting in 3,2,1 in action bar JUST DOESNT SHOW UP just the Teleporte Successfully shows when i get tped

Kodari AI
KodariNov 9 at 7:53 am 1
  • Send “Teleporting in 3…” immediately when /spawn runs.

  • Refresh the blue countdown in the action bar each tick, switching to 2 and 1 at one-second intervals.

Fixed the countdown path: /spawn now sends the blue 3 to the action bar immediately, then refreshes it every tick and switches to 2 and 1 at one-second intervals before teleporting.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
9 352
src/main/java/com/kodari/survivalspawn/SurvivalSpawnPlugin.java
package com.kodari.survivalspawn;

import com.kodari.survivalspawn.command.SetSpawnCommand;
import com.kodari.survivalspawn.command.SpawnCommand;
import com.kodari.survivalspawn.command.SpawnTeleportManager;
import com.kodari.survivalspawn.config.SpawnConfig;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class SurvivalSpawnPlugin extends JavaPlugin {
    private SpawnConfig spawnConfig;
    private SpawnTeleportManager teleportManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        spawnConfig = new SpawnConfig(this);
        teleportManager = new SpawnTeleportManager(this, spawnConfig);
        getServer().getPluginManager().registerEvents(teleportManager, this);

        PluginCommand spawnCommand = getCommand("spawn");
        PluginCommand setSpawnCommand = getCommand("setspawn");
        if (spawnCommand == null || setSpawnCommand == null) {
            getLogger().severe("Required commands are missing from plugin.yml; disabling plugin.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        spawnCommand.setExecutor(new SpawnCommand(spawnConfig, teleportManager));
        setSpawnCommand.setExecutor(new SetSpawnCommand(spawnConfig));
    }

    @Override
    public void onDisable() {
        if (teleportManager != null) {
            teleportManager.cancelAllTeleports();
        }
    }
}