Manoj kumar Sahni
๐Ÿ“Ž 1 file 13,101 chars
๐Ÿ“„
pasted-code-1791259220413.txt
txt 779 lines
โ–ถ
Create a complete Minecraft Paper plugin called **ElementalBending**.

## CORE CONCEPT

When a player joins the server for the first time, automatically assign them **ONE random bending element**.

Available elements:

1. Fire
2. Water
3. Earth
4. Air
5. Ice
6. Lightning

The player must permanently keep their assigned element unless an administrator resets or changes it.

Do NOT give multiple elements to one player.

The plugin should feel like a Minecraft RPG/progression system inspired by elemental bending, but all abilities must be original.

---

# FIRST JOIN SYSTEM

When a player joins for the first time:

- Randomly select one element.
- Save the element permanently in player data.
- Display a large title:

`&b&lELEMENT AWAKENED`

Then:

`&7You have awakened the power of &e`

- Play an awakening sound.
- Spawn appropriate particles around the player.
- Give the player access to their element's abilities.

Add:

`/element`

to display:

- Current element
- Current level
- XP
- XP required for next level
- Unlocked abilities
- Ability cooldowns

---

# PROGRESSION SYSTEM

Every element has its own progression level.

Starting level:

`Level 1`

Maximum level:

`Level 50`

Players gain **Element XP** by actually using their abilities.

Example:

- Basic ability hit/use โ†’ small XP
- Successful combat ability โ†’ more XP
- Advanced ability โ†’ more XP
- Ultimate ability โ†’ large XP

Prevent XP farming exploits.

For example, repeatedly using an ability without actually affecting anything should provide little or no XP.

When leveling up:

- Play level-up sound.
- Show title.
- Display new level.
- Give particles.
- Unlock abilities at specific levels.

Example progression:

Level 1 โ†’ Basic abilities  
Level 5 โ†’ Ability 2  
Level 10 โ†’ Ability 3  
Level 15 โ†’ Ability 4  
Level 20 โ†’ Ability 5  
Level 25 โ†’ Ability 6  
Level 35 โ†’ Ability 7  
Level 50 โ†’ Ultimate ability

Make these unlock levels configurable in `config.yml`.

---

# POWER SCALING

Abilities should become stronger as the player's element level increases.

Example:

Level 1:

Damage = 4

Level 25:

Damage = 8

Level 50:

Damage = 14

Use configurable scaling rather than hardcoding everything.

Add configuration options for:

- Base damage
- Maximum damage
- Range
- Radius
- Knockback
- Cooldown
- XP reward
- Mana/energy cost if enabled

Do NOT make abilities instantly overpowered.

The strongest abilities should require high levels and have meaningful cooldowns.

---

# ELEMENT 1 โ€” FIRE

Create 8 completely unique fire abilities.

### 1. Fire Bolt
Shoot a fast fire projectile.

### 2. Flame Burst
Create a small explosion of flames around the player.

### 3. Fire Dash
Dash forward while leaving a fire trail.

### 4. Flame Wall
Create a temporary wall of fire.

### 5. Burning Chain
Launch fire toward a target and allow it to jump between nearby enemies.

### 6. Meteor Strike
Call down a powerful fire projectile at the targeted location.

### 7. Inferno
Create a large temporary burning area.

### 8. Phoenix Awakening
Ultimate ability.

Create a powerful fire transformation effect around the player.

Give temporary bonuses such as:

- Fire resistance
- Speed
- Increased fire ability damage
- Flame particles

Use a long cooldown.

---

# ELEMENT 2 โ€” WATER

Create 8 unique water abilities.

### 1. Water Shot
Launch a water projectile.

### 2. Water Whip
Create a long-range water attack.

### 3. Healing Wave
Heal the player or nearby allies.

### 4. Water Shield
Create a temporary defensive water shield.

### 5. Tidal Push
Create a wave that knocks enemies backward.

### 6. Aqua Prison
Trap a target temporarily inside a water-like particle sphere.

### 7. Tsunami
Create a large directional water wave.

### 8. Ocean's Wrath
Ultimate ability.

Create a massive water attack with strong knockback and damage.

---

# ELEMENT 3 โ€” EARTH

Create 8 unique earth abilities.

### 1. Earth Shot
Launch a stone projectile.

### 2. Rock Spike
Create temporary stone spikes from the ground.

### 3. Earth Wall
Create a defensive wall.

### 4. Boulder Throw
Launch a large boulder.

### 5. Ground Slam
Create an area shockwave with knockback.

### 6. Earth Armor
Temporarily increase defense and resistance.

### 7. Earthquake
Create a large area-based earthquake effect.

### 8. Mountain's Wrath
Ultimate ability.

Create a massive earth attack with large area control.

---

# ELEMENT 4 โ€” AIR

Create 8 unique air abilities.

### 1. Air Blast
Launch an invisible/particle-based air projectile.

### 2. Air Dash
Quick directional movement.

### 3. Tornado
Create a small tornado that lifts enemies.

### 4. Wind Wall
Create a defensive wind barrier.

### 5. Cyclone
Spin nearby enemies around the player.

### 6. Vacuum
Pull nearby enemies toward a target point.

### 7. Sky Breaker
Create a powerful downward wind strike.

### 8. Tempest
Ultimate ability.

Create a huge tornado around the player with strong crowd control.

---

# ELEMENT 5 โ€” ICE

Create 8 unique ice abilities.

### 1. Ice Shard
Shoot an ice projectile.

### 2. Frost Nova
Create an ice explosion that slows nearby enemies.

### 3. Ice Wall
Create a temporary ice wall.

### 4. Frozen Ground
Create an area that slows enemies.

### 5. Ice Spear
Launch a powerful ice spear.

### 6. Crystal Prison
Temporarily freeze/trap a target.

### 7. Blizzard
Create a large snow/ice storm area.

### 8. Absolute Zero
Ultimate ability.

Create a powerful freezing area with heavy slow/freeze effects and strong damage.

---

# ELEMENT 6 โ€” LIGHTNING

Create 8 unique lightning abilities.

### 1. Lightning Bolt
Strike a targeted enemy with lightning.

### 2. Electric Dash
Teleport/dash a short distance with lightning particles.

### 3. Chain Lightning
Lightning jumps between nearby enemies.

### 4. Static Field
Create an area that damages enemies periodically.

### 5. Thunder Strike
Call down multiple lightning strikes.

### 6. Lightning Spear
Launch a concentrated lightning projectile.

### 7. Storm Call
Create a temporary lightning storm.

### 8. Zeus Protocol
Ultimate ability.

Create an extremely powerful lightning attack with a long cooldown.

---

# ABILITY CONTROL SYSTEM

Create an easy ability-selection system.

Default:

`Sneak + Right Click`

cycles through abilities.

Display the selected ability using an action bar:

`&bSelected Ability: &fFire Bolt`

Then:

`Right Click`

casts the selected ability.

Make keybind behavior configurable.

Also support commands:

`/element abilities`

`/element select `

`/element info`

`/element level`

`/element reset`

Admin-only:

`/element set  `

`/element give  `

`/element remove `

`/element xp  `

`/element level  `

`/element reload`

---

# COOLDOWN SYSTEM

Every ability must have its own cooldown.

When an ability is on cooldown, show:

`&cAbility is on cooldown! &7(5.2s)`

Use precise decimal cooldowns where appropriate.

Show cooldowns in the action bar.

All cooldowns must be configurable.

---

# PARTICLES & SOUNDS

Every element needs its own visual identity.

Fire:
- Flame
- Lava
- Smoke
- Fire sounds

Water:
- Splash
- Bubble
- Water sounds

Earth:
- Block crack
- Dust
- Stone sounds

Air:
- Cloud
- Sweep
- Wind-like sounds

Ice:
- Snow
- Frost
- Glass/ice sounds

Lightning:
- Electric particles
- Lightning effects
- Thunder sounds

Make particle count configurable for performance.

---

# GUI

Create a professional inventory GUI.

`/element menu`

GUI should show:

Player's element  
Current level  
XP progress  
Unlocked abilities  
Locked abilities  
Cooldown status

Locked abilities should display:

`&cLOCKED`

and:

`&7Unlocks at Level 20`

Unlocked abilities should show:

`&aUNLOCKED`

Clicking an ability should select it.

---

# PLAYER DATA

Store player information persistently.

Save:

- UUID
- Element
- Level
- XP
- Unlocked abilities
- Selected ability
- Statistics
- First join status

Use YAML or SQLite.

Prefer SQLite for reliable persistent storage.

Never lose player progression after server restart.

---

# ADMIN SYSTEM

Permission:

`elemental.admin`

Admin commands:

`/element set  `

`/element random `

`/element reset `

`/element level  `

`/element xp  `

`/element reload`

Add tab completion for all commands.

Validate all arguments and show helpful error messages.

---

# CONFIGURATION

Create a clean `config.yml`.

Everything important must be configurable:

- Elements enabled/disabled
- Maximum level
- XP requirements
- XP rewards
- Ability damage
- Cooldowns
- Range
- Radius
- Knockback
- Particle amounts
- Sounds
- Ability unlock levels
- Messages
- GUI settings
- Database settings
- Anti-exploit settings

Example:

elements:
  fire:
    enabled: true
    max-level: 50

  water:
    enabled: true
    max-level: 50

  earth:
    enabled: true
    max-level: 50

  air:
    enabled: true
    max-level: 50

  ice:
    enabled: true
    max-level: 50

  lightning:
    enabled: true
    max-level: 50

---

# BALANCE

The plugin should be suitable for a survival/SMP server.

Do not make abilities destroy the entire world.

Avoid excessive block modification.

For abilities that temporarily create blocks:

- Store original blocks.
- Restore them safely.
- Never permanently destroy player builds unless explicitly configured.

Add protection against:

- Ability spam
- XP farming
- Excessive entity spawning
- Excessive particles
- Server lag
- Abilities being used through protected regions if possible

---

# PERFORMANCE

The plugin must be optimized.

Avoid unnecessary repeating tasks.

Use scheduled tasks only when required.

Clean up:

- Particles
- Temporary blocks
- Temporary entities
- Cooldowns
- Active ability effects

Do not create a new task for every particle if it can be handled efficiently.

The plugin should support servers with many players.

---

# WORLD COMPATIBILITY

The plugin must work with normal Paper worlds and Multiverse worlds.

Add configuration:

`enabled-worlds:`

Allow administrators to choose which worlds bending works in.

Example:

enabled-worlds:
  - survival
  - lifesteal

If a world is not enabled, abilities should not work there.

---

# DEATH / RESPAWN

Element and progression must NOT reset when a player dies.

Keep:

- Element
- Level
- XP
- Unlocked abilities

after death.

Optionally configure whether temporary buffs disappear on death.

---

# RESOURCE PACK COMPATIBILITY

Do not require a resource pack.

The plugin must work using vanilla Minecraft particles, sounds, entities and effects.

Optionally provide hooks/API for custom resource packs later.

---

# API

Create a clean developer API so other plugins can interact with the bending system.

Example API functions:

`getElement(player)`

`setElement(player, element)`

`getLevel(player)`

`getXP(player)`

`addXP(player, amount)`

`setLevel(player, level)`

`useAbility(player, ability)`

`isOnCooldown(player, ability)`

Allow future plugins to add custom elements and abilities.

---

# PROJECT STRUCTURE

Create a complete Maven Java project.

Use:

- Java
- Paper API
- Maven
- SQLite

Organize code cleanly:

`commands/`

`abilities/`

`elements/`

`listeners/`

`gui/`

`data/`

`progression/`

`utils/`

`config/`

`api/`

Do not put the entire plugin into one Java class.

Use proper object-oriented design.

---

# DELIVERABLE

Generate the COMPLETE working plugin project.

Include:

1. `pom.xml`
2. Main plugin class
3. plugin.yml
4. config.yml
5. All 6 elements
6. All 48 abilities
7. XP system
8. Level system
9. Cooldown system
10. GUI
11. Commands
12. Tab completion
13. SQLite player database
14. Permissions
15. Multiverse/world support
16. Anti-exploit protection
17. Performance optimization
18. API
19. README.md

The plugin must compile without errors using Maven.

Do not provide pseudo-code.

Do not leave TODO sections.

Do not omit ability implementations.

Every ability must actually work in-game.

Use modern Paper API practices and avoid deprecated APIs where possible.

Before finishing, check the project for compilation errors, missing imports, invalid event handling, incorrect API usage, and command registration issues.

The final result should be a ready-to-build `.jar` Minecraft server plugin.
Kodari AI
KodariOct 6 at 4:11 am 4
ElementalBending
A comprehensive Paper plugin that assigns players a random elemental power on first join, featuring six elements (Fire, Water, Earth, Air, Ice, Lightning) with 48 unique abilities, an XP-based progression system from level 1 to 50, configurable cooldowns and damage scaling, a professional inventory GUI for ability selection, SQLite persistent storage, admin commands with tab completion, world compatibility, anti-exploit protection, and a developer API for custom integrations.
  1. Set up the Paper/Maven plugin, configuration, SQLite persistence, element registry, and progression.

  2. Implement the 48 built-in abilities through a shared, configurable casting system with cooldowns and anti-farming XP.

  3. Add join/click controls, GUI, commands, public API, and README.

Created the ElementalBending Maven project with six elements and 48 abilities, SQLite player progression, configurable XP and cooldowns, the ability GUI, commands and tab completion, sneak-right-click selection, and a developer API.

Configuration covers per-element level caps, enabled worlds, ability unlocks and power settings, sounds, particles, and database location. Targets Paper 1.21.4+ and Java 21.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
README.md
Code
19 1,692
src/main/java/com/kodari/elementalbending/ElementalBendingPlugin.java
package com.kodari.elementalbending;

import com.kodari.elementalbending.ability.AbilityCatalog;
import com.kodari.elementalbending.ability.AbilityService;
import com.kodari.elementalbending.ability.CooldownService;
import com.kodari.elementalbending.api.ElementalBendingAPI;
import com.kodari.elementalbending.command.ElementCommand;
import com.kodari.elementalbending.data.PlayerStore;
import com.kodari.elementalbending.element.ElementRegistry;
import com.kodari.elementalbending.listener.BendingListener;
import com.kodari.elementalbending.model.ElementInfo;
import com.kodari.elementalbending.progression.ProgressionService;
import com.kodari.elementalbending.util.Text;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;

import java.sql.SQLException;
import java.util.List;

public final class ElementalBendingPlugin extends JavaPlugin {
    private ElementRegistry elements;
    private AbilityCatalog abilities;
    private CooldownService cooldowns;
    private PlayerStore store;
    private ProgressionService progression;
    private AbilityService abilityService;
    private ElementalBendingAPI api;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        elements = new ElementRegistry();
        abilities = new AbilityCatalog();
        cooldowns = new CooldownService();
        try {
            store = new PlayerStore(this);
        } catch (SQLException exception) {
            getLogger().severe("Could not initialize player database: " + exception.getMessage());
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        progression = new ProgressionService(this, store, elements, abilities);
        abilityService = new AbilityService(this, abilities, elements, progression, cooldowns);
        api = new ElementalBendingAPI(this);
        getServer().getPluginManager().registerEvents(new BendingListener(this), this);
        ElementCommand command = new ElementCommand(this);
        getCommand("element").setExecutor(command);
        getCommand("element").setTabCompleter(command);
        getServer().getScheduler().runTaskTimer(this, () -> {
            if (!getConfig().getBoolean("control.show-cooldowns-in-action-bar", true)) return;
            for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
                var profile = progression.getOrCreate(player.getUniqueId());
                var selected = abilities.get(profile.getSelectedAbility());
                if (selected == null) continue;
                long remaining = abilityService.cooldownRemaining(player.getUniqueId(), selected.id());
                if (remaining > 0) {
                    player.sendActionBar(Text.color("&c" + selected.name() + " &7- &f" + String.format(java.util.Locale.US, "%.1f", remaining / 1000.0) + "s"));
                }
            }
        }, 20L, 20L);
        for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
            progression.getOrCreate(player.getUniqueId());
        }
        getLogger().info("ElementalBending enabled with " + abilities.all().size() + " built-in abilities.");
    }

    @Override
    public void onDisable() {
        if (store != null) {
            for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
                if (progression != null) progression.unload(player.getUniqueId());
            }
            try {
                store.close();
            } catch (SQLException exception) {
                getLogger().warning("Could not close player database cleanly: " + exception.getMessage());
            }
        }
    }

    public boolean isWorldEnabled(String worldName) {
        List<String> enabledWorlds = getConfig().getStringList("enabled-worlds");
        return enabledWorlds.isEmpty() || enabledWorlds.stream().anyMatch(name -> name.equalsIgnoreCase(worldName));
    }

    public void playAwakening(org.bukkit.entity.Player player, ElementInfo element) {
        String configuredSound = getConfig().getString("elements." + element.id() + ".sound", element.sound());
        XSound.matchXSound(configuredSound).ifPresent(sound -> sound.play(player));
        XSound.matchXSound("ENTITY_PLAYER_LEVELUP").ifPresent(sound -> sound.play(player));
    }

    public void playLevelUp(org.bukkit.entity.Player player) {
        XSound.matchXSound("ENTITY_PLAYER_LEVELUP").ifPresent(sound -> sound.play(player));
    }

    public void spawnElementParticles(org.bukkit.entity.Player player, ElementInfo element, int amount) {
        Location location = player.getLocation().add(0, 1, 0);
        int count = Math.min(amount, getConfig().getInt("anti-exploit.maximum-particle-count", 48));
        String particleName = getConfig().getString("elements." + element.id() + ".particle", element.particle());
        XParticle.of(particleName).ifPresent(particle -> player.getWorld().spawnParticle(particle.get(), location, Math.max(1, count)));
    }

    public ElementRegistry getElements() { return elements; }
    public AbilityCatalog getAbilities() { return abilities; }
    public CooldownService getCooldowns() { return cooldowns; }
    public ProgressionService getProgression() { return progression; }
    public AbilityService getAbilityService() { return abilityService; }
    public ElementalBendingAPI getAPI() { return api; }
}