Anas Works
📎 1 file 9,958 chars
📄
pasted-code-1789903326098.txt
txt 605 lines
▶
You are an expert Minecraft Paper plugin developer.

Create a professional, lightweight Minecraft Paper plugin called **DeathCurse** for a Death Curse SMP.

The plugin should feel polished and professional for a YouTube SMP, but DO NOT over-engineer it.

## PLATFORM

* Paper 1.21.x
* Java 21
* Maven or Gradle
* No economy plugin
* No database required; use simple UUID-based YAML/JSON player data
* Fully configurable
* Clean modular code
* Must compile successfully
* No TODOs, placeholder methods, fake features, or incomplete code

---

# CORE GAMEPLAY

When a player dies:

1. Detect the death.
2. Increase their death counter.
3. Give them one random enabled curse.
4. Do not give a curse they already have.
5. Save the curse permanently.
6. Apply the curse immediately after respawn.
7. Show a professional curse announcement.
8. Play appropriate sounds and particles.

Maximum active curses:

```yaml
settings:
  max-curses: 5
```

If the player already has the maximum number of curses, do not give another curse.

---

# CURSES

Implement these 6 curses:

### 1. BROKEN LEGS

* Player cannot sprint.
* Use PlayerToggleSprintEvent.
* Display name: "Broken Legs"
* Icon: LEATHER_BOOTS

### 2. SHIELD CURSE

* Player cannot use/raise a shield.
* Cancel appropriate interaction/blocking behavior.
* Icon: SHIELD

### 3. LIFE DRAIN

* Permanently reduce maximum health by 1 heart.
* Default reduction: 2.0 health points.
* Properly restore the health when the curse is removed.
* Never permanently corrupt the player's normal max health.
* Icon: RED_DYE or another suitable vanilla item.

### 4. NETHER CURSE

* Player cannot enter the Nether through a portal.
* Cancel portal entry.
* Send a clear message explaining that the curse prevents Nether access.
* Icon: NETHERRACK

### 5. WEAK ARMS

* Reduce melee attack damage by 20%.
* Make the multiplier configurable.
* Icon: IRON_SWORD

### 6. LOST POSSESSION

* When the player receives this curse, mark it as active.
* On their next death, remove one random non-protected item from their inventory.
* Never remove Curse Fragments or Curse Breakers.
* After triggering successfully, the curse should remain active unless manually removed.
* Icon: CHEST

---

# PROFESSIONAL CURSE ANNOUNCEMENT

This is very important.

When a player receives a curse, show a cinematic title/subtitle to THAT player.

Example:

Title:

```text
☠ YOU HAVE BEEN CURSED
```

Subtitle:

```text
BROKEN LEGS
```

Then show the description below through an additional title/action-bar/message if appropriate:

```text
You can no longer sprint.
```

The announcement should remain visible for several seconds.

Default:

```yaml
curse-announcement:
  enabled: true
  fade-in: 10
  stay: 100
  fade-out: 20
```

Use Minecraft title timing correctly.

The announcement should feel dramatic, clean, and readable.

Play:

* Low horror/cursed sound
* Small particle effect
* Optional configurable sound

Do not spam the player with repeated messages.

---

# SERVER-WIDE CURSE ANNOUNCEMENT

When someone receives a curse, all online players should receive a clean server announcement.

Example:

```text
☠ ─────────────────────

        PLAYER CURSED

Anas has received:

☠ Broken Legs

───────────────────── ☠
```

Do NOT use huge spammy chat messages.

Make the announcement configurable in `messages.yml`.

Allow placeholders:

```text
%player%
%curse%
%curse_description%
%death_count%
```

---

# DEATH ANNOUNCEMENT

When a player dies, keep the normal Minecraft death message.

Do not replace the normal death message unnecessarily.

After the player respawns and receives the curse, show the curse announcement.

This prevents the chat from becoming confusing.

---

# CURSE GUI

Command:

```text
/curse
```

Open a professional inventory GUI.

Title:

```text
☠ YOUR CURSES
```

Show:

* Active curses
* Curse icons
* Curse descriptions
* Death count
* Active curse count
* Curse Fragment count

Example:

```text
☠ YOUR CURSES

[🏃] Broken Legs
     Sprint Disabled

[🛡] Shield Curse
     Shield Disabled

[❤️] Life Drain
     -1 Heart

Deaths: 4
Active Curses: 3/5
Fragments: 3/5
```

Clicking a curse should show detailed information.

Do not allow normal players to remove curses directly from this GUI.

---

# CURSE FRAGMENTS

Create a custom item:

Name:

```text
🔮 Curse Fragment
```

Use a suitable vanilla material such as AMETHYST_SHARD.

IMPORTANT:

Use PersistentDataContainer / NamespacedKey to identify the item.

Do NOT identify custom items only by their display name.

Curse Fragments should NOT randomly spawn in the world.

For this simple version, fragments can be given through:

* Admin command
* Configurable future reward system

Command:

```text
/curse fragments  give 
```

Show fragment progress in the `/curse` GUI.

---

# CURSE BREAKER

Create a custom item:

```text
🧿 Curse Breaker
```

Use NETHER_STAR or another suitable material.

Identify it with PersistentDataContainer.

The Curse Breaker must NOT randomly spawn in the world.

Default crafting requirement:

```text
5 Curse Fragments = 1 Curse Breaker
```

Do not use a normal crafting table.

Create a simple custom Curse Breaker crafting/confirmation system.

Make the fragment requirement configurable:

```yaml
curse-breaker:
  fragments-required: 5
```

---

# CURSE BREAKER GUI

When the player uses a Curse Breaker:

Open:

```text
🧿 CURSE BREAKER
```

Show all active curses.

Example:

```text
[🏃 Broken Legs]
[🛡 Shield Curse]
[❤️ Life Drain]
```

Click a curse.

Open confirmation:

```text
Remove Broken Legs?

[✔ CONFIRM]
[✖ CANCEL]
```

If confirmed:

* Remove exactly one Curse Breaker
* Remove selected curse
* Remove its effects
* Update saved data
* Play sound
* Spawn small particles
* Show title:

```text
🧿 CURSE REMOVED
```

Subtitle:

```text
Broken Legs
```

Do not consume the Curse Breaker if the player cancels.

Prevent shift-click, drag, double-click, and inventory exploits.

---

# COMMANDS

Player:

```text
/curse
/curse list
/curse info 
```

Admin:

```text
/curse give  
/curse remove  
/curse clear 
/curse fragments  give 
/curse fragments  set 
/curse breaker 
/curse reload
```

Add proper tab completion.

---

# PERMISSIONS

```text
deathcurse.use
deathcurse.admin
deathcurse.give
deathcurse.remove
deathcurse.fragments
deathcurse.breaker
deathcurse.reload
```

Normal players must not be able to use admin commands.

---

# PLAYER DATA

Store data using UUID.

Save:

* Active curses
* Death count
* Curse Fragment count

Data must survive:

* Server restart
* Player logout/login

Do not store data by username.

---

# CONFIGURATION

Create a clean `config.yml`.

Example:

```yaml
settings:
  max-curses: 5
  curse-on-death: true

curse-announcement:
  enabled: true
  fade-in: 10
  stay: 100
  fade-out: 20

curse-breaker:
  fragments-required: 5

curses:

  broken-legs:
    enabled: true

  shield-curse:
    enabled: true

  life-drain:
    enabled: true
    health-reduction: 2.0

  nether-curse:
    enabled: true

  weak-arms:
    enabled: true
    damage-multiplier: 0.80

  lost-possession:
    enabled: true
```

Create a separate `messages.yml` so all announcements can be customized.

---

# MESSAGES

Include customizable messages for:

* Curse received
* Curse removed
* No curses
* Maximum curses reached
* Fragment received
* Fragment progress
* Not enough fragments
* Curse Breaker created
* Nether blocked
* Permission denied
* Player not found
* Invalid curse

Support color formatting and placeholders.

---

# VISUAL POLISH

Make the plugin feel professional without adding unnecessary mechanics.

Use:

* Titles
* Subtitles
* Action bars
* Sounds
* Small particle effects
* Clean GUI
* Consistent colors
* Consistent curse icons

Do not constantly spam particles or sounds.

---

# IMPORTANT SECURITY

Prevent:

* Curse Breaker duplication
* Curse Fragment duplication
* GUI item stealing
* Shift-click exploits
* Inventory drag exploits
* Death duplication
* Double death-event processing
* Unauthorized curse removal
* Invalid custom item creation

Use PersistentDataContainer for all custom items.

---

# CODE STRUCTURE

Use a clean structure such as:

```text
src/main/java/
  .../DeathCursePlugin.java

  commands/
  curses/
  gui/
  items/
  data/
  listeners/
  managers/
  utilities/

src/main/resources/
  plugin.yml
  config.yml
  messages.yml
```

Use separate classes for each curse where practical.

Do not put the entire plugin in one huge Java class.

---

# FINAL REQUIREMENTS

Before finishing, verify the complete flow:

PLAYER DIES
↓
DEATH COUNT INCREASES
↓
RANDOM CURSE SELECTED
↓
CURSE ANNOUNCEMENT APPEARS
↓
CURSE STAYS ACTIVE
↓
PLAYER CAN CHECK IT WITH /curse
↓
PLAYER COLLECTS CURSE FRAGMENTS
↓
PLAYER GETS CURSE BREAKER
↓
PLAYER OPENS BREAKER GUI
↓
SELECTS CURSE
↓
CONFIRMS
↓
CURSE IS REMOVED
↓
REMOVAL ANNOUNCEMENT APPEARS

The final project must compile successfully with Java 21 and Paper 1.21.x.

Generate the COMPLETE project files, not snippets.

Do not add unnecessary systems such as:

* Custom bosses
* Trials
* Shrines
* Curse Master
* Complicated economies
* External databases
* Random world events

Keep the gameplay simple, but make the UI, announcements, effects, configuration, and code quality professional.
Kodari AI
KodariSep 20 at 11:40 am 3
DeathCurse
A professional Minecraft Paper plugin for a Death Curse SMP. When players die, they receive random permanent curses that alter gameplay, such as Broken Legs preventing sprinting, Life Drain reducing max health, and Nether Curse blocking portal entry. Features a cinematic curse announcement system with titles, sounds, and particles, plus a server-wide broadcast. Includes a curse management GUI showing active curses, death count, and Curse Fragment progress. Players collect Curse Fragments to craft Curse Breakers, which allow removing curses through a confirmation GUI. Fully configurable via config.yml and messages.yml, with UUID-based player data storage and comprehensive admin commands for curse management.
  1. Create the Gradle/Paper project and resource configuration.

  2. Add UUID-backed player data, curse logic, item identity, and announcements.

  3. Add GUI flows for curse viewing and Curse Breaker confirmation.

  4. Add player/admin commands, tab completion, listeners, and plugin metadata.

The project structure and core flow are in place. I’m correcting the cross-version particle import and the zero-amount fragment edge case before finishing the remaining consistency pass.Created the complete DeathCurse Paper 1.21.x plugin project with:

  • Java 21 Gradle setup and Paper API dependency

  • Six configurable curses with persistent UUID-based YAML data

  • Death tracking and random curse assignment

  • Curse effects:

    • Broken Legs

    • Shield Curse

    • Life Drain

    • Nether Curse

    • Weak Arms

    • Lost Possession

  • PersistentDataContainer-based Curse Fragments and Curse Breakers

  • Curse Breaker fragment conversion and removal confirmation flow

  • Protected GUI inventories with drag, shift-click, and item-stealing prevention

  • /curse GUI with active curses, death count, fragments, and details

  • Player and admin commands with tab completion

  • Configurable messages, titles, sounds, particles, limits, and curse settings

  • Login, logout, respawn, portal, combat, sprint, interaction, and death listeners

  • Server-wide curse announcements and personal title/action-bar effects

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
21 1,379
src/main/java/com/kodari/deathcurse/DeathCursePlugin.java
package com.kodari.deathcurse;

import com.kodari.deathcurse.commands.CurseCommand;
import com.kodari.deathcurse.data.DataManager;
import com.kodari.deathcurse.data.PlayerData;
import com.kodari.deathcurse.curses.CurseManager;
import com.kodari.deathcurse.curses.CurseType;
import com.kodari.deathcurse.gui.GUIManager;
import com.kodari.deathcurse.items.ItemManager;
import com.kodari.deathcurse.listeners.CurseListener;
import com.kodari.deathcurse.listeners.DeathListener;
import com.kodari.deathcurse.listeners.GUIListener;
import com.kodari.deathcurse.util.TextUtil;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import java.io.File;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.configuration.file.YamlConfiguration;

public final class DeathCursePlugin extends JavaPlugin {
    private DataManager dataManager;
    private ItemManager itemManager;
    private CurseManager curseManager;
    private GUIManager guiManager;
    private YamlConfiguration messages;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("messages.yml", false);
        messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml"));

        dataManager = new DataManager(this);
        itemManager = new ItemManager(this);
        curseManager = new CurseManager(this, dataManager, itemManager);
        guiManager = new GUIManager(this);

        getServer().getPluginManager().registerEvents(new DeathListener(this), this);
        getServer().getPluginManager().registerEvents(new CurseListener(this), this);
        getServer().getPluginManager().registerEvents(new GUIListener(this), this);

        CurseCommand command = new CurseCommand(this);
        getCommand("curse").setExecutor(command);
        getCommand("curse").setTabCompleter(command);
    }

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

    public String message(String path, Map<String, String> placeholders) {
        String value = messages.getString(path, "");
        placeholders = new java.util.HashMap<>(placeholders);
        placeholders.putIfAbsent("prefix", messages.getString("prefix", ""));
        return TextUtil.color(TextUtil.replace(value, placeholders));
    }

    public void send(Player player, String path, Map<String, String> placeholders) {
        String value = message(path, placeholders);
        if (!value.isEmpty()) {
            player.sendMessage(value);
        }
    }

    public void announceCurse(Player player, CurseType type) {
        PlayerData data = dataManager.getOrLoad(player.getUniqueId());
        Map<String, String> placeholders = Map.of(
                "player", player.getName(),
                "curse", TextUtil.color(type.displayName()),
                "curse_description", TextUtil.color(type.description()),
                "death_count", String.valueOf(data.getDeaths())
        );
        if (getConfig().getBoolean("curse-announcement.enabled", true)) {
            player.sendTitle(
                    message("curse-title", placeholders),
                    message("curse-subtitle", placeholders),
                    getConfig().getInt("curse-announcement.fade-in", 10),
                    getConfig().getInt("curse-announcement.stay", 100),
                    getConfig().getInt("curse-announcement.fade-out", 20)
            );
            player.sendActionBar(message("curse-description", placeholders));
            XSound.matchXSound(getConfig().getString("curse-announcement.sound", "BLOCK_RESPAWN_ANCHOR_DEPLETE"))
                    .ifPresent(sound -> sound.play(player));
            XParticle.of(getConfig().getString("curse-announcement.particle", "SOUL_FIRE_FLAME"))
                    .ifPresent(particle -> {
                        Location location = player.getLocation().add(0, 1, 0);
                        player.getWorld().spawnParticle(particle.get(), location, 18, 0.35, 0.5, 0.35, 0.02);
                    });
        }
        Bukkit.broadcastMessage(message("server-curse-announcement", placeholders));
    }

    public void announceRemoval(Player player, CurseType type) {
        Map<String, String> placeholders = Map.of("curse", TextUtil.color(type.displayName()));
        player.sendTitle(message("removal-title", placeholders), message("removal-subtitle", placeholders), 8, 60, 12);
        send(player, "curse-removed", placeholders);
        XSound.matchXSound("BLOCK_BEACON_DEACTIVATE").ifPresent(sound -> sound.play(player));
        XParticle.of("HAPPY_VILLAGER").ifPresent(particle ->
                player.getWorld().spawnParticle(particle.get(), player.getLocation().add(0, 1, 0), 12, 0.3, 0.4, 0.3, 0.02));
    }

    public void reloadMessages() {
        messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml"));
    }

    public DataManager getDataManager() { return dataManager; }
    public ItemManager getItemManager() { return itemManager; }
    public CurseManager getCurseManager() { return curseManager; }
    public GUIManager getGuiManager() { return guiManager; }
}