C

Create a Minecraft plugin with the following requirements:

Plugin Name: SetSpawn Java Version: 21 Minecraft Version: 1.21.11 and below (Spigot/Paper)

Core Features:

  1. Commands:
  • /setspawn → Sets the spawn location to the player's current position

• Permission: Only admins (use permission: setspawn.admin)

  • /spawn → Teleports the player to the saved spawn location
  1. Combat Restriction:
  • If a player is in combat, they cannot use /spawn
  • Combat lasts for 10 seconds after being hit
  • If the player tries to use /spawn during combat, cancel teleport and show a message
  1. Teleport Cooldown:
  • When a player uses /spawn, there is a 5-second delay before teleporting
  • During this time, show a mini-screen countdown message:

Example: "Teleporting to spawn in 5..." "Teleporting to spawn in 4..."

  • If the player moves or takes damage, cancel the teleport
  1. Messages:
  • All messages must use a prefix: [PickleSpawn]
  • The prefix must be configurable in config.yml
  • All messages (combat blocked, countdown, success, cancel, etc.) must be customizable in config.yml
  1. Config:
  • config.yml should include:

• Prefix • All messages • Teleport delay time (default: 5 seconds) • Combat duration (default: 10 seconds)

  1. Data Storage:
  • Save spawn location in a file (config.yml or separate file like spawn.yml)
  • Ensure spawn persists after server restart
  1. Code Requirements:
  • Clean, optimized, and well-structured code
  • Use modern Java (Java 21 features if needed)
  • No unnecessary features, no addons, keep it lightweight

Important:

  • Do NOT include extra systems like INVENTORY GUI, economy, or permissions plugin integration
  • Only implement exactly what is described above

Output:

  • Full plugin source code
  • plugin.yml
  • config.yml
  • Main class and all required classes
Kodari AI
KodariApr 6 at 12:40 pm 8,378 (v2)

I’ll create a lightweight SetSpawn plugin with combat restriction and teleport countdown system.

SetSpawn
A spawn management plugin with combat restrictions and teleport delays. Features include admin spawn point management, player teleportation with countdown, combat tracking system, and movement-based teleport cancellation. All messages and timings are configurable. Spawn location persists across restarts. Clean and optimized for Java 21 and Minecraft 1.21+.

All files created! The SetSpawn plugin is complete with:

Core Features:

  • /setspawn sets spawn (admin only)

  • /spawn teleports with 5-second countdown

  • Combat tracking blocks teleports for 10 seconds

  • Movement or damage cancels teleportation

  • Action bar countdown messages

  • Persistent spawn storage in config.yml

Architecture:

  • ConfigManager - Handles all configuration and messages

  • CombatManager - Tracks combat status with concurrent-safe map

  • TeleportManager - Handles countdown, movement detection, and cancellation

  • Listeners - Combat tracking and teleport cancellation

  • Commands - Simple, focused command executors

The plugin uses Java 21, Lombok for clean code, and action bar for countdown display. All timings and messages are configurable in config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
11 505
src/main/java/com/pickle/setspawn/SetSpawnPlugin.java
package com.pickle.setspawn;

import com.pickle.setspawn.command.SetSpawnCommand;
import com.pickle.setspawn.command.SpawnCommand;
import com.pickle.setspawn.listener.CombatListener;
import com.pickle.setspawn.listener.TeleportListener;
import com.pickle.setspawn.manager.CombatManager;
import com.pickle.setspawn.manager.ConfigManager;
import com.pickle.setspawn.manager.TeleportManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class SetSpawnPlugin extends JavaPlugin {
    
    private ConfigManager configManager;
    private CombatManager combatManager;
    private TeleportManager teleportManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.combatManager = new CombatManager(this);
        this.teleportManager = new TeleportManager(this);
        
        registerCommands();
        registerListeners();
        
        getLogger().info("SetSpawn has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (teleportManager != null) {
            teleportManager.cancelAll();
        }
        
        getLogger().info("SetSpawn has been disabled!");
    }
    
    private void registerCommands() {
        getCommand("setspawn").setExecutor(new SetSpawnCommand(this));
        getCommand("spawn").setExecutor(new SpawnCommand(this));
    }
    
    private void registerListeners() {
        getServer().getPluginManager().registerEvents(new CombatListener(this), this);
        getServer().getPluginManager().registerEvents(new TeleportListener(this), this);
    }
}