C

PvP Toggle Plugin (Paper/Spigot 1.21+) - Full Development Prompt

Create a Minecraft Paper/Spigot plugin for version 1.21+ called EpicPvP.

Overview

The plugin is designed for Survival SMP servers where some players prefer peaceful gameplay while others enjoy PvP combat.

Each player should be able to control their own PvP status independently.

---

Main Features

Personal PvP Toggle System

Every player has their own PvP state.

Commands

/pvp on

  • Enables PvP for the player.
  • The player can attack other PvP-enabled players.
  • Other PvP-enabled players can attack them.

/pvp off

  • Disables PvP for the player.
  • The player cannot attack other players.
  • Other players cannot attack them.

/pvp status

  • Displays the player's current PvP status.
  • Example:

- PvP Status: Enabled - PvP Status: Disabled

---

PvP Rules

Attack Validation

Before damage is applied:

If Attacker PvP = OFF

  • Cancel the attack.
  • Send action bar message:

"You must enable PvP first."

If Victim PvP = OFF

  • Cancel the attack.
  • Send action bar message:

"This player has PvP disabled."

If Both Players PvP = ON

  • Allow combat normally.

---

Title Notifications

Whenever a player changes their PvP state:

PvP Enabled

Title:

PvP Enabled

Subtitle:

You can now fight other players.

PvP Disabled

Title:

PvP Disabled

Subtitle:

You are now protected from PvP.

Only the player executing the command should see these titles.

---

Action Bar Messages

Configurable action bar messages:

Victim Protected

"This player has PvP disabled."

Attacker Protected

"You must enable PvP first."

PvP Enabled

"Your PvP has been enabled."

PvP Disabled

"Your PvP has been disabled."

---

Data Storage

Store player PvP status permanently.

Requirements:

  • Save automatically when a player leaves.
  • Load automatically when a player joins.
  • Status must persist after server restarts.
  • Use UUID-based storage.

Supported storage:

  • YAML by default.
  • Expandable for future database support.

---

Permissions

epicpvp.use

  • Allows use of /pvp commands.

epicpvp.admin

  • Administrative access.

epicpvp.reload

  • Allows plugin reload command.

---

Admin Commands

/pvp reload

Reloads all plugin configuration files.

/pvp set <on/off>

Allows admins to force a player's PvP state.

Examples:

  • /pvp set Steve on
  • /pvp set Steve off

---

Configuration

Fully configurable config.yml.

Options:

  • Titles
  • Messages
  • Action bars
  • Sounds
  • Permission messages

Example:

default-pvp: false

titles: enabled: title: "&aPvP Enabled" subtitle: "&7You can now fight players."

disabled: title: "&cPvP Disabled" subtitle: "&7You are now protected."

messages: victim-protected: "&cThis player has PvP disabled." attacker-protected: "&cYou must enable PvP first."

---

Sounds

Optional sounds when toggling PvP.

Example:

sounds: enabled: ENTITY_PLAYER_LEVELUP disabled: BLOCK_NOTE_BLOCK_BASS

---

Performance

Requirements:

  • Lightweight.
  • Async file saving where possible.
  • No memory leaks.
  • Suitable for large SMP servers.
  • Compatible with Paper

Without any error and bug

Kodari AI
KodariJun 5 at 6:41 pm 1

Creating the EpicPvP plugin — a personal PvP toggle system for Paper 1.21+ SMP servers.

EpicPvP
Personal PvP toggle plugin for Paper 1.21+ SMP servers. Each player controls their own PvP state independently. Prevents PvP between players with mismatched or disabled settings. Features configurable titles, action bars, sounds, and permissions. YAML-based persistent storage with UUID keying. Lightweight, async file saving, admin override commands, and tab completion.&lt;/project_descriptionI'll create the EpicPvP plugin — a personal PvP toggle system for Paper 1.21+ SMP servers.
EpicPvP
Personal PvP toggle plugin for Survival SMP servers. Each player controls their own PvP state independently via /pvp commands. Features configurable titles, action bar messages, sounds and admin commands. YAML-based persistent storage loads on join and saves on quit. Attack validation prevents PvP when either player has it disabled, with clear feedback messages.

Creating all project files:

All files created. Here’s the complete structure:

Plain Text
EpicPvP/
├── build.gradle                          # Gradle build, Paper API 1.21+, Lombok, Java 21
├── src/main/resources/
│   ├── plugin.yml                        # Plugin metadata, commands, permissions
│   └── config.yml                        # Fully configurable titles, messages, sounds
└── src/main/java/com/epicpvp/
    ├── EpicPvP.java                      # Main plugin — init managers, register events
    ├── data/
    │   ├── PvPData.java                  # @Data model: UUID + pvpEnabled
    │   ├── PvPStorage.java              # Interface for expandable storage (future DB)
    │   ├── YamlStorage.java             # YAML implementation, UUID-keyed, async saves
    │   └── PvPManager.java              # In-memory map, load/save delegation
    ├── listeners/
    │   └── PvPListener.java             # Join/quit loading, damage validation
    ├── commands/
    │   └── PvPCommand.java              # /pvp on|off|status|set|reload
    └── utils/
        └── MessageUtil.java             # Color translate, action bar, titles

Key design decisions:

  • Storage interface (PvPStorage) — allows swapping YAML for MySQL/PostgreSQL later without touching managers or commands

  • ConcurrentHashMap for player data — thread-safe, no leaks on async operations

  • Async file saves — YAML writes run off the main thread via runTaskAsynchronously

  • Already-enabled/disabled checks — no redundant title/sound spam if player spams /pvp on

  • UUID-based persistence — survives name changes and server restarts

  • Permissions — epicpvp.use defaults to true (all players), epicpvp.admin and epicpvp.reload default to op

  • Attack validation — checks attacker first (early exit), then victim; action bar messages come from config

  • Title timings — 10 ticks fade-in, 40 stay, 10 fade-out (standard for SMP)

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
11 485
src/main/java/com/epicpvp/EpicPvP.java
package com.epicpvp;

import com.epicpvp.commands.PvPCommand;
import com.epicpvp.data.PvPManager;
import com.epicpvp.data.YamlStorage;
import com.epicpvp.listeners.PvPListener;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class EpicPvP extends JavaPlugin {

    private static EpicPvP instance;
    private PvPManager pvpManager;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();
        reloadConfig();

        pvpManager = new PvPManager(new YamlStorage(this));

        getCommand("pvp").setExecutor(new PvPCommand(this));
        getServer().getPluginManager().registerEvents(new PvPListener(this), this);

        // Load data for any already-online players (plugin reload scenario)
        getServer().getOnlinePlayers().forEach(player -> pvpManager.loadPlayer(player.getUniqueId()));
    }

    @Override
    public void onDisable() {
        if (pvpManager != null) {
            pvpManager.saveAll();
        }
    }

    public static EpicPvP getInstance() {
        return instance;
    }
}