📄
pasted-code-1780289651988.txt
txt
124 lines
▶
You are an expert Minecraft datapack/plugin developer. Create a fully functional custom Netherite Sword with the following exact specifications. Do not simplify, omit, or alter any requirements.
## Custom Weapon
* A custom Netherite Sword with a unique name and lore.
* The sword must be obtainable ONLY through commands by players with Operator (OP) permissions.
* It must not be craftable, obtainable through survival gameplay, loot tables, villagers, structures, or any other method.
## Configuration System
Create a config file that allows server owners to modify the following values without recompiling or editing the source code:
* Cooldown duration
* Damage amount
* Projectile range
* Explosion delay
* Action Bar cooldown messages
* Ready message
* Custom sword name
* Sword lore
* Projectile speed
* Sound effects
* Particle effects
* Permission node required to obtain/use the sword
The plugin/datapack must load all values from the configuration and use sensible defaults.
## Special Ability: TNT Launcher
When a player right-clicks while holding the sword:
* Launch a TNT block projectile from the player's position.
* The projectile must move smoothly and naturally through the air like an arrow.
* It should visually appear as a flying/sliding TNT block.
* The movement must be fluid and professional-looking, not based on slow or obvious teleportation.
* The projectile travels in the direction the player is looking.
* The projectile has a maximum range of exactly 13 blocks by default.
* The range must be configurable through the config file.
* Range is measured from the original firing position.
* Once the projectile reaches its configured range, it must immediately disappear.
## Direct Hit Effects
When the projectile hits a player or mob:
1. The TNT projectile immediately disappears.
2. A countdown begins.
3. The countdown is 2 seconds by default.
4. The countdown duration must be configurable.
5. After the countdown:
* A TNT explosion effect and sound play.
* The explosion is cosmetic only.
* No blocks are damaged, destroyed, moved, or modified.
* No fire is created.
* No terrain damage occurs.
6. The target receives exactly 2 true hearts (4 health points) of damage by default.
7. The damage amount must be configurable.
8. Damage must completely bypass:
* Armor
* Armor Toughness
* Protection Enchantments
* Resistance Effects
* Absorption
* Shields
* Any normal damage reduction mechanics
## Missed Shot Behavior
If the projectile does not hit a target before reaching its maximum range:
* The projectile automatically disappears.
* No TNT block remains in the world.
* No explosion occurs.
* No entities remain behind.
## Cooldown System
* The ability has a default cooldown of 45 seconds.
* The cooldown duration must be configurable.
* Cooldowns must be tracked separately for each player.
* Players cannot fire again until the cooldown expires.
### Action Bar Display
While the sword is held:
* Show the remaining cooldown in the Action Bar.
* Update the display in real time.
* The cooldown message must be configurable.
* Support placeholders such as:
* {seconds}
* {cooldown}
* {remaining}
Example:
* TNT Launcher Cooldown: {seconds}s
When ready:
* Display a configurable ready message.
* Example:
* TNT Launcher Ready
## Performance Requirements
* Must be multiplayer compatible.
* Must be optimized to minimize lag.
* Must properly clean up all temporary entities and data.
* No projectile, TNT block, marker, armor stand, or helper entity should remain after use.
* The system should be reliable and production-quality.
## Example Config
Provide a complete example config.yml showing every configurable option and its default value.
## Output Requirements
Provide the complete implementation with all required files, classes, commands, functions, permissions, configuration files, and setup instructions. Return production-ready code with comments explaining important sections.
Planning classes before writing any code:
TntSwordPlugin— main class, wires everything togetherConfigManager— typed getters overconfig.ymlSwordManager— creates/detects the sword via PDCCooldownManager— per-player cooldown trackingProjectileData— data holder for an in-flight projectileProjectileManager— launches projectiles, runs the per-tick loopSwordListener— right-click, item-held action-bar, block placement cancelSwordCommand—/tntsword give [player]
Here’s a summary of every component:
How it works
File | Role |
|---|---|
TntSwordPlugin | Wires all managers, starts the tick task |
ConfigManager | Typed getters over every config.yml key |
SwordManager | Creates the Netherite Sword and detects it via PDC ( tnt_sword key) — immune to name spoofing |
CooldownManager | Per-player cooldowns using expiry timestamps |
ProjectileData | Holds owner UUID, origin location, FallingBlock reference |
ProjectileManager | Launches FallingBlock(TNT) with configured velocity; every tick checks range, entity collisions, and draws a trail particle; schedules the delayed cosmetic explosion |
SwordListener | Handles right-click, cancels EntityChangeBlockEvent so the FallingBlock never converts to a placed block |
SwordCommand | /tntsword give [player] — requires tntsword.admin (defaults to OP) |
Key design decisions
True damage bypass —
living.setHealth(max(0, health - damage))skips the entire Bukkit damage pipeline (armor, enchants, absorption, resistance, shields all ignored)Projectile detection —
isTrackedProjectile(UUID)prevents false-positives on unrelated FallingBlocksAction bar — runs every tick inside the same scheduler loop as projectile ticks (zero extra tasks)
Cleanup —
onDisable()removes all in-flight FallingBlocks and cancels tasks so no entities are orphaned on reload
make it so it activates only when i crouch and right click because i cant shield
The ability now only fires when you crouch (shift) + right-click while holding the sword. A plain right-click does nothing.
this is spamming in console
📄
pasted-code-1780291775929.txt
txt
12 lines
▶
[01:29:21 WARN]: [TntSword] Task #140 for TntSword v1.0.0 generated an exception
java.lang.IllegalAccessError: class com.kodari.tntsword.manager.ProjectileManager$1 tried to access private method 'void com.kodari.tntsword.manager.ProjectileManager.tickProjectiles()' (com.kodari.tntsword.manager.ProjectileManager$1 and com.kodari.tntsword.manager.ProjectileManager are in unnamed module of loader 'TntSword (1).jar' @1326f867)
at TntSword (1).jar//com.kodari.tntsword.manager.ProjectileManager$1.run(ProjectileManager.java:42) ~[?:?]
at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1756) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1611) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.dedicated.DedicatedServer.tickServer(DedicatedServer.java:427) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.processPacketsAndTick(MinecraftServer.java:1667) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1335) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
The anonymous Runnable inner class couldn’t access a private method on its enclosing class due to how the JVM handles unnamed module classloaders. Removing private (package-private) resolves it.
then fix this spamming in my console
📄
pasted-code-1780292241492.txt
txt
11 lines
▶
[01:34:21 WARN]: [TntSword] Task #126 for TntSword v1.0.0 generated an exception
java.lang.IllegalAccessError: class com.kodari.tntsword.manager.ProjectileManager$1 tried to access private method 'void com.kodari.tntsword.manager.ProjectileManager.tickActionBars()' (com.kodari.tntsword.manager.ProjectileManager$1 and com.kodari.tntsword.manager.ProjectileManager are in unnamed module of loader 'TntSword (2).jar' @7ee7a9d)
at TntSword (2).jar//com.kodari.tntsword.manager.ProjectileManager$1.run(ProjectileManager.java:43) ~[?:?]
at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1756) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1611) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.dedicated.DedicatedServer.tickServer(DedicatedServer.java:427) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.processPacketsAndTick(MinecraftServer.java:1667) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1335) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388) ~[paper-1.21.11.jar:1.21.11-128-1fdbce1]
Same root cause — tickActionBars() was also private. Now package-private, the inner BukkitRunnable can access it without an IllegalAccessError.
package com.kodari.tntsword;
import com.kodari.tntsword.command.SwordCommand;
import com.kodari.tntsword.listener.SwordListener;
import com.kodari.tntsword.manager.ConfigManager;
import com.kodari.tntsword.manager.CooldownManager;
import com.kodari.tntsword.manager.ProjectileManager;
import com.kodari.tntsword.manager.SwordManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
public class TntSwordPlugin extends JavaPlugin {
@Getter private static TntSwordPlugin instance;
@Getter private ConfigManager configManager;
@Getter private SwordManager swordManager;
@Getter private CooldownManager cooldownManager;
@Getter private ProjectileManager projectileManager;
@Override
public void onEnable() {
instance = this;
saveDefaultConfig();
this.configManager = new ConfigManager(this);
this.swordManager = new SwordManager(this);
this.cooldownManager = new CooldownManager();
this.projectileManager = new ProjectileManager(this);
getServer().getPluginManager().registerEvents(new SwordListener(this), this);
SwordCommand cmd = new SwordCommand(this);
getCommand("tntsword").setExecutor(cmd);
getCommand("tntsword").setTabCompleter(cmd);
// Projectile tick + action bar update (every tick)
projectileManager.startTickTask();
getLogger().info("TntSword enabled.");
}
@Override
public void onDisable() {
if (projectileManager != null) {
projectileManager.cleanup();
}
getLogger().info("TntSword disabled.");
}
}