═══════════════════════════════ ONE LEGENDARY PER PLAYER RULE: ═══════════════════════════════
- When a player successfully crafts a legendary item,
store their UUID and the legendary name in a data file (players.yml)
- When ANY player attempts to craft a legendary:
* Check players.yml if they already own that legendary * If YES → cancel the craft, give back their materials, send message: §cYou already own a [Legendary Name]!
You cannot craft it again. * If NO → allow the craft, save to players.yml
- If a player DROPS or LOSES the legendary item,
they still cannot craft it again (intentional, makes it precious)
- Admin command: /legendary reset <player> <weaponname>
to reset a specific legendary for a player if needed Permission: legendaryweapons.admin
- players.yml structure should look like:
players: <player-uuid>: owned-legendaries: - WAR_PICK - CHRONO_SWORD
📄
pasted-code-1782365044412.txt
txt
193 lines
▶
Create a Paper/Spigot plugin for Minecraft 1.21 called
"LegendaryWeapons".
REQUIREMENTS:
- Each legendary has a custom crafting recipe
- Each legendary has a unique right-click ability with cooldown
- Custom item names in GOLD color with lore description
- Cooldown shown in action bar when ability is used
- All values (cooldowns, damage, etc) are configurable
in config.yml
- Plugin should have a clean config.yml file
═══════════════════════════════
LEGENDARY 1 — WAR PICK
═══════════════════════════════
Item: Diamond Pickaxe
Name: §6War Pick
Lore: §7A legendary pickaxe that deals devastating blows.
Ability 1 — MINE EXPLODE:
- When player mines any block, trigger a 3x3x3 explosion
around that block (no block damage to prevent griefing,
only entity damage)
- Cooldown: 5 seconds
Ability 2 — ARMOR SHRED:
- On critical hit against a player, 30% chance to damage
a random piece of their armor by 10 durability points
- Cooldown: 20 seconds
Custom Recipe (Shaped):
A B A
B C B
A B A
A = Block of Redstone
B = Block of Redstone
C = Diamond Pickaxe
+ require 1x TNT and 1x Player Head in offhand
(if offhand not possible, add TNT and Player Head
to recipe grid instead)
═══════════════════════════════
LEGENDARY 2 — GOLEM HAMMER
═══════════════════════════════
Item: Iron Axe
Name: §6Golem Hammer
Lore: §7Harness the power of an Iron Golem.
Ability — GROUND POUND:
- Right click to launch player into the air (velocity Y+2.0)
- When player lands, trigger ground pound in 4 block radius:
* Nearby enemies get launched upward
* Apply Slowness II for 3 seconds to hit enemies
* Deal 6 damage to hit enemies
* No fall damage for the user on this landing
- Cooldown: 30 seconds
Custom Recipe (Shaped):
A B A
C D C
A E A
A = Diamond
B = Lodestone
C = Block of Iron
D = Iron Axe
E = Blaze Rod
═══════════════════════════════
LEGENDARY 3 — CHRONO SWORD
═══════════════════════════════
Item: Diamond Sword
Name: §6Chrono Sword
Lore: §7A blade that manipulates time itself.
Ability — TIME REWIND:
- Right click to save current player state:
* Save position (X, Y, Z)
* Save current health
* Save current inventory
- After 7 seconds, automatically teleport player back
to saved position and restore saved health
- Right clicking again before 7 seconds cancels and
triggers rewind immediately
- Cooldown: 45 seconds (90 seconds if player dies
during ability)
Custom Recipe (Shaped):
A B A
C D C
A B A
A = Soul Lantern
B = Iron Chain
C = Diamond
D = Diamond Sword
+ 1x Clock and 1x Ender Pearl anywhere in grid
═══════════════════════════════
LEGENDARY 4 — EAGLE EYE BOW
═══════════════════════════════
Item: Bow
Name: §6Eagle Eye Bow
Lore: §7Infused with the spirit of an eagle.
Ability 1 — MID-AIR HOVER:
- When player is in air and charges the bow (hold right
click), cancel gravity (set Y velocity to 0) until
they release/shoot
- Stop hovering when arrow is released
Ability 2 — HEADSHOT:
- If arrow hits a player in the head slot area, deal
150% of normal arrow damage instead
- Only triggers on fully charged shots
Enchantments on item: Power III
Custom Recipe (Shaped):
A B A
B C B
A B A
A = Diamond
B = Glowstone Dust
C = Bow
+ 1x Rabbit's Foot anywhere in grid
═══════════════════════════════
LEGENDARY 5 — FREEZING CHAKRAM
═══════════════════════════════
Item: Diamond Hoe (renamed)
Name: §6Freezing Chakram
Lore: §7Arctic chakrams that return to the thrower.
Ability — THROW AND RETURN:
- Right click to throw the chakram (as a snowball entity
visually, or use a shulker bullet for boomerang effect)
- Chakram travels forward dealing 6 damage to first
enemy hit
- After 2 seconds OR on hit, returns to player position
- Deals 4 damage again on return hit to any enemy in path
- 4 charges total, recharges 1 charge every 15 seconds
- Show charges remaining in item lore
Custom Recipe (Shaped):
A B A
B C B
A B A
A = Amethyst Shard
B = Block of Iron
C = Diamond Hoe
+ 1x Powder Snow Bucket anywhere in grid
═══════════════════════════════
CONFIG.YML STRUCTURE REQUIRED:
═══════════════════════════════
war-pick:
mine-explode-cooldown: 5
armor-shred-cooldown: 20
armor-shred-chance: 30
armor-damage: 10
golem-hammer:
cooldown: 30
launch-velocity: 2.0
ground-pound-radius: 4
enemy-damage: 6
slowness-duration: 3
chrono-sword:
cooldown: 45
death-cooldown: 90
rewind-seconds: 7
eagle-eye-bow:
headshot-multiplier: 1.5
freezing-chakram:
max-charges: 4
recharge-seconds: 15
throw-damage: 6
return-damage: 4
return-delay-seconds: 2
═══════════════════════════════
ADDITIONAL REQUIREMENTS:
═══════════════════════════════
- Legendary items must be UNBREAKABLE
- Items must be tagged with custom NBT/PersistentDataContainer
so abilities only trigger on actual legendary items
(not regular items of same type)
- Command: /legendary give
to give legendaries to players
- Permission node: legendaryw eapons.give for the command
- On plugin enable, print "LegendaryWeapons loaded!" to console
I’ll create a comprehensive legendary weapons plugin with custom crafting, unique abilities, and one-per-player restrictions.
LegendaryWeapons plugin created!
Five unique legendary weapons with custom abilities:
War Pick - Mining explosions & armor shredding
Golem Hammer - Ground pound devastation
Chrono Sword - Time rewind mechanics
Eagle Eye Bow - Mid-air hovering & headshots
Freezing Chakram - Boomerang projectiles with charges
Each legendary enforces one-per-player ownership with admin reset capability. All cooldowns and values are fully configurable in config.yml.
📄
pasted-code-1782436740969.txt
txt
247 lines
▶
Rewrite the GolemHammer.java class for a Paper 1.21.4 plugin.
The current version is broken because it checks for landing
after a fixed 40 tick delay instead of continuously checking.
Here is the FIXED version - use exactly this logic:
package com.legendaryweapons.items;
import com.legendaryweapons.LegendaryWeapons;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class GolemHammer implements LegendaryItem {
private final LegendaryWeapons plugin;
private final Map landingCheckers = new HashMap<>();
public GolemHammer(LegendaryWeapons plugin) {
this.plugin = plugin;
}
@Override
public String getName() { return "GOLEM_HAMMER"; }
@Override
public String getDisplayName() { return "§6Golem Hammer"; }
@Override
public String[] getLore() {
return new String[]{
"§7Harness the power of an Iron Golem.",
"§eRight Click §7to launch and ground pound!"
};
}
@Override
public Material getBaseMaterial() { return Material.IRON_AXE; }
@Override
public String getIdentifier() { return "golem_hammer"; }
@Override
public ItemStack createItem() {
ItemStack item = new ItemStack(Material.IRON_AXE);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(getDisplayName());
meta.setLore(Arrays.asList(getLore()));
meta.setUnbreakable(true);
meta.getPersistentDataContainer().set(
new NamespacedKey(plugin, "legendary_item"),
PersistentDataType.STRING,
getIdentifier()
);
item.setItemMeta(meta);
return item;
}
@Override
public Recipe getCraftingRecipe() {
NamespacedKey key = new NamespacedKey(plugin, "golem_hammer_recipe");
ShapedRecipe recipe = new ShapedRecipe(key, createItem());
recipe.shape("ABA", "CDC", "AEA");
recipe.setIngredient('A', Material.DIAMOND);
recipe.setIngredient('B', Material.LODESTONE);
recipe.setIngredient('C', Material.IRON_BLOCK);
recipe.setIngredient('D', Material.IRON_AXE);
recipe.setIngredient('E', Material.BLAZE_ROD);
return recipe;
}
@Override
public void onRightClick(Player player, PlayerInteractEvent event) {
String cooldownKey = "golem_hammer_ground_pound";
int cooldown = plugin.getConfig().getInt("golem-hammer.cooldown", 30);
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
player.sendActionBar("§cGround Pound on cooldown! §f" + remaining + "s remaining");
return;
}
// Cancel any existing landing checker for this player
if (landingCheckers.containsKey(player.getUniqueId())) {
landingCheckers.get(player.getUniqueId()).cancel();
landingCheckers.remove(player.getUniqueId());
}
// Launch player upward
double launchVelocity = plugin.getConfig()
.getDouble("golem-hammer.launch-velocity", 2.0);
player.setVelocity(new Vector(
player.getVelocity().getX(),
launchVelocity,
player.getVelocity().getZ()
));
// Prevent fall damage for this jump
player.setFallDistance(-100f);
player.sendActionBar("§a§lLAUNCHED! §7Land to trigger Ground Pound!");
player.playSound(player.getLocation(), Sound.ENTITY_IRON_GOLEM_ATTACK, 1.0f, 0.8f);
// Track if player was in air (must go up before landing counts)
final boolean[] wasInAir = {false};
final int[] ticksChecked = {0};
// Check every tick if player has landed
BukkitTask task = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
ticksChecked[0]++;
// Safety timeout after 10 seconds (200 ticks)
if (ticksChecked[0] > 200) {
landingCheckers.remove(player.getUniqueId());
player.setFallDistance(0);
Bukkit.getScheduler().cancelTask(
landingCheckers.getOrDefault(player.getUniqueId(),
null) != null ? landingCheckers.get(
player.getUniqueId()).getTaskId() : -1
);
return;
}
// Wait until player is clearly in the air first
if (!player.isOnGround()) {
wasInAir[0] = true;
// Keep resetting fall distance so no fall damage
player.setFallDistance(-100f);
return;
}
// Player has landed after being in air
if (wasInAir[0] && player.isOnGround()) {
// Cancel this checker
BukkitTask checker = landingCheckers.remove(player.getUniqueId());
if (checker != null) checker.cancel();
// Reset fall distance to prevent damage
player.setFallDistance(0);
// Perform the ground pound
performGroundPound(player);
}
}, 1L, 1L); // Check every tick (1L = every tick)
landingCheckers.put(player.getUniqueId(), task);
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
}
private void performGroundPound(Player player) {
Location loc = player.getLocation();
int radius = plugin.getConfig().getInt("golem-hammer.ground-pound-radius", 4);
double damage = plugin.getConfig().getDouble("golem-hammer.enemy-damage", 6.0);
int slownessDuration = plugin.getConfig().getInt("golem-hammer.slowness-duration", 3);
// Visual and sound effects
loc.getWorld().spawnParticle(Particle.EXPLOSION, loc, 5, 1, 0.5, 1, 0);
loc.getWorld().spawnParticle(Particle.BLOCK, loc, 30, 2, 1, 2,
Material.IRON_BLOCK.createBlockData());
loc.getWorld().playSound(loc, Sound.ENTITY_IRON_GOLEM_DEATH, 1.5f, 0.5f);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 1.2f);
int entitiesHit = 0;
for (Entity entity : loc.getWorld().getNearbyEntities(loc, radius, radius, radius)) {
if (!(entity instanceof LivingEntity)) continue;
if (entity == player) continue;
LivingEntity target = (LivingEntity) entity;
// Calculate knockback direction away from player
Vector knockback = target.getLocation().toVector()
.subtract(loc.toVector());
// Handle case where entity is exactly at same location
if (knockback.lengthSquared() == 0) {
knockback = new Vector(0, 1, 0);
} else {
knockback = knockback.normalize();
}
// Set knockback with upward component
knockback.setY(0.8);
knockback.multiply(1.5);
target.setVelocity(knockback);
// Deal damage
target.damage(damage, player);
// Apply slowness
target.addPotionEffect(new PotionEffect(
PotionEffectType.SLOWNESS,
slownessDuration * 20,
1,
false,
true
));
entitiesHit++;
}
// Feedback to player
if (entitiesHit > 0) {
player.sendActionBar("§a§lGROUND POUND! §7Hit " + entitiesHit + " entities!");
player.sendMessage("§6[Golem Hammer] §aGround Pound hit " + entitiesHit + " entities!");
} else {
player.sendActionBar("§e§lGROUND POUND! §7No enemies nearby.");
}
}
// Required interface methods - not used by GolemHammer
@Override
public void onLeftClick(Player player, PlayerInteractEvent event) {}
@Override
public void onHit(Player player, EntityDamageByEntityEvent event) {}
@Override
public void onBlockBreak(Player player, BlockBreakEvent event) {}
@Override
public void onBowShoot(Player player, EntityShootBowEvent event) {}
}
I’ll read the current GolemHammer.java file and replace it with the fixed version.
Add a command to reload plugin config
Added /legendary reload command
Usage: /legendary reload
Reloads the plugin configuration file without restarting the server. Requires legendaryweapons.admin permission.
The compilation failed with this error:
Compilation failed with 60 error(s):
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 161: method onBlockBreak(Player,BlockBreakEvent) is already defined in class WarPick
@Override public void onBlockBreak(Player player, org.bukkit.event.block.BlockBreakEvent event) { onBlockBreak(player, event); }
^
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 39: cannot find symbol
if (plugin.getPlayerDataManager().hasLegendary(player.getUniqueId(), legendary.getName())) {
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 45: cannot find symbol
plugin.getPlayerDataManager().addLegendary(player.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 50: cannot find symbol
for (LegendaryItem legendary : plugin.getLegendaries().values()) {
^
symbol: method getLegendaries()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/ItemAbilityListener.java at line 146: cannot find symbol
for (LegendaryItem legendary : plugin.getLegendaries().values()) {
^
symbol: method getLegendaries()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 94: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 95: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 147: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/FreezingChakram.java at line 138: incompatible types: void cannot be converted to BukkitTask
BukkitTask trackTask = Bukkit.getScheduler().runTaskTimer(plugin, trackTaskRef -> {
^
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 77: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 78: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 105: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 118: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(attacker, cooldownKey)) return;
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 144: cannot find symbol
plugin.getCooldownManager().setCooldown(attacker, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 70: cannot find symbol
recipe.setIngredient('B', Material.CHAIN);
^
symbol: variable CHAIN
location: class Material
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 94: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 95: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 123: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/commands/LegendaryCommand.java at line 66: cannot find symbol
plugin.getPlayerDataManager().addLegendary(target.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/commands/LegendaryCommand.java at line 72: cannot find symbol
plugin.getPlayerDataManager().removeLegendary(target.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/FreezingChakram.java at line 138: incompatible types: void cannot be converted to BukkitTask
BukkitTask trackTask = Bukkit.getScheduler().runTaskTimer(plugin, trackTaskRef -> {
^
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 70: cannot find symbol
recipe.setIngredient('B', Material.CHAIN);
^
symbol: variable CHAIN
location: class Material
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 39: cannot find symbol
if (plugin.getPlayerDataManager().hasLegendary(player.getUniqueId(), legendary.getName())) {
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 45: cannot find symbol
plugin.getPlayerDataManager().addLegendary(player.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 50: cannot find symbol
for (LegendaryItem legendary : plugin.getLegendaries().values()) {
^
symbol: method getLegendaries()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/ItemAbilityListener.java at line 146: cannot find symbol
for (LegendaryItem legendary : plugin.getLegendaries().values()) {
^
symbol: method getLegendaries()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 94: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 95: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 147: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 77: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 78: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 105: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 118: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(attacker, cooldownKey)) return;
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 144: cannot find symbol
plugin.getCooldownManager().setCooldown(attacker, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 94: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 95: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 123: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/commands/LegendaryCommand.java at line 66: cannot find symbol
plugin.getPlayerDataManager().addLegendary(target.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/commands/LegendaryCommand.java at line 72: cannot find symbol
plugin.getPlayerDataManager().removeLegendary(target.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 161: method onBlockBreak(Player,BlockBreakEvent) is already defined in class WarPick
@Override public void onBlockBreak(Player player, org.bukkit.event.block.BlockBreakEvent event) { onBlockBreak(player, event); }
^
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 161: method onBlockBreak(Player,BlockBreakEvent) is already defined in class WarPick
@Override public void onBlockBreak(Player player, org.bukkit.event.block.BlockBreakEvent event) { onBlockBreak(player, event); }
^
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 39: cannot find symbol
if (plugin.getPlayerDataManager().hasLegendary(player.getUniqueId(), legendary.getName())) {
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 45: cannot find symbol
plugin.getPlayerDataManager().addLegendary(player.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/CraftingListener.java at line 50: cannot find symbol
for (LegendaryItem legendary : plugin.getLegendaries().values()) {
^
symbol: method getLegendaries()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/listeners/ItemAbilityListener.java at line 146: cannot find symbol
for (LegendaryItem legendary : plugin.getLegendaries().values()) {
^
symbol: method getLegendaries()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 94: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 95: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/GolemHammer.java at line 147: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/FreezingChakram.java at line 138: incompatible types: void cannot be converted to BukkitTask
BukkitTask trackTask = Bukkit.getScheduler().runTaskTimer(plugin, trackTaskRef -> {
^
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 77: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 78: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 105: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 118: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(attacker, cooldownKey)) return;
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/WarPick.java at line 144: cannot find symbol
plugin.getCooldownManager().setCooldown(attacker, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 70: cannot find symbol
recipe.setIngredient('B', Material.CHAIN);
^
symbol: variable CHAIN
location: class Material
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 94: cannot find symbol
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 95: cannot find symbol
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/items/ChronoSword.java at line 123: cannot find symbol
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
^
symbol: method getCooldownManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/commands/LegendaryCommand.java at line 66: cannot find symbol
plugin.getPlayerDataManager().addLegendary(target.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
ERROR in src/main/java/com/legendaryweapons/commands/LegendaryCommand.java at line 72: cannot find symbol
plugin.getPlayerDataManager().removeLegendary(target.getUniqueId(), legendary.getName());
^
symbol: method getPlayerDataManager()
location: variable plugin of type LegendaryWeapons
=== COMPILATION ERROR ANALYSIS ===
MISSING METHODS:
- getPlayerDataManager()
- getLegendaries()
- getCooldownManager()
ACTION: Check method names and signatures
TYPE MISMATCHES:
- incompatible types: void cannot be converted to BukkitTask
- incompatible types: void cannot be converted to BukkitTask
- incompatible types: void cannot be converted to BukkitTask
ACTION: Fix variable types or casting
FILES TO INVESTIGATE:
- src/main/java/com/legendaryweapons/items/WarPick.java
- src/main/java/com/legendaryweapons/listeners/CraftingListener.java
- src/main/java/com/legendaryweapons/listeners/ItemAbilityListener.java
- src/main/java/com/legendaryweapons/items/GolemHammer.java
- src/main/java/com/legendaryweapons/items/FreezingChakram.java
- src/main/java/com/legendaryweapons/items/ChronoSword.java
- src/main/java/com/legendaryweapons/commands/LegendaryCommand.java
- src/main/java/com/legendaryweapons/items/FreezingChakram.java
- src/main/java/com/legendaryweapons/items/ChronoSword.java
- src/main/java/com/legendaryweapons/listeners/CraftingListener.java
- src/main/java/com/legendaryweapons/listeners/ItemAbilityListener.java
- src/main/java/com/legendaryweapons/items/GolemHammer.java
- src/main/java/com/legendaryweapons/items/WarPick.java
- src/main/java/com/legendaryweapons/commands/LegendaryCommand.java
Please fix this error by creating a new artifact with the corrected code.
I need to investigate the main plugin class and the files with errors to fix all compilation issues.
Fixed all compilation errors:
Added Lombok dependency - The main plugin class uses
@Getterbut Lombok wasn’t in build.gradleFixed Material.CHAIN - Replaced with XSeries
XMaterial.matchXMaterial("CHAIN")for cross-version compatibilityFixed BukkitTask lambda pattern - Replaced incorrect
trackTaskReflambda withtrackTaskHolderarray patternRemoved duplicate method - Deleted recursive
onBlockBreakoverride in WarPick
The plugin should now compile successfully. The /legendary reload command is active and all items work properly.
In Golem hamer when it launches up and we fall down it gives us fall dmg which should not happen
I’ll investigate the Golem hammer launch mechanic and fix the fall damage issue.
I can see the issue. The fall damage prevention logic sets fall distance in the task that runs every tick, but there’s a race condition—Minecraft can apply fall damage between ticks before the task cancels it. The fix is to add an event listener that prevents fall damage for players with active landing checkers.
Fixed! The Golem Hammer now prevents fall damage by cancelling fall damage events for players mid-launch. The issue was a race condition—Minecraft applied fall damage before the task could reset it. Now an event listener blocks the damage entirely while the player has an active landing checker.
In eagle eye bow when we are in air hovering and we hold right click the hover gets off andd then turn on and so we cannot shot the bow even when hovering or standing as right clicking turns of hovering
I’ll investigate the Eagle Eye Bow hover and shooting mechanics to fix the toggle conflict.
I see the issue. When you hold right-click to charge the bow, the interact event fires continuously, toggling hover on/off repeatedly. This prevents both hovering and shooting.
The fix: only allow starting hover via right-click, not toggling it off. Hover will automatically stop when you shoot (already handled in onBowShoot) or when you land.
Fixed! Now when hovering, right-clicking will charge the bow normally instead of toggling hover on/off. The hover automatically stops when you shoot the arrow or land on the ground. You can now shoot while hovering without interruption.
there is error in freezing chakram also in which the throw dmg is not going and make it so when returning the chakram 100% hits
I’ll investigate the Freezing Chakram to fix the throw damage and ensure it returns to the player reliably.
I can see the issues:
Throw damage: The chakram only damages entities near the final position after 2 seconds, not when it actually hits something mid-flight. We need to handle the snowball hit event.
Return reliability: The chakram checks distance < 1.5, but can miss moving players. We need a larger detection radius and better tracking.
Fixed both issues!
1. Throw damage now works: The onHit event handler now applies the configured throw damage (6 by default) when the chakram snowball hits an entity mid-flight, plus applies the freeze effect immediately.
2. Return is now 100% reliable:
Increased detection radius from 1.5 → 2.5 blocks
Chakram accelerates when close (1.2 speed within 5 blocks vs 0.8 when far)
Much harder to dodge the returning chakram
The chakram now deals proper damage on direct hits and reliably returns to the player even if they’re moving.
make in bow like when we are in hover and do left click it insta shoots arrow and by right clicking we can toggle hover and increase velocity of falling while dropping
I’ll modify the Eagle Eye Bow to use left-click for instant shooting while hovering, right-click to toggle hover, and add faster falling.
Perfect! I’ve updated the Eagle Eye Bow with the new mechanics:
New Controls:
Right-click in air: Toggle hover on/off
Left-click while hovering: Instantly shoot a powerful arrow (no charging needed)
Shift while hovering: Drop faster (stops hovering and accelerates downward)
What changed:
Right-click now toggles hover instead of blocking when already hovering
Left-click while hovering launches an instant arrow with max power, consumes 1 arrow, and includes the headshot bonus
Sneaking while hovering lets you drop at -0.5 velocity for controlled descent
Updated lore to show all the new controls
Now you can hover, shoot instantly with left-click, toggle hover on/off with right-click, and drop faster by holding shift!
In eagle eye bow make that arrow blast when its touches a player and Add a INVENTORY GUI which is directly linked to onffig.yml so from that INVENTORY GUI people can change config of each item seperatly
I’ll add arrow blast on hit for the Eagle Eye Bow and create a full GUI system for editing weapon configs from in-game.
Now I’ll add the arrow blast effect and create the complete GUI system for config editing.
Now I’ll patch the files to integrate the GUI system and add the arrow explosion:
Perfect! I’ve added:
1. Eagle Eye Bow Arrow Blast:
Arrows now create an explosion effect (visual + sound) when hitting anything
Deals up to 4 damage to entities within 2.5 blocks (damage decreases with distance)
Excludes the shooter from damage
Still maintains the headshot bonus system
2. Complete GUI Config System:
/legendary configopens the main config menu (requireslegendaryweapons.adminpermission)Click any weapon to open its individual config editor
Each config value shows its current value and type
Click any setting to edit it via chat prompt
Smart icon selection based on config key name (damage = sword, cooldown = clock, etc.)
Save button writes to config.yml
Reload button refreshes from disk
Back button returns to main menu
GUI Framework includes:
InventoryHandler- Interface for inventory eventsInventoryButton- Builder pattern for clickable slotsInventoryGUI- Abstract base class with lazy initializationGUIManager- Centralized inventory trackingGUIListener- Auto-registering event handlerConfigMenuGUI- Shows all 5 weaponsWeaponConfigGUI- Edits individual weapon settings
The GUI directly reads from and writes to config.yml, so all changes persist on server restart!
In plugin add support for itemadder & oraxen plugin so other plugin users can add costum textures on the items
I’ll add support for ItemsAdder and Oraxen custom textures to all legendary weapons.
Now I’ll add full ItemsAdder and Oraxen support for custom textures on all legendary weapons.
Now I’ll patch all the weapon classes to use the CustomTextureManager:
Perfect! I’ve successfully added ItemsAdder and Oraxen support to the Legendary Weapons plugin. Here’s what was implemented:
✅ Complete ItemsAdder & Oraxen Integration
1. CustomTextureManager - Handles both plugins automatically:
Detects which plugin is installed (ItemsAdder or Oraxen)
Falls back to vanilla materials if neither is present
Creates custom textured items based on config settings
2. Config Structure - Each weapon now has custom texture settings:
war-pick:
custom-texture:
enabled: false
provider: "itemsadder" # or "oraxen"
item-id: "legendary:war_pick"
3. All Weapons Updated:
War Pick
Golem Hammer
Chrono Sword
Eagle Eye Bow
Freezing Chakram
4. Dependencies Added to build.gradle:
ItemsAdder API (compile-only)
Oraxen API (compile-only)
JitPack repository
How to Use:
For ItemsAdder:
Set
enabled: truein configSet
provider: "itemsadder"Set
item-idto your ItemsAdder item (e.g.,"legendary:war_pick")Create the custom item in ItemsAdder with that ID
For Oraxen:
Set
enabled: truein configSet
provider: "oraxen"Set
item-idto your Oraxen item (e.g.,"legendary_war_pick")Create the custom item in Oraxen with that ID
The system automatically detects which plugin is installed and uses the appropriate API. If neither is installed or enabled: false, it uses vanilla Minecraft materials!
📄
KODARI_PROMPT.txt
txt
338 lines
▶
Add the following to the LegendaryWeapons plugin:
═══════════════════════════════════════════
STEP 1 — ADD NEW FILE: util/LegendaryGlow.java
═══════════════════════════════════════════
Create a new file at:
src/main/java/com/legendaryweapons/util/LegendaryGlow.java
Content:
package com.legendaryweapons.util;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class LegendaryGlow {
public static ItemStack applyGlow(ItemStack item) {
if (item == null || !item.hasItemMeta()) return item;
ItemMeta meta = item.getItemMeta();
Enchantment glow = getGlowEnchantment(item.getType());
if (glow != null) {
meta.addEnchant(glow, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
item.setItemMeta(meta);
return item;
}
private static Enchantment getGlowEnchantment(Material material) {
switch (material) {
case BOW: return Enchantment.UNBREAKING;
case DIAMOND_SWORD: return Enchantment.AQUA_AFFINITY;
case IRON_AXE: return Enchantment.AQUA_AFFINITY;
case DIAMOND_PICKAXE: return Enchantment.AQUA_AFFINITY;
case DIAMOND_HOE: return Enchantment.AQUA_AFFINITY;
case BLAZE_ROD: return Enchantment.AQUA_AFFINITY;
default: return Enchantment.UNBREAKING;
}
}
}
═══════════════════════════════════════════
STEP 2 — ADD NEW FILE: items/HypnosisStaff.java
═══════════════════════════════════════════
Create a new file at:
src/main/java/com/legendaryweapons/items/HypnosisStaff.java
With this exact content (copy verbatim):
package com.legendaryweapons.items;
import com.legendaryweapons.LegendaryWeapons;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.*;
public class HypnosisStaff implements LegendaryItem, Listener {
private final LegendaryWeapons plugin;
private final Map> controlledMobs = new HashMap<>();
private final Map followTasks = new HashMap<>();
private static final int MAX_MOBS = 10;
private static final int CONTROL_RADIUS = 8;
public HypnosisStaff(LegendaryWeapons plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@Override public String getName() { return "HYPNOSIS_STAFF"; }
@Override public String getDisplayName() { return "§5Hypnosis Staff"; }
@Override public String[] getLore() {
return new String[]{
"§7Mind-control nearby mobs to fight for you.",
"§eRight Click §7a mob to control it.",
"§eRight Click air §7to release all mobs.",
"§5Max §f10 §5mobs at once."
};
}
@Override public Material getBaseMaterial() { return Material.BLAZE_ROD; }
@Override public String getIdentifier() { return "hypnosis_staff"; }
@Override
public ItemStack createItem() {
ItemStack item = new ItemStack(Material.BLAZE_ROD);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(getDisplayName());
meta.setLore(Arrays.asList(getLore()));
meta.setUnbreakable(true);
meta.addEnchant(Enchantment.LOYALTY, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.getPersistentDataContainer().set(
new NamespacedKey(plugin, "legendary_item"),
PersistentDataType.STRING, getIdentifier());
item.setItemMeta(meta);
return item;
}
@Override
public Recipe getCraftingRecipe() {
NamespacedKey key = new NamespacedKey(plugin, "hypnosis_staff_recipe");
ShapedRecipe recipe = new ShapedRecipe(key, createItem());
recipe.shape("ABA", "BCB", "ABA");
recipe.setIngredient('A', Material.AMETHYST_SHARD);
recipe.setIngredient('B', Material.ECHO_SHARD);
recipe.setIngredient('C', Material.BLAZE_ROD);
return recipe;
}
@Override
public void onRightClick(Player player, PlayerInteractEvent event) {
if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_AIR
|| event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) {
LivingEntity target = getNearestMobInSight(player);
if (target == null) {
releaseAllMobs(player);
return;
}
String cooldownKey = "hypnosis_staff_control";
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
long r = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
player.sendActionBar("§cHypnosis on cooldown! §f" + r + "s");
return;
}
List myMobs = controlledMobs.getOrDefault(player.getUniqueId(), new ArrayList<>());
if (myMobs.contains(target.getUniqueId())) {
releaseMob(player, target);
return;
}
if (myMobs.size() >= MAX_MOBS) {
player.sendActionBar("§cMax mobs reached! Release some first.");
return;
}
controlMob(player, target);
plugin.getCooldownManager().setCooldown(player, cooldownKey, 3);
}
}
private void controlMob(Player player, LivingEntity mob) {
UUID playerUUID = player.getUniqueId();
UUID mobUUID = mob.getUniqueId();
mob.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 0, false, false));
mob.getWorld().spawnParticle(Particle.PORTAL, mob.getLocation().add(0,1,0), 20, 0.3, 0.5, 0.3, 0.1);
mob.getWorld().spawnParticle(Particle.WITCH, mob.getLocation().add(0,1,0), 10, 0.3, 0.5, 0.3, 0.1);
mob.getWorld().playSound(mob.getLocation(), Sound.ENTITY_ENDERMAN_STARE, 1.0f, 1.5f);
mob.getPersistentDataContainer().set(
new NamespacedKey(plugin, "hypnosis_owner"),
PersistentDataType.STRING, playerUUID.toString());
List myMobs = controlledMobs.computeIfAbsent(playerUUID, k -> new ArrayList<>());
myMobs.add(mobUUID);
BukkitTask task = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
if (!mob.isValid() || mob.isDead()) { releaseMob(player, mob); return; }
if (!player.isOnline()) { releaseMob(player, mob); return; }
Location playerLoc = player.getLocation();
double distance = mob.getLocation().distance(playerLoc);
if (distance > 4) {
Vector dir = playerLoc.toVector().subtract(mob.getLocation().toVector()).normalize().multiply(0.3);
mob.setVelocity(dir);
}
LivingEntity enemy = getNearestEnemy(mob, player);
if (enemy != null && mob instanceof Mob) ((Mob) mob).setTarget(enemy);
mob.getWorld().spawnParticle(Particle.WITCH, mob.getLocation().add(0,1,0), 1, 0.2, 0.3, 0.2, 0);
}, 0L, 5L);
followTasks.put(mobUUID, task);
int total = controlledMobs.get(playerUUID).size();
player.sendActionBar("§5§lHYPNOTIZED! §7Controlling §5" + total + "§7/" + MAX_MOBS);
player.sendMessage("§5[Hypnosis Staff] §aControlled §f" + mob.getType().name() + "§a! Total: §5" + total + "§a/" + MAX_MOBS);
}
private void releaseMob(Player player, LivingEntity mob) {
BukkitTask task = followTasks.remove(mob.getUniqueId());
if (task != null) task.cancel();
mob.removePotionEffect(PotionEffectType.GLOWING);
mob.getPersistentDataContainer().remove(new NamespacedKey(plugin, "hypnosis_owner"));
if (mob instanceof Mob) ((Mob) mob).setTarget(null);
mob.getWorld().spawnParticle(Particle.SMOKE, mob.getLocation().add(0,1,0), 15, 0.3, 0.5, 0.3, 0.05);
List myMobs = controlledMobs.get(player.getUniqueId());
if (myMobs != null) myMobs.remove(mob.getUniqueId());
player.sendMessage("§5[Hypnosis Staff] §7Released §f" + mob.getType().name());
}
private void releaseAllMobs(Player player) {
List myMobs = controlledMobs.remove(player.getUniqueId());
if (myMobs == null || myMobs.isEmpty()) {
player.sendActionBar("§7No mobs currently controlled.");
return;
}
int count = myMobs.size();
for (UUID mobUUID : new ArrayList<>(myMobs)) {
BukkitTask task = followTasks.remove(mobUUID);
if (task != null) task.cancel();
for (World world : Bukkit.getWorlds()) {
world.getEntities().stream()
.filter(e -> e.getUniqueId().equals(mobUUID) && e instanceof LivingEntity)
.findFirst().ifPresent(e -> {
LivingEntity mob = (LivingEntity) e;
mob.removePotionEffect(PotionEffectType.GLOWING);
mob.getPersistentDataContainer().remove(new NamespacedKey(plugin, "hypnosis_owner"));
if (mob instanceof Mob) ((Mob) mob).setTarget(null);
mob.getWorld().spawnParticle(Particle.SMOKE, mob.getLocation().add(0,1,0), 15, 0.3, 0.5, 0.3, 0.05);
});
}
}
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 1.0f, 0.8f);
player.sendActionBar("§5Released §f" + count + " §5mobs!");
}
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
String ownerStr = entity.getPersistentDataContainer().get(
new NamespacedKey(plugin, "hypnosis_owner"), PersistentDataType.STRING);
if (ownerStr == null) return;
UUID playerUUID = UUID.fromString(ownerStr);
BukkitTask task = followTasks.remove(entity.getUniqueId());
if (task != null) task.cancel();
List myMobs = controlledMobs.get(playerUUID);
if (myMobs != null) myMobs.remove(entity.getUniqueId());
Player owner = Bukkit.getPlayer(playerUUID);
if (owner != null) owner.sendMessage("§5[Hypnosis Staff] §cYour §f" + entity.getType().name() + " §cdied!");
}
@EventHandler
public void onMobAttack(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof LivingEntity)) return;
if (!(event.getEntity() instanceof Player)) return;
LivingEntity attacker = (LivingEntity) event.getDamager();
Player victim = (Player) event.getEntity();
String ownerStr = attacker.getPersistentDataContainer().get(
new NamespacedKey(plugin, "hypnosis_owner"), PersistentDataType.STRING);
if (ownerStr != null && ownerStr.equals(victim.getUniqueId().toString())) {
event.setCancelled(true);
}
}
private LivingEntity getNearestMobInSight(Player player) {
List nearby = player.getNearbyEntities(CONTROL_RADIUS, CONTROL_RADIUS, CONTROL_RADIUS);
LivingEntity nearest = null;
double closestAngle = 30;
for (Entity entity : nearby) {
if (!(entity instanceof LivingEntity) || entity instanceof Player || entity.isDead()) continue;
Vector toEntity = entity.getLocation().add(0,1,0).toVector()
.subtract(player.getEyeLocation().toVector()).normalize();
double angle = Math.toDegrees(toEntity.angle(player.getEyeLocation().getDirection()));
if (angle < closestAngle) { closestAngle = angle; nearest = (LivingEntity) entity; }
}
return nearest;
}
private LivingEntity getNearestEnemy(LivingEntity mob, Player owner) {
List nearby = mob.getNearbyEntities(12, 12, 12);
LivingEntity nearest = null;
double closestDist = Double.MAX_VALUE;
for (Entity entity : nearby) {
if (!(entity instanceof LivingEntity) || entity.equals(mob) || entity.equals(owner)) continue;
String ownerStr = ((LivingEntity) entity).getPersistentDataContainer().get(
new NamespacedKey(plugin, "hypnosis_owner"), PersistentDataType.STRING);
if (ownerStr != null && ownerStr.equals(owner.getUniqueId().toString())) continue;
double dist = mob.getLocation().distanceSquared(entity.getLocation());
if (dist < closestDist) { closestDist = dist; nearest = (LivingEntity) entity; }
}
return nearest;
}
}
═══════════════════════════════════════════
STEP 3 — MODIFY: LegendaryWeapons.java (main class)
═══════════════════════════════════════════
In the initializeLegendaries() method, add this line with the others:
legendaries.put("HYPNOSIS_STAFF", new HypnosisStaff(this));
Also add to config.yml:
hypnosis-staff:
max-mobs: 10
control-radius: 8
control-cooldown: 3
═══════════════════════════════════════════
STEP 4 — MODIFY ALL createItem() METHODS
═══════════════════════════════════════════
In every legendary's createItem() method, after setting the item meta,
call LegendaryGlow.applyGlow(item) before returning.
Import: import com.legendaryweapons.util.LegendaryGlow;
Example change in WarPick.java:
BEFORE:
item.setItemMeta(meta);
return item;
AFTER:
item.setItemMeta(meta);
return LegendaryGlow.applyGlow(item);
Apply this same change to ALL 5 existing legendaries:
- WarPick.java
- GolemHammer.java
- ChronoSword.java
- EagleEyeBow.java
- FreezingChakram.java
- HypnosisStaff.java (new one too)
Recompile and output the jar.
📄
HypnosisStaff (1).java
java
346 lines
▶
package com.legendaryweapons.items;
import com.legendaryweapons.LegendaryWeapons;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.*;
public class HypnosisStaff implements LegendaryItem, Listener {
private final LegendaryWeapons plugin;
// UUID -> list of controlled mob UUIDs
private final Map> controlledMobs = new HashMap<>();
// Mob UUID -> task keeping it following
private final Map followTasks = new HashMap<>();
private static final int MAX_MOBS = 10;
private static final int CONTROL_RADIUS = 8;
public HypnosisStaff(LegendaryWeapons plugin) {
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@Override public String getName() { return "HYPNOSIS_STAFF"; }
@Override public String getDisplayName() { return "§5Hypnosis Staff"; }
@Override public String[] getLore() {
return new String[]{
"§7Mind-control nearby mobs to fight for you.",
"§eRight Click §7a mob to control it.",
"§eRight Click air §7to release all mobs.",
"§5Max §f" + MAX_MOBS + " §5mobs at once."
};
}
@Override public Material getBaseMaterial() { return Material.BLAZE_ROD; }
@Override public String getIdentifier() { return "hypnosis_staff"; }
@Override
public ItemStack createItem() {
ItemStack item = new ItemStack(Material.BLAZE_ROD);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(getDisplayName());
meta.setLore(Arrays.asList(getLore()));
meta.setUnbreakable(true);
meta.addEnchant(org.bukkit.enchantments.Enchantment.LOYALTY, 1, true);
meta.addItemFlags(org.bukkit.inventory.ItemFlag.HIDE_ENCHANTS);
meta.getPersistentDataContainer().set(
new NamespacedKey(plugin, "legendary_item"),
PersistentDataType.STRING,
getIdentifier()
);
item.setItemMeta(meta);
return item;
}
@Override
public Recipe getCraftingRecipe() {
NamespacedKey key = new NamespacedKey(plugin, "hypnosis_staff_recipe");
ShapedRecipe recipe = new ShapedRecipe(key, createItem());
recipe.shape("ABA", "BCB", "ABA");
recipe.setIngredient('A', Material.AMETHYST_SHARD);
recipe.setIngredient('B', Material.ECHO_SHARD);
recipe.setIngredient('C', Material.BLAZE_ROD);
return recipe;
}
@Override
public void onRightClick(Player player, PlayerInteractEvent event) {
String cooldownKey = "hypnosis_staff_control";
int cooldown = 3; // short cooldown per mob control
// Right click AIR = release all mobs
if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_AIR) {
releaseAllMobs(player);
return;
}
// Right click on a block = try to find nearby mob
if (plugin.getCooldownManager().isOnCooldown(player, cooldownKey)) {
long remaining = plugin.getCooldownManager().getRemainingCooldown(player, cooldownKey);
player.sendActionBar("§cHypnosis on cooldown! §f" + remaining + "s");
return;
}
// Find nearest living entity in crosshair
LivingEntity target = getNearestMobInSight(player);
if (target == null) {
player.sendActionBar("§cNo mob in range! Look at a mob within §f" + CONTROL_RADIUS + " §cblocks.");
return;
}
// Check if already controlled by this player
List myMobs = controlledMobs.getOrDefault(player.getUniqueId(), new ArrayList<>());
if (myMobs.contains(target.getUniqueId())) {
// Release this specific mob
releaseMob(player, target);
return;
}
// Check max mob limit
if (myMobs.size() >= MAX_MOBS) {
player.sendActionBar("§cMax mobs reached! §f(" + MAX_MOBS + "/" + MAX_MOBS + ") §cRelease some first.");
return;
}
// Control the mob
controlMob(player, target);
plugin.getCooldownManager().setCooldown(player, cooldownKey, cooldown);
}
private void controlMob(Player player, LivingEntity mob) {
UUID playerUUID = player.getUniqueId();
UUID mobUUID = mob.getUniqueId();
// Add glowing effect to show it's controlled
mob.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, Integer.MAX_VALUE, 0, false, false));
// Particle effect on control
mob.getWorld().spawnParticle(Particle.PORTAL, mob.getLocation().add(0, 1, 0), 20, 0.3, 0.5, 0.3, 0.1);
mob.getWorld().spawnParticle(Particle.WITCH, mob.getLocation().add(0, 1, 0), 10, 0.3, 0.5, 0.3, 0.1);
mob.getWorld().playSound(mob.getLocation(), Sound.ENTITY_ENDERMAN_STARE, 1.0f, 1.5f);
// Tag mob as controlled
mob.getPersistentDataContainer().set(
new NamespacedKey(plugin, "hypnosis_owner"),
PersistentDataType.STRING,
playerUUID.toString()
);
// Add to player's controlled list
List myMobs = controlledMobs.computeIfAbsent(playerUUID, k -> new ArrayList<>());
myMobs.add(mobUUID);
// Make mob follow player and attack nearby players/enemies
BukkitTask task = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
if (!mob.isValid() || mob.isDead()) {
releaseMob(player, mob);
return;
}
if (!player.isOnline()) {
releaseMob(player, mob);
return;
}
Location playerLoc = player.getLocation();
Location mobLoc = mob.getLocation();
double distance = mobLoc.distance(playerLoc);
// Follow player if too far
if (distance > 4) {
Vector direction = playerLoc.toVector()
.subtract(mobLoc.toVector())
.normalize()
.multiply(0.3);
mob.setVelocity(direction);
}
// Attack nearest enemy (player or hostile mob NOT controlled by owner)
LivingEntity nearestEnemy = getNearestEnemy(mob, player);
if (nearestEnemy != null && mob instanceof Mob) {
((Mob) mob).setTarget(nearestEnemy);
}
// Particle trail to show it's controlled
mob.getWorld().spawnParticle(
Particle.WITCH,
mob.getLocation().add(0, 1, 0),
1, 0.2, 0.3, 0.2, 0
);
}, 0L, 5L);
followTasks.put(mobUUID, task);
int totalMobs = controlledMobs.get(playerUUID).size();
player.sendActionBar("§5§lHYPNOTIZED! §7Controlling §5" + totalMobs + "§7/" + MAX_MOBS + " mobs.");
player.sendMessage("§5[Hypnosis Staff] §aControlled §f" + mob.getType().name() + "§a! Total: §5" + totalMobs + "§a/" + MAX_MOBS);
}
private void releaseMob(Player player, LivingEntity mob) {
UUID mobUUID = mob.getUniqueId();
// Cancel follow task
BukkitTask task = followTasks.remove(mobUUID);
if (task != null) task.cancel();
// Remove effects
mob.removePotionEffect(PotionEffectType.GLOWING);
mob.getPersistentDataContainer().remove(new NamespacedKey(plugin, "hypnosis_owner"));
if (mob instanceof Mob) ((Mob) mob).setTarget(null);
// Release particle
mob.getWorld().spawnParticle(Particle.SMOKE, mob.getLocation().add(0, 1, 0), 15, 0.3, 0.5, 0.3, 0.05);
// Remove from player list
List myMobs = controlledMobs.get(player.getUniqueId());
if (myMobs != null) myMobs.remove(mobUUID);
player.sendMessage("§5[Hypnosis Staff] §7Released §f" + mob.getType().name() + "§7.");
}
private void releaseAllMobs(Player player) {
List myMobs = controlledMobs.remove(player.getUniqueId());
if (myMobs == null || myMobs.isEmpty()) {
player.sendActionBar("§7No mobs currently controlled.");
return;
}
int count = myMobs.size();
for (UUID mobUUID : new ArrayList<>(myMobs)) {
BukkitTask task = followTasks.remove(mobUUID);
if (task != null) task.cancel();
// Find entity by UUID and clean up
for (World world : Bukkit.getWorlds()) {
Entity entity = world.getEntities().stream()
.filter(e -> e.getUniqueId().equals(mobUUID))
.findFirst().orElse(null);
if (entity instanceof LivingEntity) {
LivingEntity mob = (LivingEntity) entity;
mob.removePotionEffect(PotionEffectType.GLOWING);
mob.getPersistentDataContainer().remove(
new NamespacedKey(plugin, "hypnosis_owner"));
if (mob instanceof Mob) ((Mob) mob).setTarget(null);
mob.getWorld().spawnParticle(
Particle.SMOKE,
mob.getLocation().add(0, 1, 0),
15, 0.3, 0.5, 0.3, 0.05
);
}
}
}
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_BEACON_DEACTIVATE, 1.0f, 0.8f);
player.sendActionBar("§5Released §f" + count + " §5controlled mobs!");
player.sendMessage("§5[Hypnosis Staff] §7Released all §f" + count + " §7mobs.");
}
// Clean up when a controlled mob dies
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
if (!entity.getPersistentDataContainer().has(
new NamespacedKey(plugin, "hypnosis_owner"), PersistentDataType.STRING)) return;
String ownerUUID = entity.getPersistentDataContainer().get(
new NamespacedKey(plugin, "hypnosis_owner"), PersistentDataType.STRING);
UUID playerUUID = UUID.fromString(ownerUUID);
Player owner = Bukkit.getPlayer(playerUUID);
BukkitTask task = followTasks.remove(entity.getUniqueId());
if (task != null) task.cancel();
List myMobs = controlledMobs.get(playerUUID);
if (myMobs != null) myMobs.remove(entity.getUniqueId());
if (owner != null) {
owner.sendMessage("§5[Hypnosis Staff] §cYour §f" + entity.getType().name() + " §chas died!");
}
}
// Prevent controlled mobs from damaging their owner
@EventHandler
public void onMobAttack(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof LivingEntity)) return;
if (!(event.getEntity() instanceof Player)) return;
LivingEntity attacker = (LivingEntity) event.getDamager();
Player victim = (Player) event.getEntity();
String ownerStr = attacker.getPersistentDataContainer().get(
new NamespacedKey(plugin, "hypnosis_owner"), PersistentDataType.STRING);
if (ownerStr == null) return;
// Cancel damage if attacking their own owner
if (ownerStr.equals(victim.getUniqueId().toString())) {
event.setCancelled(true);
}
}
private LivingEntity getNearestMobInSight(Player player) {
List nearby = player.getNearbyEntities(CONTROL_RADIUS, CONTROL_RADIUS, CONTROL_RADIUS);
LivingEntity nearest = null;
double closestAngle = 30; // max degrees off-center
for (Entity entity : nearby) {
if (!(entity instanceof LivingEntity)) continue;
if (entity instanceof Player) continue; // don't control players
if (entity.isDead()) continue;
Vector toEntity = entity.getLocation().add(0, 1, 0)
.toVector().subtract(player.getEyeLocation().toVector()).normalize();
Vector playerDir = player.getEyeLocation().getDirection().normalize();
double angle = Math.toDegrees(toEntity.angle(playerDir));
if (angle < closestAngle) {
closestAngle = angle;
nearest = (LivingEntity) entity;
}
}
return nearest;
}
private LivingEntity getNearestEnemy(LivingEntity mob, Player owner) {
List nearby = mob.getNearbyEntities(12, 12, 12);
LivingEntity nearest = null;
double closestDist = Double.MAX_VALUE;
for (Entity entity : nearby) {
if (!(entity instanceof LivingEntity)) continue;
if (entity.equals(mob)) continue;
if (entity.equals(owner)) continue;
// Skip other controlled mobs of same owner
String ownerStr = ((LivingEntity) entity).getPersistentDataContainer().get(
new NamespacedKey(plugin, "hypnosis_owner"), PersistentDataType.STRING);
if (ownerStr != null && ownerStr.equals(owner.getUniqueId().toString())) continue;
double dist = mob.getLocation().distanceSquared(entity.getLocation());
if (dist < closestDist) {
closestDist = dist;
nearest = (LivingEntity) entity;
}
}
return nearest;
}
}
📄
LegendaryGlow (1).java
java
54 lines
▶
package com.legendaryweapons.util;
import com.legendaryweapons.LegendaryWeapons;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
public class LegendaryGlow {
/**
* Applies a glow effect to any legendary ItemStack.
* Uses a hidden enchantment + HIDE_ENCHANTS flag so only
* the purple shimmer shows, not the enchantment text.
*/
public static ItemStack applyGlow(ItemStack item) {
if (item == null || !item.hasItemMeta()) return item;
ItemMeta meta = item.getItemMeta();
// Pick an enchantment that doesn't conflict with the item type
Enchantment glow = getGlowEnchantment(item.getType());
if (glow != null) {
meta.addEnchant(glow, 1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
item.setItemMeta(meta);
return item;
}
private static Enchantment getGlowEnchantment(Material material) {
// Use an enchantment that won't naturally apply to this item
// so it always shows the glow without conflicting
switch (material) {
case BOW:
case CROSSBOW:
return Enchantment.UNBREAKING;
case DIAMOND_SWORD:
case IRON_AXE:
case DIAMOND_PICKAXE:
case DIAMOND_HOE:
case BLAZE_ROD:
return Enchantment.AQUA_AFFINITY;
default:
return Enchantment.UNBREAKING;
}
}
}
I’ll add the Hypnosis Staff legendary weapon and apply glow effects to all legendary items.
Now I’ll create the LegendaryGlow utility and HypnosisStaff, then add glow effects to all legendary weapons.
Now I’ll patch all 5 existing legendary weapons to add the glow effect:
package com.legendaryweapons;
import com.legendaryweapons.commands.LegendaryCommand;
import com.legendaryweapons.inventory.gui.GUIListener;
import com.legendaryweapons.inventory.gui.GUIManager;
import com.legendaryweapons.items.*;
import com.legendaryweapons.listeners.CraftingListener;
import com.legendaryweapons.listeners.ItemAbilityListener;
import com.legendaryweapons.managers.CooldownManager;
import com.legendaryweapons.managers.PlayerDataManager;
import com.legendaryweapons.managers.RecipeManager;
import com.legendaryweapons.util.CustomTextureManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Map;
@Getter
public class LegendaryWeapons extends JavaPlugin {
private CooldownManager cooldownManager;
private PlayerDataManager playerDataManager;
private RecipeManager recipeManager;
private GUIManager guiManager;
private CustomTextureManager customTextureManager;
private Map<String, LegendaryItem> legendaries;
@Override
public void onEnable() {
saveDefaultConfig();
this.cooldownManager = new CooldownManager();
this.playerDataManager = new PlayerDataManager(this);
this.recipeManager = new RecipeManager(this);
this.guiManager = new GUIManager();
this.customTextureManager = new CustomTextureManager(this);
initializeLegendaries();
registerListeners();
registerCommands();
registerRecipes();
Bukkit.getConsoleSender().sendMessage("§aLegendaryWeapons loaded!");
}
@Override
public void onDisable() {
if (playerDataManager != null) {
playerDataManager.saveData();
}
recipeManager.unregisterRecipes();
}
private void initializeLegendaries() {
legendaries = new HashMap<>();
legendaries.put("WAR_PICK", new WarPick(this));
legendaries.put("GOLEM_HAMMER", new GolemHammer(this));
legendaries.put("CHRONO_SWORD", new ChronoSword(this));
legendaries.put("EAGLE_EYE_BOW", new EagleEyeBow(this));
legendaries.put("FREEZING_CHAKRAM", new FreezingChakram(this));
legendaries.put("HYPNOSIS_STAFF", new HypnosisStaff(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new ItemAbilityListener(this), this);
Bukkit.getPluginManager().registerEvents(new CraftingListener(this), this);
Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
}
private void registerCommands() {
getCommand("legendary").setExecutor(new LegendaryCommand(this));
}
private void registerRecipes() {
for (LegendaryItem legendary : legendaries.values()) {
recipeManager.registerRecipe(legendary);
}
}
public LegendaryItem getLegendary(String name) {
return legendaries.get(name.toUpperCase());
}
}