kirat017
๐Ÿ“Ž 1 file 3,335 chars
๐Ÿ“„
pasted-code-1791455139809.txt
txt 94 lines
โ–ถ
Act as an expert Minecraft Spigot/Paper Plugin Developer (Java, API version 1.20+). 

Please write a complete, fully functional Minecraft Spigot/Paper plugin titled "AstralStart" based on the exact specifications below. Ensure the code is clean, well-commented, thread-safe, and uses proper event listeners and scheduler tasks.

---

### ๐Ÿ“Œ Plugin Specifications

#### ๐ŸŒ Plugin & Server Identity
- **Plugin Name:** AstralStart
- **Default SMP Name:** Astral SMP

#### ๐ŸŒ Phases & Mechanics
1. **Starting Phase (Pre-Game)**
   - World Border is locked to a small, configurable size (`borders.starting-size`).
   - World Border center is anchored at the configured location.
   - PvP is completely disabled.
   - Block breaking and placing are disabled for non-OP players.
   - World difficulty is set to `starting-phase.difficulty`.
   - Player default gamemode is set to `starting-phase.gamemode`.
   - Mob spawning can be disabled based on `starting-phase.disable-mob-spawning`.

2. **Transition & Countdown**
   - When `/smpstart start` is triggered:
     - If `start-countdown.enabled` is true, run a titles/sound countdown (3.. 2.. 1.. GO!).
     - Smoothly expand the World Border from `starting-size` to `start-size` over `borders.transition-seconds`.
   
3. **Started Phase (Active SMP)**
   - World difficulty updates to `started-phase.difficulty`.
   - Player gamemode updates to `started-phase.gamemode`.
   - Mob spawning returns to normal.
   - Block breaking and placing are enabled for everyone.
   - **PvP Delay System:**
     - If `pvp-delay.enabled` is true, start a timer for `pvp-delay.seconds`.
     - Display periodic bossbar/actionbar warnings counting down to PvP enable.
     - Automatically enable PvP when the timer hits 0 and broadcast a title message.
     - If `pvp-delay.enabled` is false, enable PvP immediately upon starting.

---

### โŒจ๏ธ Commands & Permissions
Permission node for all commands: `astralstart.admin` (Default: OP / Console only).

- `/smpstart center`
  Sets the center location for spawn and the world border to the sender's current location. Save coordinates & world name in `config.yml`.
- `/smpstart starting`
  Forces the server back into the Starting Phase (resets border to starting size, turns off PvP, disables block breaking).
- `/smpstart starting border `
  Updates `borders.starting-size` in memory and `config.yml`.
- `/smpstart start`
  Initiates the countdown and starts the Astral SMP (expands border, triggers PvP delay timer, enables block building).
- `/smpstart start border `
  Updates `borders.start-size` in memory and `config.yml`. If the SMP is already started, immediately resizes the border over `borders.transition-seconds`.

---

### โš™๏ธ Default `config.yml` Structure

```yaml
smp-name: "Astral SMP"

# Border Center Location
center:
  world: "world"
  x: 0.0
  y: 64.0
  z: 0.0

# Start Countdown (3.. 2.. 1.. GO!)
start-countdown:
  enabled: true
  seconds: 10

# PvP Delay Settings
pvp-delay:
  enabled: true
  seconds: 300 # 5 minutes after start

# World Border Settings
borders:
  starting-size: 50.0
  start-size: 2000.0
  transition-seconds: 15

# Starting Phase Rules
starting-phase:
  difficulty: PEACEFUL
  gamemode: ADVENTURE
  disable-mob-spawning: true

# Started Phase Rules
started-phase:
  difficulty: HARD
  gamemode: SURVIVAL
Kodari AI
KodariOct 8 at 10:29 am 1
AstralStart
AstralStart is a Spigot/Paper plugin that manages a two-phase SMP server experience. It locks the world border to a small starting size with PvP disabled and block protection for non-OP players, then transitions to a full survival experience via a countdown command. The plugin smoothly expands the border over a configurable duration, updates difficulty and gamemode settings, and supports an optional PvP delay timer with bossbar/actionbar warnings. Includes commands to set border center, adjust border sizes, and force phase transitions, all managed through a comprehensive configuration file.
  1. Add the Gradle and plugin descriptors plus the requested default configuration.

  2. Implement phase, border, countdown, PvP-delay, and player-rule management.

  3. Register /smpstart and the event listeners for protection, spawning, PvP, and joins.

Created AstralStart with the requested configuration, /smpstart commands, starting/active phase rules, border transitions, countdown titles and sounds, and delayed PvP warnings. The plugin targets Spigot 1.20.4 and requires Java 17.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 563
src/main/java/com/astralstart/AstralStartPlugin.java
package com.astralstart;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class AstralStartPlugin extends JavaPlugin {
    private SmpManager smpManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        smpManager = new SmpManager(this);
        Bukkit.getPluginManager().registerEvents(new SmpListener(smpManager), this);
        getCommand("smpstart").setExecutor(new SmpStartCommand(smpManager));
        getCommand("smpstart").setTabCompleter(new SmpStartCommand(smpManager));
        smpManager.forceStartingPhase();
    }

    @Override
    public void onDisable() {
        if (smpManager != null) {
            smpManager.shutdown();
        }
    }
}