๐
pasted-code-1788268127487.txt
txt
1069 lines
โถ
# ๐ฅ FIRE SWORD PLUGIN โ MINECRAFT 1.21.11 PAPER
Create a complete, production-ready **Minecraft Java Edition Paper plugin specifically for Minecraft 1.21.11**.
This plugin is for my SMP and adds a powerful custom **Fire Sword** with a passive ability, two active abilities, custom particles, sounds, cooldown BossBars, temporary terrain effects, anvil renaming support, and strong SMP-safe protections.
---
# โ๏ธ DEVELOPMENT REQUIREMENTS
* Minecraft Java Edition **1.21.11**
* **Paper 1.21.11**
* Java **21**
* Use modern Paper/Bukkit APIs appropriate for 1.21.11.
* Do NOT write the plugin for an older Minecraft version.
* Do NOT use outdated/deprecated APIs when a modern 1.21.11 API exists.
* Make sure the project compiles cleanly.
* Do not provide pseudocode.
* Provide every required Java class.
* Provide `plugin.yml`.
* Provide `config.yml`.
* Provide the complete Gradle or Maven build configuration.
* The finished project must be ready to compile into a `.jar`.
Use a clean package structure such as:
`com.example.firesword`
---
# โ๏ธ FIRE SWORD
Create a custom weapon based on:
`Material.NETHERITE_SWORD`
Default display name:
**๐ฅ Fire Sword**
Suggested formatting:
`ยงcยงl๐ฅ Fire Sword`
The name should look powerful and fiery.
The sword must have:
* **Fire Aspect V**
* **Unbreakable**
* Custom lore
* Custom PersistentDataContainer identifier
Use a `NamespacedKey` and `PersistentDataContainer` to identify the Fire Sword.
For example:
`firesword:is_fire_sword = true`
## IMPORTANT โ NEVER IDENTIFY THE SWORD BY NAME
The plugin must **NOT** determine whether an item is the Fire Sword by checking its display name.
Do NOT use:
```java
item.getItemMeta().getDisplayName().equals("๐ฅ Fire Sword")
```
The sword must remain functional even if its name is changed.
Use the PDC/custom item data as the authoritative identifier.
This must continue working when the sword is:
* Renamed
* Moved between inventory slots
* Put in the offhand
* Dropped
* Picked up
* Stored in containers
* Moved between players
Normal Netherite Swords must never be treated as Fire Swords.
---
# ๐จ ANVIL RENAMING
The Fire Sword **MUST be fully compatible with normal Minecraft anvils**.
Players must be able to place the Fire Sword inside an anvil and rename it to whatever they want.
Example:
`๐ฅ Fire Sword` โ `Hellbringer`
or:
`๐ฅ Fire Sword` โ `Inferno`
or:
`๐ฅ Fire Sword` โ `My Legendary Sword`
Renaming the sword must **NOT break or remove any functionality**.
The following must remain intact after anvil renaming:
* Fire Aspect V
* Unbreakable status
* Fire Resistance passive
* Inferno Beam
* Inferno Ring
* Cooldown system
* PDC identifier
* Custom item data
* Ability functionality
* Lore
The plugin must preserve the custom PDC when the item passes through an anvil.
Do **not** force the sword back to `๐ฅ Fire Sword` after it has been renamed.
Do **not** continuously reset the item's name from a scheduled task.
The player's chosen name should remain.
## ANVIL LORE
The default ability lore should remain when the player renames the sword.
For example:
**Hellbringer**
`ยง7Forged in the heart of the Nether.`
`ยงcPassive: Inferno's Resistance`
`ยง7Fire Resistance while in your inventory.`
`ยง6Ability I: Inferno Beam`
`ยง7Shift + Left Click`
`ยง4Ability II: Inferno Ring`
`ยง7Shift + Right Click`
The player changing the name must not remove the ability lore.
## ANVIL ENCHANTMENTS
Renaming the sword must preserve:
* Fire Aspect V
* Unbreakable
* Any other legitimate enchantments on the sword
Do not cancel normal anvil renaming.
Use the normal Minecraft anvil mechanics and XP costs.
## ANVIL TEST
The finished plugin must pass this test:
1. Use `/firesword give `.
2. Put the Fire Sword into an anvil.
3. Rename it to `Hellbringer`.
4. Take the renamed sword out.
5. Put it into the player's inventory.
6. Fire Resistance still works.
7. Fire Aspect V still works.
8. Shift + Left Click still activates Inferno Beam.
9. Shift + Right Click still activates Inferno Ring.
10. Cooldowns still work.
11. The item is still recognized as the Fire Sword.
12. The name remains `Hellbringer`.
---
# ๐ ITEM LORE
Give the default Fire Sword clean lore similar to:
**๐ฅ Fire Sword**
`ยง7Forged in the heart of the Nether.`
`ยงcPassive: Inferno's Resistance`
`ยง7Fire Resistance while in your inventory.`
`ยง6Ability I: Inferno Beam`
`ยง7Shift + Left Click`
`ยง4Ability II: Inferno Ring`
`ยง7Shift + Right Click`
Make the lore configurable through `config.yml` if practical.
---
# ๐ก๏ธ PASSIVE โ INFERNO'S RESISTANCE
As long as a player has the Fire Sword anywhere in their inventory, give them:
**Fire Resistance**
Use:
`PotionEffectType.FIRE_RESISTANCE`
The effect should work when the sword is:
* In the hotbar
* In the main inventory
* In the offhand
The player does **not** need to hold the sword.
The passive should remain active continuously while the Fire Sword is present.
When the player no longer has the Fire Sword:
* Remove the Fire Sword's Fire Resistance.
* Do not accidentally remove Fire Resistance supplied by another plugin, potion, beacon, or other source.
Do not constantly stack potion effects every tick.
Use an efficient scheduled check or another optimized system.
---
# โ๏ธ ABILITY I โ INFERNO BEAM
## Activation
Activate using:
**Shift + Left Click**
Only activate when:
* The player has the Fire Sword.
* The player is holding the Fire Sword.
* The player is sneaking.
* The ability is not on cooldown.
Use the appropriate Paper/Bukkit event for Minecraft 1.21.11.
Make sure normal gameplay isn't unnecessarily broken.
---
# โฑ๏ธ COOLDOWN
Cooldown:
**60 seconds**
Use a server-side cooldown manager.
Store cooldowns using player UUIDs.
For example:
```java
Map infernoBeamCooldowns;
```
Do not use Bukkit metadata as the primary cooldown system.
Cooldowns must not be bypassable by:
* Relogging
* Switching worlds
* Switching inventory slots
* Dropping the sword
* Picking the sword back up
Use timestamps to calculate remaining cooldown time.
---
# ๐ฅ PROJECTILE
When activated, create a powerful fiery projectile that travels in the direction the player is looking.
It should look like a:
**massive concentrated beam/fireball of fire**
Do not simply use a vanilla fireball with no customization.
The projectile should:
* Start approximately from the player's hand/body.
* Travel forward.
* Have a visible fire trail.
* Detect blocks.
* Detect players.
* Detect mobs.
* Explode on impact.
* Disappear after reaching a maximum distance.
* Never remain permanently in the world.
A custom scheduled projectile system is acceptable and may be preferable for precise behavior.
---
# โจ PROJECTILE PARTICLES
Create a visually impressive fiery trail using combinations of:
* `Particle.FLAME`
* `Particle.LAVA`
* `Particle.SMOKE`
* `Particle.LARGE_SMOKE`
* `Particle.SOUL_FIRE_FLAME`
* `Particle.EXPLOSION`
* `Particle.FIREWORK`
Add small ember particles trailing behind the projectile.
Optimize particle counts to prevent server lag.
---
# ๐ฅ INFERNO BEAM EXPLOSION
When the projectile hits a:
* Player
* Mob
* Block
create a large fiery explosion.
Damage:
**4 hearts = 8.0 health points**
The damage MUST ignore armor.
Do not use ordinary damage behavior if it causes armor to reduce the damage.
Apply exactly **8.0 damage** while respecting appropriate Minecraft protections such as:
* Invulnerability
* Spectator
* Creative mode where appropriate
* Server/plugin protection systems
---
# ๐ TEMPORARY INFERNO TERRAIN
At the explosion location, create a temporary fiery area containing:
* Fire
* Lava
* Magma Blocks
Default radius:
**4 blocks**
The effect must look like the ground has been temporarily transformed into a Nether inferno.
## CRITICAL SMP WORLD PROTECTION
DO NOT permanently grief the world.
Before changing any block:
1. Check whether it is safe to modify.
2. Save its original state.
3. Change it temporarily.
4. Schedule restoration.
5. Restore the original state.
Avoid modifying:
* Chests
* Shulker Boxes
* Ender Chests
* Furnaces
* Crafting Tables
* Enchanting Tables
* Beds
* Redstone components
* Nether portals
* Player-built containers
* Important structures
Prefer modifying:
* Air
* Replaceable blocks
* Safe natural terrain
If a block cannot safely be modified, skip it.
Do not permanently overwrite player builds.
If restoring a block could destroy something a player placed during the ability, prioritize player-built terrain and avoid damaging it.
---
# ๐ฅ EXPLOSION VISUALS
Create a large fiery particle burst using:
* `Particle.EXPLOSION`
* `Particle.FLAME`
* `Particle.LAVA`
* `Particle.SMOKE`
* `Particle.LARGE_SMOKE`
* `Particle.FIREWORK`
Add:
* Expanding fiery shockwave
* Outward-flying embers
* Rising smoke
* Vertical flame burst
* Magma-style particles
Make the effect last roughly 1โ2 seconds.
---
# ๐ INFERNO BEAM SOUNDS
Use appropriate vanilla Minecraft sounds such as:
* Blaze shoot
* Fire charge
* Lava
* Explosion
* Nether-related sounds
Use separate sounds for:
1. Ability activation
2. Projectile launch
3. Projectile impact
4. Explosion
5. Cooldown ready
Keep the volume powerful but not obnoxious.
---
# ๐ ABILITY II โ INFERNO RING
## Activation
Activate using:
**Shift + Right Click**
Only activate when:
* Player has Fire Sword.
* Player is holding Fire Sword.
* Player is sneaking.
* Ability is not on cooldown.
Cooldown:
**120 seconds**
Duration:
**8 seconds**
Radius:
**6 blocks**
---
# ๐ฅ RING CREATION
Create a large circular ring of fire around the player.
Radius:
**6 blocks**
The ring must follow the player as they move.
It should not remain at the original activation location.
The ring lasts exactly **8 seconds**.
---
# โจ RING PARTICLES
Make the ring extremely impressive.
Create multiple particle layers.
### Outer Ring
Radius:
**6 blocks**
Use:
* Flame
* Lava
* Smoke
### Inner Ring
Radius:
**5.5 blocks**
Use:
* Flame
* Embers
### Clockwise Layer
Create a rotating circle of particles.
Use:
`x = centerX + cos(angle) * radius`
`z = centerZ + sin(angle) * radius`
Increase the angle each update.
### Counter-Clockwise Layer
Create another rotating particle circle moving in the opposite direction.
Use different heights for each layer.
### Rising Fire
Spawn flames rising upward around the perimeter.
### Center Effects
Occasionally spawn embers and flame particles around the owner.
The finished effect should look like a **magical inferno barrier**.
---
# ๐ซ INFERNO RING โ ENEMY TRAP
The 6-block perimeter acts as a fiery barrier.
Track nearby entities.
When a player or mob attempts to cross the perimeter from outside to inside:
1. Knock them toward the center.
2. Set them on fire.
3. Prevent easy traversal through the barrier.
The knockback should feel powerful but fair.
Do not affect the ring owner.
Do not repeatedly knock an entity back every tick.
Give each affected entity a short internal knockback cooldown.
Suggested:
**0.5โ1 second**
The ability should work against:
* Players
* Hostile mobs
* Passive mobs
* Other living entities where appropriate
---
# ๐ฅ ENEMY FIRE
Entities crossing/touching the perimeter should be set on fire.
Default:
**3 seconds**
Make this configurable.
Do not reset the fire timer every tick.
---
# ๐ช RING OWNER BUFF
While the Fire Sword owner is inside their active Inferno Ring, give:
**Speed I**
and
**Strength II**
Use:
`PotionEffectType.SPEED`
`PotionEffectType.STRENGTH`
These effects remain active while the owner is inside the ring.
Remove the plugin's effects when:
* Ring expires
* Player leaves the ring
* Player dies
* Player disconnects
* Ability is cancelled
Do not accidentally remove effects originating from other sources.
Track plugin-applied effects separately.
---
# โฑ๏ธ COOLDOWN BOSSBARS
Create a custom cooldown display using the Paper/Bukkit BossBar API.
Display the cooldown near the bottom of the screen.
## Inferno Beam
Cooldown:
`๐ฅ Inferno Beam โ 47s`
Ready:
`๐ฅ Inferno Beam โ READY`
## Inferno Ring
Cooldown:
`๐ Inferno Ring โ 102s`
Ready:
`๐ Inferno Ring โ READY`
Use an appropriate fiery BossBar color.
For example:
`BarColor.RED`
Use:
`BarStyle.SEGMENTED_10`
or another polished style.
Each player must have their own BossBars.
Do not create duplicate BossBars.
Update the progress smoothly.
When ready:
* Display READY
* Play a subtle fire sound
* Spawn small flame/ember particles around the player
If both abilities are on cooldown, make sure each cooldown is independently visible.
---
# ๐ COOLDOWN BEHAVIOR
Cooldowns must be completely independent.
Inferno Beam:
**60 seconds**
Inferno Ring:
**120 seconds**
Activating one must NOT reset or affect the other.
Cooldowns should be calculated using timestamps.
---
# ๐งน CLEANUP
Properly clean up:
* Scheduled tasks
* BossBars
* Active rings
* Temporary blocks
* Potion effects
* Projectile tasks
* Entity cooldowns
* Player cooldown data
Clean up when:
* Plugin disables
* Player dies
* Player disconnects
* Ring expires
* Projectile hits
* Projectile reaches maximum distance
---
# ๐ก๏ธ ANTI-DUPLICATION
Use:
`PersistentDataContainer`
with:
`NamespacedKey(plugin, "fire_sword")`
Create methods such as:
```java
createFireSword()
isFireSword(ItemStack item)
hasFireSword(Player player)
```
The PDC identifier must survive:
* Anvil renaming
* Inventory movement
* Dropping
* Picking up
* Container storage
Never rely on the display name.
---
# ๐ฅ FIRE/LAVA PROTECTION
The Fire Sword itself must never be destroyed by:
* Fire
* Lava
Make sure dropped Fire Swords cannot burn.
Only protect the Fire Sword item.
Do not interfere with unrelated item entities.
---
# ๐ฆ COMMANDS
Add:
`/firesword give `
Permission:
`firesword.admin`
Add:
`/firesword reload`
Reloads the configuration.
Add:
`/firesword cooldown reset`
Resets both Fire Sword cooldowns.
Add:
`/firesword remove`
Removes Fire Swords where practical.
Commands must support tab completion.
---
# โ๏ธ CONFIG.YML
Create a complete working configuration.
Example:
```yaml
fire-sword:
name: "&c&l๐ฅ Fire Sword"
fire-aspect: 5
unbreakable: true
passive:
fire-resistance: true
inferno-beam:
enabled: true
cooldown: 60
damage: 8.0
armor-ignore: true
explosion-radius: 4.0
projectile-speed: 1.0
max-distance: 40
temporary-block-duration: 5
inferno-ring:
enabled: true
cooldown: 120
duration: 8
radius: 6.0
knockback: 1.5
fire-duration: 3
cooldown-bars:
enabled: true
update-interval: 2
show-ready: true
particles:
enabled: true
quality: high
sounds:
enabled: true
volume: 1.0
world-protection:
enabled: true
protect-containers: true
restore-blocks: true
```
Every setting included in the configuration must actually be used by the plugin.
---
# ๐ SMP PERFORMANCE & WORLD SAFETY
This plugin will run on an SMP, so optimize everything.
Do NOT:
* Spawn thousands of particles every tick.
* Spawn unnecessary entities.
* Create infinite scheduled tasks.
* Leave BossBars behind.
* Leave potion effects behind.
* Leave projectiles behind.
* Create permanent fire.
* Create permanent lava.
* Permanently replace blocks.
* Scan entire worlds unnecessarily.
Only check entities within relevant ability radii.
Cancel scheduled tasks immediately when abilities finish.
---
# ๐ PLUGIN.YML
Create a correct `plugin.yml` for Paper/Minecraft 1.21.11.
Include:
* Plugin name
* Version
* Main class
* Appropriate API version
* Commands
* Permissions
Do not use an API version intended for an older Minecraft version.
---
# ๐งฉ PROJECT STRUCTURE
Use a clean architecture such as:
```text
src/
โโโ main/
โโโ java/
โ โโโ com/example/firesword/
โ โโโ FireSwordPlugin.java
โ โ
โ โโโ item/
โ โ โโโ FireSwordItem.java
โ โ
โ โโโ ability/
โ โ โโโ InfernoBeam.java
โ โ โโโ InfernoRing.java
โ โ
โ โโโ cooldown/
โ โ โโโ CooldownManager.java
โ โ
โ โโโ effects/
โ โ โโโ FireEffects.java
โ โ
โ โโโ listener/
โ โ โโโ AbilityListener.java
โ โ โโโ PlayerListener.java
โ โ โโโ ItemProtectionListener.java
โ โ
โ โโโ command/
โ โ โโโ FireSwordCommand.java
โ โ
โ โโโ util/
โ โโโ FireSwordUtils.java
โ
โโโ resources/
โโโ plugin.yml
โโโ config.yml
```
You may improve the architecture if necessary.
---
# ๐งช FINAL TESTING REQUIREMENTS
Before giving the final source code, verify every feature.
## Item
* Netherite Sword
* Fire Aspect V
* Unbreakable
* Custom PDC
* Cannot burn
* Can be renamed in an anvil
* Renaming does not break functionality
## Passive
* Fire Resistance works anywhere in inventory
* Fire Resistance disappears when sword is removed
* Does not constantly stack effects
## Inferno Beam
* Shift + Left Click works
* 60-second cooldown works
* Projectile follows player's direction
* Fiery trail works
* Projectile disappears correctly
* Explosion works
* Deals exactly 8.0 damage
* Damage ignores armor
* Temporary fire/lava/magma effects work
* Terrain restoration works
* No permanent grief
* No excessive lag
## Inferno Ring
* Shift + Right Click works
* 120-second cooldown works
* Lasts 8 seconds
* Radius is 6 blocks
* Follows player
* Multiple particle layers rotate
* Enemies are knocked toward center
* Enemies are set on fire
* Owner gets Speed I
* Owner gets Strength II
* Effects are removed correctly
* Cannot create infinite rings
## Anvil
Test:
**Fire Sword โ Anvil โ Rename to Hellbringer โ Take out**
Verify:
* Name stays `Hellbringer`
* PDC remains
* Fire Aspect V remains
* Unbreakable remains
* Lore remains
* Passive remains
* Inferno Beam remains functional
* Inferno Ring remains functional
## Cooldowns
* Both cooldowns work independently
* BossBars update correctly
* READY state works
* Cooldowns cannot be bypassed by reconnecting
* BossBars don't duplicate
## Cleanup
* No leaked tasks
* No leaked BossBars
* No lingering potion effects
* No permanent terrain changes
* No lingering projectiles
---
# ๐ฏ FINAL DESIGN GOAL
Make this feel like a **rare legendary SMP weapon**, not a basic plugin.
The visual theme should be:
**๐ฅ INFERNO + NETHER + MAGMA + LEGENDARY FIRE**
The **Inferno Beam** should feel like a devastating concentrated blast of Nether fire.
The **Inferno Ring** should feel like a powerful magical barrier of swirling flames.
The plugin should prioritize:
**Polished visuals โ reliable mechanics โ smooth gameplay โ SMP safety โ performance.**
Return the **complete source code for every file**.
Do not return pseudocode.
Do not leave TODO sections.
Do not omit required classes.
Also provide exact instructions for:
1. Compiling the plugin.
2. Where the compiled `.jar` is located.
3. Which Java version to use.
4. Which Paper 1.21.11 server version to use.
5. Installing the plugin.
6. Using `/firesword give`.
7. Configuring the plugin.
8. Troubleshooting common startup/compilation errors.
Create the Paper 1.21.11 Gradle project, descriptor, and complete configuration.
Implement PDC-backed Fire Sword creation, anvil preservation, inventory passive, and lava/fire item protection.
Implement cooldown BossBars, Inferno Beam, temporary terrain restoration, and Inferno Ring effects.
Register commands, listeners, lifecycle cleanup, and installation/build documentation.
Created the complete Fire Sword Paper plugin project.
Gradle Kotlin build targeting Java 21 and Paper
1.21.11-R0.1-SNAPSHOTPDC-backed, anvil-safe Netherite Fire Sword with configurable lore/enchantments
Inventory-wide Fire Resistance passive and dropped-item fire/lava protection
Inferno Beam projectile, armor-bypassing damage, visuals, temporary protected terrain, and cleanup
Inferno Ring with rotating particle layers, moving perimeter, enemy knockback/fire, and owner buffs
Independent timestamp cooldowns with per-player BossBars and ready effects
/firesword give,reload,cooldown <player> reset, andremovecommands with completionplugin.yml, completeconfig.yml, and build/install troubleshooting inREADME.md
Build with JDK 21 using Gradle; the jar is produced at:
build/libs/FireSword-1.0.0.jar
package com.example.firesword;
import com.example.firesword.ability.InfernoBeam;
import com.example.firesword.ability.InfernoRing;
import com.example.firesword.command.FireSwordCommand;
import com.example.firesword.cooldown.CooldownManager;
import com.example.firesword.effects.FireEffects;
import com.example.firesword.item.FireSwordItem;
import com.example.firesword.listener.AbilityListener;
import com.example.firesword.listener.ItemProtectionListener;
import com.example.firesword.listener.PlayerListener;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
public final class FireSwordPlugin extends JavaPlugin {
private FireSwordItem fireSwordItem;
private FireEffects fireEffects;
private CooldownManager cooldownManager;
private InfernoBeam infernoBeam;
private InfernoRing infernoRing;
@Override
public void onEnable() {
saveDefaultConfig();
fireSwordItem = new FireSwordItem(this);
fireEffects = new FireEffects(this);
cooldownManager = new CooldownManager(this, fireEffects);
infernoRing = new InfernoRing(this, fireEffects);
infernoBeam = new InfernoBeam(this, fireEffects);
getServer().getPluginManager().registerEvents(new AbilityListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
getServer().getPluginManager().registerEvents(new ItemProtectionListener(this), this);
FireSwordCommand command = new FireSwordCommand(this);
PluginCommand fireSwordCommand = getCommand("firesword");
if (fireSwordCommand != null) {
fireSwordCommand.setExecutor(command);
fireSwordCommand.setTabCompleter(command);
}
cooldownManager.start();
}
@Override
public void onDisable() {
if (infernoBeam != null) infernoBeam.shutdown();
if (infernoRing != null) infernoRing.shutdown();
if (cooldownManager != null) cooldownManager.shutdown();
}
public void reloadPluginConfig() {
reloadConfig();
cooldownManager.restart();
}
public FireSwordItem getFireSwordItem() { return fireSwordItem; }
public FireEffects getFireEffects() { return fireEffects; }
public CooldownManager getCooldownManager() { return cooldownManager; }
public InfernoBeam getInfernoBeam() { return infernoBeam; }
public InfernoRing getInfernoRing() { return infernoRing; }
}