bentley

gives ppl blindness and slowness 30 or find me sonthin els also it has to be a sword also make it slowly corrupt over the time you have it in your inventory unlocking new amazing abilities each with modeldaas so i can make a resourcepack with them

Kodari AI
KodariOct 29 at 11:57 pm 1
CorruptedBlade
A cursed sword that grants blindness and slowness effects for 30 seconds upon wield. The blade progressively corrupts while in inventory, unlocking new abilities at each corruption stage. Each stage features distinct model data values for resource pack integration, allowing custom 3D models per evolution tier. Players experience escalating power alongside visual transformation.
  1. Create the plugin setup, config, and /corruptedsword command.

  2. Add inventory-time corruption stages with a custom model data ID for each stage.

  3. Add 30-second blindness and slowness on hits, plus abilities unlocked as it corrupts.

Created The Withering, a diamond sword that inflicts blindness and slowness for 30 seconds on hit. Its corruption advances while it’s in a player’s inventory: at 5 minutes it unlocks Corruption Burst, at 20 minutes it gains life siphoning, and at 60 minutes its burst gets stronger.

Custom model data IDs are 1001–1004 for stages 0–3; use those in your resource pack. Give the sword with /corruptedsword [player] (op-only).

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 279
src/main/java/com/kodari/corruptedsword/CorruptedSwordPlugin.java
package com.kodari.corruptedsword;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class CorruptedSwordPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private NamespacedKey swordKey;
    private NamespacedKey heldSecondsKey;
    private NamespacedKey stageKey;
    private final Map<UUID, Long> burstCooldowns = new HashMap<>();
    private final Map<UUID, Long> leechCooldowns = new HashMap<>();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        swordKey = new NamespacedKey(this, "corrupted_sword");
        heldSecondsKey = new NamespacedKey(this, "held_seconds");
        stageKey = new NamespacedKey(this, "corruption_stage");
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("corruptedsword").setExecutor(this);
        Bukkit.getScheduler().runTaskTimer(this, () -> Bukkit.getOnlinePlayers().forEach(this::advanceSword), 20L, 20L);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!sender.hasPermission("corruptedsword.admin")) {
            sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");
            return true;
        }
        if (args.length > 1) {
            sender.sendMessage(ChatColor.RED + "Usage: /corruptedsword [player]");
            return true;
        }

        Player target;
        if (args.length == 1) {
            target = Bukkit.getPlayerExact(args[0]);
        } else if (sender instanceof Player player) {
            target = player;
        } else {
            sender.sendMessage(ChatColor.RED + "Specify a player: /corruptedsword <player>");
            return true;
        }

        if (target == null) {
            sender.sendMessage(ChatColor.RED + "That player is not online.");
            return true;
        }

        for (ItemStack leftover : target.getInventory().addItem(createSword()).values()) {
            target.getWorld().dropItemNaturally(target.getLocation(), leftover);
        }
        target.sendMessage(ChatColor.DARK_PURPLE + "The Withering has entered your inventory.");
        if (target != sender) {
            sender.sendMessage(ChatColor.GREEN + "Gave The Withering to " + target.getName() + ".");
        }
        return true;
    }

    @EventHandler
    public void onSwordHit(EntityDamageByEntityEvent event) {
        if (!(event.getDamager() instanceof Player player) || !(event.getEntity() instanceof LivingEntity target)) {
            return;
        }

        ItemStack item = player.getInventory().getItemInMainHand();
        if (!isCorruptedSword(item)) {
            return;
        }

        int duration = Math.max(1, getConfig().getInt("combat.hit-effect-seconds", 30) * 20);
        applyEffect(target, "BLINDNESS", duration, 0);
        applyEffect(target, "SLOWNESS", duration, 0);

        if (getStage(item) >= 2 && System.currentTimeMillis() >= leechCooldowns.getOrDefault(player.getUniqueId(), 0L)) {
            leechCooldowns.put(player.getUniqueId(), System.currentTimeMillis() + 8_000L);
            player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + 2.0));
            player.sendMessage(ChatColor.LIGHT_PURPLE + "The sword siphons life from your target.");
        }
    }

    @EventHandler
    public void onRightClick(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND) {
            return;
        }

        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInMainHand();
        int stage = getStage(item);
        if (!isCorruptedSword(item) || stage < 1) {
            return;
        }

        long now = System.currentTimeMillis();
        if (now < burstCooldowns.getOrDefault(player.getUniqueId(), 0L)) {
            return;
        }

        burstCooldowns.put(player.getUniqueId(), now + 45_000L);
        double radius = stage >= 3 ? 8.0 : 5.0;
        int duration = stage >= 3 ? 12 * 20 : 8 * 20;
        for (Entity entity : player.getNearbyEntities(radius, radius, radius)) {
            if (entity instanceof LivingEntity target && target != player) {
                applyEffect(target, "BLINDNESS", duration, 0);
                applyEffect(target, "SLOWNESS", duration, 0);
            }
        }
        player.sendMessage(ChatColor.DARK_PURPLE + "Corruption Burst unleashed.");
        event.setCancelled(true);
    }

    private ItemStack createSword() {
        ItemStack sword = XMaterial.matchXMaterial("DIAMOND_SWORD").map(XMaterial::parseItem).orElse(null);
        if (sword == null) {
            throw new IllegalStateException("Could not create a diamond sword.");
        }
        updateSword(sword, 0, 0);
        return sword;
    }

    private void advanceSword(Player player) {
        for (ItemStack item : player.getInventory().getContents()) {
            if (!isCorruptedSword(item)) {
                continue;
            }

            ItemMeta meta = item.getItemMeta();
            int seconds = meta.getPersistentDataContainer().getOrDefault(heldSecondsKey, PersistentDataType.INTEGER, 0) + 1;
            int previousStage = getStage(item);
            int stage = stageFor(seconds);
            if (stage != previousStage || seconds % 60 == 0) {
                updateSword(item, seconds, stage);
            } else {
                meta.getPersistentDataContainer().set(heldSecondsKey, PersistentDataType.INTEGER, seconds);
                item.setItemMeta(meta);
            }

            if (stage > previousStage) {
                player.sendMessage(ChatColor.DARK_PURPLE + "The Withering has corrupted further: " + stageName(stage) + " unlocked!");
            }
        }
    }

    private ItemStack updateSword(ItemStack item, int seconds, int stage) {
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.DARK_PURPLE + "§lThe Withering");
        meta.setCustomModelData(getConfig().getInt("model-data.stage-" + stage, 1001 + stage));
        meta.getPersistentDataContainer().set(swordKey, PersistentDataType.BYTE, (byte) 1);
        meta.getPersistentDataContainer().set(heldSecondsKey, PersistentDataType.INTEGER, seconds);
        meta.getPersistentDataContainer().set(stageKey, PersistentDataType.INTEGER, stage);
        meta.setLore(Arrays.asList(
                ChatColor.GRAY + "Corruption: " + ChatColor.DARK_PURPLE + stageName(stage),
                ChatColor.GRAY + "Time in inventory: " + seconds / 60 + " minutes",
                ChatColor.GRAY + "On hit: Blindness + Slowness (" + getConfig().getInt("combat.hit-effect-seconds", 30) + "s)",
                stage >= 1 ? ChatColor.LIGHT_PURPLE + "Right-click: Corruption Burst" : ChatColor.DARK_GRAY + "A power stirs within...",
                stage >= 2 ? ChatColor.LIGHT_PURPLE + "Siphons life on hits (8s cooldown)" : ChatColor.DARK_GRAY + "Keep it close to awaken it.",
                stage >= 3 ? ChatColor.LIGHT_PURPLE + "Burst range and duration increased." : ""
        ));
        item.setItemMeta(meta);
        return item;
    }

    private int stageFor(int seconds) {
        if (seconds >= getConfig().getInt("progression.stage-3-seconds", 3600)) {
            return 3;
        }
        if (seconds >= getConfig().getInt("progression.stage-2-seconds", 1200)) {
            return 2;
        }
        if (seconds >= getConfig().getInt("progression.stage-1-seconds", 300)) {
            return 1;
        }
        return 0;
    }

    private int getStage(ItemStack item) {