Desere Fargas
πŸ“Ž 1 file 14,214 chars
πŸ“„
pasted-code-1790287483453.txt
txt 851 lines
β–Ά
Create a complete, production-ready Minecraft Java plugin for my scripted SMP.

## πŸ› οΈ SERVER / DEVELOPMENT

* Minecraft Java **1.21.11**
* Target **Paper 1.21.11**
* Java 21+
* Build the plugin in Java.
* Use clean, organized classes.
* Do NOT put the entire plugin into one giant Java class.
* Include `plugin.yml`.
* Include a fully functional `config.yml`.
* Make the plugin easy to expand with additional custom items later.
* Do NOT require Multiverse-Core.
* Avoid unnecessary external dependencies.
* Use `PersistentDataContainer` / NamespacedKeys to identify custom items rather than relying only on item names.
* Make sure custom items do not accidentally trigger when using normal vanilla versions of the same item.

---

# βš™οΈ FULL CONFIGURATION SYSTEM

Create a complete `config.yml` that allows me to modify **EVERY important setting without editing Java code**.

I want to be able to open the server's plugin folder and edit:

`plugins//config.yml`

Then restart/reload the plugin and have the changes apply.

Every custom item must be configurable.

The config should allow me to change things such as:

* Item material
* Item name
* Item lore
* Ability enabled/disabled
* Cooldown
* Range
* Duration
* Damage
* Knockback
* Particle effects
* Sound effects
* Number of hits required
* Number of items stolen
* Return time
* Area/radius
* Potion effects
* Launch strength
* Any other important value used by that item

Do NOT hardcode values that should reasonably be configurable.

Example structure:

```yaml
items:

  combo:
    enabled: true
    material: NETHERITE_SWORD
    name: "&cCombo"
    cooldown: 30
    hits-required: 4
    stun-duration: 3
    range: 4
    particles: true
    sounds: true

  meteor:
    enabled: true
    material: ELYTRA
    name: "&6Meteor"
    cooldown: 30
    impact-radius: 8
    damage: 10
    knockback: 1.5
    launch-strength: 2.0
    particles: true
    sounds: true

  inventory-box:
    enabled: true
    material: CHEST
    name: "&eInventory Box"
    cooldown: 240
    range: 4
    stolen-items: 1
    return-time: 240

  anchor:
    enabled: true
    material: SHIELD
    name: "&7Anchor"
    cooldown: 30
    duration: 5
```

Do the same for **every item**.

If I change a value in the config, the plugin should actually use the new value.

Do not create fake config options that aren't connected to the code.

---

# ❀️ TWO-LIFE SYSTEM

Every player has exactly **2 lives**.

Store the lives persistently.

Lives must survive:

* Server restarts
* Player disconnects
* Player reconnects
* World changes

New players start with:

**2 lives**

## First death

If the player has 2 lives:

Remove 1 life.

Broadcast:

` has lost a life.`

The message must be **RED**.

Then update their display to:

`Juju ❀️`

Their TAB display should become:

`❀️ Juju`

---

## Final death

If the player has 1 life:

Remove their final life.

Lives become 0.

Broadcast:

` has been eliminated.`

This message must be **RED**.

Then immediately set them to:

`SPECTATOR`

Also broadcast:

` has left the game.`

This message must be **YELLOW**.

The player does NOT actually disconnect.

They remain connected as a spectator.

Their display becomes:

`Juju πŸ’€`

TAB:

`πŸ’€ Juju`

Make all life-system values/messages configurable.

Example:

```yaml
lives:
  starting-lives: 2

  messages:
    lost-life: "&c%player% has lost a life."
    eliminated: "&c%player% has been eliminated."
    left-game: "&e%player% has left the game."

  display:
    two-lives: "❀️❀️"
    one-life: "❀️"
    eliminated: "πŸ’€"

  elimination:
    gamemode: SPECTATOR
```

Do not alter the player's actual Minecraft health.

The hearts are a **life counter**, not health.

---

# πŸ“‹ NAME + TAB DISPLAY

Show lives next to/with the player's name.

Examples:

`Juju ❀️❀️`

`Juju ❀️`

`Juju πŸ’€`

In TAB:

`❀️❀️ Juju`

`❀️ Juju`

`πŸ’€ Juju`

Update these instantly whenever lives change.

Make the format configurable.

---

# πŸŽ’ CUSTOM ITEM SYSTEM

Create the following custom items.

IMPORTANT:

**Every item activates with RIGHT CLICK except Meteor.**

Meteor uses its special movement activation instead.

Every item should have its own cooldown.

Cooldowns must be configurable.

---

# βš”οΈ 1. COMBO

### Item

**Netherite Sword**

### Activation

Normal attack.

The player must hit the **same target 4 times**.

On the 4th successful hit:

* Stun/chain the target for approximately 3 seconds.
* Prevent normal movement.
* Add chain-style particles.
* Play a sound.
* Reset the combo.

If the attacker hits another player, the combo tracking for the previous target should not incorrectly continue.

Allow the hit requirement to be configured.

Example:

```yaml
combo:
  hits-required: 4
  stun-duration: 3
  cooldown: 30
```

---

# β˜„οΈ 2. METEOR

### Item

**Elytra**

### IMPORTANT

Meteor is the ONLY item that does NOT activate through normal right-click.

Use the configured movement/double-jump mechanic.

When activated:

* Launch the player toward the ground.
* Create a meteor-style descent.
* When the player hits the ground, create a large impact.
* Damage nearby players.
* Knock nearby players away.
* Create large impact particles.
* Play impact sounds.

Everything important must be configurable:

```yaml
meteor:
  cooldown: 30
  impact-radius: 8
  damage: 10
  knockback: 1.5
  launch-strength: 2.0
  particles: true
  sounds: true
```

---

# πŸ“¦ 3. INVENTORY BOX

### Item

**Chest**

### Activation

RIGHT CLICK a player within the configured range.

Default range:

**4 blocks**

When activated:

* Open an inventory interface representing the target's inventory.
* Allow the user to take **ONE item**.
* Once one item is taken, the interaction ends.

The stolen item must automatically return to the original owner's inventory after the configured amount of time.

Default:

**4 minutes**

This timer must persist through:

* Relogging
* Server restart
* The thief leaving
* The victim leaving

Store the stolen item and return time persistently.

Configurable:

```yaml
inventory-box:
  range: 4
  stolen-items: 1
  return-time: 240
  cooldown: 240
```

---

# βš“ 4. ANCHOR

### Item

**Shield**

### Activation

RIGHT CLICK.

When activated:

* Give the player complete knockback immunity.
* Default duration: 5 seconds.
* Add an anchor particle effect.
* Play a sound.

Configurable:

```yaml
anchor:
  duration: 5
  cooldown: 30
  particles: true
  sounds: true
```

---

# 🫳 5. SNATCH

### Item

**Netherite Hoe**

### Activation

RIGHT CLICK a player within **5 blocks**.

Steal the item the target is currently holding in their **main hand**.

The item should be transferred to the user.

Configurable:

```yaml
snatch:
  range: 5
  cooldown: 30
```

Do not steal random items for this ability.

It specifically steals the target's currently held main-hand item.

---

# 🎲 6. DICE

### Item

**Tripwire Hook**

### Activation

RIGHT CLICK.

Roll a random number from:

**1–6**

Each number has a different configurable effect.

Default effects:

### 1

Give the user Speed IV for 8 seconds.

### 2

Give the user Strength II for 8 seconds.

### 3

Launch the user upward.

### 4

Heal the user by 4 hearts.

### 5

Randomly teleport the user approximately 10 blocks.

### 6

Create a jackpot effect that launches nearby players within approximately 5 blocks.

Make EVERY outcome configurable.

Example:

```yaml
dice:
  cooldown: 30

  outcomes:
    1:
      type: SPEED
      amplifier: 4
      duration: 8

    2:
      type: STRENGTH
      amplifier: 2
      duration: 8

    3:
      type: LAUNCH
      strength: 2.0

    4:
      type: HEAL
      hearts: 4

    5:
      type: RANDOM_TELEPORT
      distance: 10

    6:
      type: AREA_LAUNCH
      radius: 5
      strength: 2.0
```

Do not hardcode these effects.

---

# 🧱 7. WALL

### Item

**Netherite Shovel**

### Activation

RIGHT CLICK the ground.

Create a **3Γ—3 wall** directly in front of the player.

Make the wall temporary.

Allow the following to be configured:

```yaml
wall:
  width: 3
  height: 3
  duration: 10
  material: OBSIDIAN
  cooldown: 30
```

The wall should not permanently destroy the terrain.

Store the original blocks and restore them when the wall expires.

Do not overwrite important containers if possible.

---

# πŸ’° 8. PICKPOCKET

### Item

**Gold Nugget**

### Activation

RIGHT CLICK a player.

Take **one random item from the target's hotbar**.

The item is transferred to the user.

Configurable:

```yaml
pickpocket:
  range: 4
  items-stolen: 1
  cooldown: 30
```

Make sure it does not steal empty slots.

---

# πŸŒ‘ 9. BLACKOUT

### Item

**Soul Lantern**

### Activation

RIGHT CLICK.

Give nearby players **Blindness**.

The radius and duration must be configurable.

Example:

```yaml
blackout:
  radius: 10
  duration: 5
  cooldown: 30
```

Do not give blindness to the user unless configured to do so.

---

# πŸͺ™ 10. COIN FLIP

### Item

**Gold Nugget**

### Activation

RIGHT CLICK.

Perform a true 50/50 random outcome.

The outcomes must be configurable.

Example:

```yaml
coin-flip:
  cooldown: 30

  heads:
    type: HEAL
    hearts: 1

  tails:
    type: DAMAGE
    hearts: 1
```

Display whether the result was:

`HEADS`

or

`TAILS`

in chat/action bar/visual effects.

Make the two outcomes completely configurable so I can change what happens later.

---

# ⏱️ ACTION-BAR COOLDOWNS

Every item with a cooldown must display its cooldown **above the hotbar** using the Action Bar.

When ready:

`βš“ ANCHOR β€” READY`

When cooling down:

`βš“ ANCHOR β€” 5s`

Then:

`βš“ ANCHOR β€” 4s`

`βš“ ANCHOR β€” 3s`

`βš“ ANCHOR β€” 2s`

`βš“ ANCHOR β€” 1s`

Then:

`βš“ ANCHOR β€” READY`

Requirements:

* Use the Minecraft Action Bar.
* Do NOT send cooldowns through chat.
* Do NOT use titles.
* Update the timer every second.
* Track cooldowns separately for every player.
* Prevent activation while cooling down.
* Start cooldown only after a successful activation.
* Cooldowns must be configurable.
* Switching hotbar slots must not reset cooldowns.
* Dropping/re-picking the item must not reset cooldowns.
* Relogging must not allow players to bypass cooldowns.

If the player is holding a custom item, display that item's cooldown.

If it is ready, display `READY`.

Make the Action Bar format configurable.

---

# 🎁 CUSTOM ITEM GIVING

Create an easy admin system for giving the custom items.

For example:

`/smpitem give  `

Examples:

`/smpitem give Juju combo`

`/smpitem give Juju meteor`

`/smpitem give Juju inventory_box`

`/smpitem give Juju anchor`

`/smpitem give Juju snatch`

`/smpitem give Juju dice`

`/smpitem give Juju wall`

`/smpitem give Juju pickpocket`

`/smpitem give Juju blackout`

`/smpitem give Juju coin_flip`

Only admins/OPs should be able to use this command.

Add tab completion for player names and item names.

---

# πŸ›‘οΈ PERMISSIONS

Create appropriate permissions such as:

`scriptedsmp.admin`

`scriptedsmp.item.give`

Only players with the correct permission should be able to use administrative commands.

---

# πŸ“ FILE STRUCTURE

Organize the project properly.

For example:

```text
src/main/java/
    .../ScriptedSMP.java

    .../commands/
    .../items/
    .../listeners/
    .../lives/
    .../cooldowns/
    .../storage/
    .../utils/

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

Use separate classes where appropriate.

Do NOT make one massive class containing everything.

---

# πŸ’Ύ DATA STORAGE

Persist:

* Player lives
* Pending Inventory Box stolen items
* Return timers
* Any other information that must survive a restart

Use a reliable storage method such as YAML/JSON or another lightweight local storage system.

The plugin should automatically save changes.

Do not lose player lives after a server crash/restart.

---

# πŸ”„ RELOAD / CONFIG

Provide a command such as:

`/scriptedsmp reload`

Permission:

`scriptedsmp.admin`

It should reload the configuration safely.

Do not require a full server restart every time I change a normal configuration value.

If a setting cannot safely be reloaded while the server is running, clearly document that in the plugin.

---

# 🚫 IMPORTANT DESIGN RULES

Do NOT add extra abilities that I did not request.

Do NOT add random potion effects to items unless the item's mechanic specifically calls for them.

Do NOT turn these into ability trees.

Each item should have **one clear gimmick**.

Do NOT require commands for normal item activation.

The custom items should feel like special scripted-SMP items, not generic RPG items.

Make the mechanics responsive and reliable.

Handle edge cases such as:

* Player disconnecting
* Player dying
* Player changing worlds
* Server restarting
* Full inventories
* Empty hotbar slots
* Invalid targets
* Cooldown bypass attempts
* Spectator players
* Players trying to use disabled items
* Items being moved through inventories
* Duplicate custom items

Finally, provide the complete source code for the plugin, including:

* All Java classes
* `plugin.yml`
* `config.yml`
* Any storage files/classes needed
* Commands
* Event listeners
* Custom item creation
* Custom item identification
* Cooldown system
* Action-bar display
* Two-life system
* TAB/name display
* Persistence

The final plugin should compile successfully for **Paper 1.21.11 / Java 21** without requiring me to manually fill in missing code.
Kodari AI
KodariSep 24 at 10:22 pm 2
  1. Create the Gradle/Paper project and full default configuration.

  2. Add persistent lives, cooldown, and inventory-return storage.

  3. Implement the custom items, listeners, GUI, displays, and admin commands.

Created the ScriptedSMP plugin project for Java 21 and Paper 1.21.11, including the configuration, commands, item abilities, two-life displays, and persistent YAML storage for lives, cooldowns, and pending Inventory Box returns. /scriptedsmp reload refreshes config-driven settings and online name/TAB displays.

Custom items are identified by PersistentDataContainer tags, and their settings are in config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
18 1,679
src/main/java/com/scriptedsmp/ScriptedSMP.java
package com.scriptedsmp;

import com.scriptedsmp.abilities.AbilityManager;
import com.scriptedsmp.abilities.InventoryBoxManager;
import com.scriptedsmp.abilities.OutcomeManager;
import com.scriptedsmp.abilities.WallManager;
import com.scriptedsmp.commands.SMPItemCommand;
import com.scriptedsmp.commands.ScriptedSMPCommand;
import com.scriptedsmp.cooldowns.CooldownManager;
import com.scriptedsmp.items.CustomItemManager;
import com.scriptedsmp.lives.LifeManager;
import com.scriptedsmp.listeners.GameplayListener;
import com.scriptedsmp.storage.DataStore;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Objects;

public final class ScriptedSMP extends JavaPlugin {
    private DataStore dataStore;
    private CustomItemManager customItemManager;
    private CooldownManager cooldownManager;
    private InventoryBoxManager inventoryBoxManager;
    private AbilityManager abilityManager;
    private LifeManager lifeManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        dataStore = new DataStore(this);
        customItemManager = new CustomItemManager(this);
        cooldownManager = new CooldownManager(this, dataStore, customItemManager);
        WallManager wallManager = new WallManager(this);
        inventoryBoxManager = new InventoryBoxManager(this, dataStore, cooldownManager);
        OutcomeManager outcomeManager = new OutcomeManager(this);
        abilityManager = new AbilityManager(this, customItemManager, cooldownManager, wallManager, inventoryBoxManager, outcomeManager);
        lifeManager = new LifeManager(this, dataStore);

        Bukkit.getPluginManager().registerEvents(
                new GameplayListener(this, customItemManager, abilityManager, cooldownManager, inventoryBoxManager, lifeManager), this);
        SMPItemCommand itemCommand = new SMPItemCommand(this, customItemManager);
        Objects.requireNonNull(getCommand("smpitem")).setExecutor(itemCommand);
        Objects.requireNonNull(getCommand("smpitem")).setTabCompleter(itemCommand);
        Objects.requireNonNull(getCommand("scriptedsmp")).setExecutor(new ScriptedSMPCommand(this));

        Bukkit.getScheduler().runTaskTimer(this, () -> {
            Bukkit.getOnlinePlayers().forEach(cooldownManager::updateActionBar);
            Bukkit.getOnlinePlayers().forEach(abilityManager::updateMeteorFlight);
        }, 1L, 20L);
    }

    @Override
    public void onDisable() {
        if (dataStore != null) {
            dataStore.save();
        }
    }

    public void reloadSettings() {
        reloadConfig();
        if (lifeManager != null) {
            Bukkit.getOnlinePlayers().forEach(lifeManager::updateDisplay);
        }
    }
}