zLithe2

make a scepter (loki's scepter) add a Right-click a mob with Loki's Scepter to mind-control it. The mob's eyes glow with blue particles and it instantly turns on its own kind or nearby enemies, attacking them for a short duration before returning to normal. and add shift left click to blue energy blast its destroy the block and 30 attack damage and scepters attack damage 10 shift right click to give a invisible effect (15 seconds ) and summon a copy (mannequin or armor stand but have my head)

Kodari AI
KodariNov 11 at 11:16 pm 3
LokisScepter
Adds a craftable Loki's Scepter item with three distinct abilities. Right-clicking a mob mind-controls it, causing blue particle eye effects and making it attack nearby enemies for a short duration. Shift-left-click fires a blue energy blast that destroys blocks and deals 30 damage, while the scepter's base attack deals 10 damage. Shift-right-click grants 15 seconds of invisibility and summons a decoy armor stand wearing the player's head to confuse enemies.

I’ll add a /scepter command and implement the mind control, energy blast, and invisibility-decoy abilities.

Use /scepter to receive Loki’s Scepter.

  • Right-click a mob: control it for 15 seconds.

  • Sneak + left-click: fire a block-breaking energy blast that deals 30 damage.

  • Sneak + right-click: become invisible and summon a player-headed decoy for 15 seconds.

  • Melee attack: deals 10 base damage.

zLithe2

The energy blast feature is not breaking blocks upon impact. Please update the projectile or explosion logic so that it destroys blocks when used. and add abilities cooldown

Kodari AI
KodariNov 11 at 11:54 pm 1
  1. Fix the energy blast so it destroys blocks on impact.

  2. Add cooldowns to the scepter’s abilities.

Updated the blast to destroy the block it hits, unless another plugin cancels the block-break event.

Added cooldown feedback and a 15-second mind-control cooldown. The blast and illusion retain their existing 2-second and 15-second cooldowns.

zLithe2

energy blast dont destroy blocks only attack and ranges 20 block and shift left click to useble looking air

Kodari AI
KodariNov 11 at 11:56 pm 1
  • Make the blast stop at blocks without damaging them, with a 20-block range.

  • Allow sneak-left-click in the air to activate it.

The energy blast now damages entities without breaking blocks, has a 20-block range, and activates with sneak-left-click while looking at air.

zLithe2
  • Make the energy blast pierce through entities, similar to the Piercing enchantment on a Crossbow. It should pass through hit targets and continue moving forward instead of stopping on the first entity it hits. and add config.yml
Kodari AI
KodariNov 12 at 12:00 am 1
  1. Make the blast pierce entities while stopping at blocks.

  2. Add a configuration file for the scepter’s abilities and cooldowns.

  • The energy blast now pierces entities, damaging each target once, and stops at blocks.

  • Added config.yml for damage, range, ability durations, and cooldowns. Restart the server after editing it.

zLithe2

and not use blazerod use iron hoe and illusion abilites armor stand have to golden chesplate , golden boots and golden leggings

Kodari AI
KodariNov 12 at 12:05 am 1
  • Change newly issued scepters to iron hoes.

  • Equip illusion armor stands with gold armor while keeping the player head.

New scepters use an iron hoe. Illusions now wear a golden chestplate, leggings, and boots with your player head.

Existing blaze-rod scepters will still work; use /scepter to get the new version.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 283
src/main/java/com/kodari/lokiscepter/LokiScepter.java
package com.kodari.lokiscepter;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

public final class LokiScepter extends JavaPlugin implements Listener {
    private NamespacedKey scepterKey;
    private final Map<UUID, BukkitTask> controlled = new HashMap<>();
    private final Map<UUID, Long> controlCooldowns = new HashMap<>();
    private final Map<UUID, Long> blastCooldowns = new HashMap<>();
    private final Map<UUID, Long> illusionCooldowns = new HashMap<>();
    private final List<ArmorStand> decoys = new ArrayList<>();
    private boolean dealingBlastDamage;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        scepterKey = new NamespacedKey(this, "scepter");
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        controlled.values().forEach(BukkitTask::cancel);
        for (ArmorStand decoy : decoys) decoy.remove();
        decoys.clear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can receive the scepter.");
            return true;
        }
        Player player = (Player) sender;
        ItemStack item = XMaterial.matchXMaterial("IRON_HOE").map(XMaterial::parseItem).orElse(null);
        if (item == null) {
            player.sendMessage(ChatColor.RED + "Could not create the scepter.");
            return true;
        }
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.AQUA + "Loki's Scepter");
        meta.setLore(java.util.Arrays.asList(ChatColor.GRAY + "Right-click a mob: Mind control", ChatColor.GRAY + "Sneak + left-click: Energy blast", ChatColor.GRAY + "Sneak + right-click: Illusion"));
        meta.getPersistentDataContainer().set(scepterKey, PersistentDataType.BYTE, (byte) 1);
        item.setItemMeta(meta);
        player.getInventory().addItem(item).values().forEach(leftover -> player.getWorld().dropItemNaturally(player.getLocation(), leftover));
        return true;
    }

    private boolean isScepter(ItemStack item) {
        return item != null && item.hasItemMeta() && item.getItemMeta().getPersistentDataContainer().has(scepterKey, PersistentDataType.BYTE);
    }

    @EventHandler(ignoreCancelled = true)
    public void onHit(EntityDamageByEntityEvent event) {
        if (!dealingBlastDamage && event.getDamager() instanceof Player && isScepter(((Player) event.getDamager()).getInventory().getItemInMainHand())) {
            event.setDamage(Math.max(0, getConfig().getDouble("melee-damage", 10.0)));
        }
        if (event.getEntity() instanceof ArmorStand && decoys.contains(event.getEntity())) event.setCancelled(true);
    }

    @EventHandler(ignoreCancelled = true)
    public void onManipulate(PlayerArmorStandManipulateEvent event) {
        if (decoys.contains(event.getRightClicked())) event.setCancelled(true);
    }

    @EventHandler(ignoreCancelled = true)
    public void onInteractEntity(PlayerInteractEntityEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || !isScepter(event.getPlayer().getInventory().getItemInMainHand())) return;
        Player player = event.getPlayer();
        if (player.isSneaking()) {
            event.setCancelled(true);
            illusion(player);
        } else if (event.getRightClicked() instanceof Mob) {
            event.setCancelled(true);
            control(player, (Mob) event.getRightClicked());
        }
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || !isScepter(event.getItem()) || !event.getPlayer().isSneaking()) return;
        Action action = event.getAction();
        if (event.isCancelled() && action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) return;
        if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) {
            event.setCancelled(true);
            Player player = event.getPlayer();
            getServer().getScheduler().runTask(this, () -> {
                if (player.isOnline()) blast(player);
            });
        } else if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
            event.setCancelled(true);
            illusion(event.getPlayer());
        }
    }

    private boolean ready(Map<UUID, Long> cooldowns, Player player, long milliseconds) {
        long now = System.currentTimeMillis();
        long remaining = cooldowns.getOrDefault(player.getUniqueId(), 0L) - now;
        if (remaining > 0) {
            player.sendMessage(ChatColor.RED + "Ability on cooldown: " + ((remaining + 999) / 1000) + "s remaining.");
            return false;
        }
        cooldowns.put(player.getUniqueId(), now + milliseconds);
        return true;
    }

    private void control(Player owner, Mob mob) {
        if (!ready(controlCooldowns, owner, (long) (Math.max(0, getConfig().getDouble("mind-control.cooldown-seconds", 15)) * 1000))) return;
        int durationTicks = (int) (Math.max(0, getConfig().getDouble("mind-control.duration-seconds", 15)) * 20);
        UUID id = mob.getUniqueId();
        BukkitTask previous = controlled.remove(id);
        if (previous != null) previous.cancel();
        LivingEntity originalTarget = mob.getTarget();
        final int[] ticks = {0};
        BukkitTask task = getServer().getScheduler().runTaskTimer(this, () -> {
            if (!mob.isValid() || mob.isDead() || ticks[0] >= durationTicks) {
                BukkitTask active = controlled.remove(id);
                if (active != null) active.cancel();
                if (mob.isValid() && !mob.isDead()) mob.setTarget(originalTarget != null && originalTarget.isValid() && !originalTarget.isDead() ? originalTarget : null);
                return;
            }
            ticks[0] += 10;
            particle(mob.getEyeLocation(), 5);
            LivingEntity target = mob.getTarget();
            if (target == null || target.isDead() || !target.isValid() || target.getUniqueId().equals(owner.getUniqueId()) || target.getWorld() != mob.getWorld() || target.getLocation().distanceSquared(mob.getLocation()) > 256) {
                LivingEntity closest = null;
                double best = 256;
                for (Entity entity : mob.getNearbyEntities(16, 8, 16)) {
                    if (!(entity instanceof LivingEntity) || entity instanceof ArmorStand || entity.getUniqueId().equals(owner.getUniqueId()) || entity.isDead()) continue;
                    double distance = entity.getLocation().distanceSquared(mob.getLocation());
                    if (distance < best) {
                        best = distance;
                        closest = (LivingEntity) entity;
                    }
                }
                mob.setTarget(closest);
            }
        }, 0L, 10L);
        controlled.put(id, task);
        owner.sendMessage(ChatColor.AQUA + "The mob is under your control.");
    }

    private void blast(Player player) {
        if (!ready(blastCooldowns, player, (long) (Math.max(0, getConfig().getDouble("energy-blast.cooldown-seconds", 2)) * 1000))) return;
        Location origin = player.getEyeLocation();
        Vector direction = origin.getDirection().normalize();
        double range = Math.max(0, getConfig().getDouble("energy-blast.range", 20));
        double damage = Math.max(0, getConfig().getDouble("energy-blast.damage", 30));
        Set<UUID> hitEntities = new HashSet<>();
        for (double distance = 0.5; distance <= range; distance += 0.5) {
            Location point = origin.clone().add(direction.clone().multiply(distance));
            particle(point, 2);
            if (!point.getBlock().isPassable()) break;
            for (Entity entity : player.getWorld().getNearbyEntities(point, 0.6, 0.6, 0.6)) {
                if (entity instanceof LivingEntity && entity != player && !(entity instanceof ArmorStand) && hitEntities.add(entity.getUniqueId())) {
                    dealingBlastDamage = true;
                    try {
                        ((LivingEntity) entity).damage(damage, player);
                    } finally {
                        dealingBlastDamage = false;
                    }
                }
            }