JWalker YouDead
📎 1 file 2,010 chars
📄
pasted-code-1794542444374.txt
txt 8 lines
▶
"Create a Paper 1.21.11 Minecraft plugin named NemesisGear with a /nemesis give command that gives the player 6 unbreakable custom items (tagged with PersistentDataContainer and assigned item_model keys in the nemesis namespace):
1. Nemesis Helmet (nemesis:nemesis_helmet, Netherite Helmet base): Set ARMOR attribute to 4.0 (+1 above Netherite) and ARMOR_TOUGHNESS to 3.0 on EquipmentSlot.HEAD. Grants permanent Night Vision while worn. Sneak + right-click with an empty hand grants Saturation III for 5 seconds on a 15-second cooldown with actionbar timer feedback.
2. Nemesis Chestplate (nemesis:nemesis_chestplate, Netherite Chestplate base): Set ARMOR attribute to 9.0 (+1 above Netherite), ARMOR_TOUGHNESS to 3.0, and add +20.0 MAX_HEALTH (+10 hearts) on EquipmentSlot.CHEST. Grants permanent Strength II while worn, and cycles a 20-second recharge followed by 10 seconds of complete damage immunity (canceling incoming damage with an anvil sound and actionbar status).
3. Nemesis Leggings (nemesis:nemesis_leggings, Netherite Leggings base): Set ARMOR attribute to 7.0 (+1 above Netherite) and ARMOR_TOUGHNESS to 3.0 on EquipmentSlot.LEGS. Grants permanent Resistance II (amplifier 1) and permanent Invisibility while worn.
4. Nemesis Boots (nemesis:nemesis_boots, Netherite Boots base): Set ARMOR attribute to 4.0 (+1 above Netherite) and ARMOR_TOUGHNESS to 3.0 on EquipmentSlot.FEET. Grants permanent Speed III (amplifier 2) while worn.
5. Nemesis Gauntlet Sword (nemesis:gauntlet_sword, Netherite Sword base): Adds +10.0 ARMOR (+5 armor bars) while held in the main hand. Tracks melee hits per player: every 5th hit heals the attacker with Instant Health III, and every 30th hit strikes lightning on the target.
6. Nemesis Laser Blaster (nemesis:laser_blaster, Blaze Rod base): Zero-draw, ammoless right-click weapon that works in Survival mode with a 0.25-second cooldown. Fires a 50-block straight-line red DUST particle beam that deals 16 damage (8 hearts) and ignites hit entities for 3 seconds."
Kodari AI
KodariNov 13 at 4:02 am 2
NemesisGear
Creates six unbreakable custom Netherite-based items with PersistentDataContainer tags and nemesis item_model keys. Each piece grants enhanced attributes, permanent potion effects while worn, and unique abilities: helmet provides night vision and saturation burst on sneak-right-click with cooldown; chestplate offers strength and periodic damage immunity; leggings grant resistance and invisibility; boots give speed; gauntlet sword adds armor while held and triggers healing or lightning on hit streaks; laser blaster fires a damaging particle beam with ignition. All items are distributed via /nemesis give command.
  • Create the six tagged items with their attributes and model keys.

  • Implement their equipped effects, abilities, cooldowns, and /nemesis give.

Created NemesisGear with /nemesis give and all six item abilities. The command defaults to operators.

The items have the requested model keys; custom visuals require a matching resource pack.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 252
src/main/java/com/kodari/nemesisgear/NemesisGear.java
package com.kodari.nemesisgear;

import com.cryptomorin.xseries.XAttribute;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.command.Command;
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.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
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 org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;

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

public final class NemesisGear extends JavaPlugin implements Listener {
    private NamespacedKey itemKey;
    private final Map<UUID, Long> saturationCooldowns = new HashMap<>();
    private final Map<UUID, Long> blasterCooldowns = new HashMap<>();
    private final Map<UUID, Long> chestCycles = new HashMap<>();
    private final Map<UUID, Integer> hits = new HashMap<>();
    private long tick;

    @Override
    public void onEnable() {
        itemKey = new NamespacedKey(this, "item");
        Bukkit.getPluginManager().registerEvents(this, this);
        Bukkit.getScheduler().runTaskTimer(this, this::updatePlayers, 1L, 1L);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("§cOnly players can receive Nemesis gear.");
            return true;
        }
        if (args.length != 1 || !args[0].equalsIgnoreCase("give")) return false;
        Player player = (Player) sender;
        give(player, create("nemesis_helmet", "NETHERITE_HELMET", "§5Nemesis Helmet", EquipmentSlot.HEAD, 4, 3, 0));
        give(player, create("nemesis_chestplate", "NETHERITE_CHESTPLATE", "§5Nemesis Chestplate", EquipmentSlot.CHEST, 9, 3, 20));
        give(player, create("nemesis_leggings", "NETHERITE_LEGGINGS", "§5Nemesis Leggings", EquipmentSlot.LEGS, 7, 3, 0));
        give(player, create("nemesis_boots", "NETHERITE_BOOTS", "§5Nemesis Boots", EquipmentSlot.FEET, 4, 3, 0));
        give(player, create("gauntlet_sword", "NETHERITE_SWORD", "§5Nemesis Gauntlet Sword", EquipmentSlot.HAND, 10, 0, 0));
        give(player, create("laser_blaster", "BLAZE_ROD", "§5Nemesis Laser Blaster", null, 0, 0, 0));
        player.sendMessage("§5You received the Nemesis gear set.");
        return true;
    }

    private void give(Player player, ItemStack item) {
        player.getInventory().addItem(item).values().forEach(leftover -> player.getWorld().dropItemNaturally(player.getLocation(), leftover));
    }

    private ItemStack create(String id, String material, String name, EquipmentSlot slot, double armor, double toughness, double health) {
        ItemStack item = XMaterial.matchXMaterial(material).map(XMaterial::parseItem)
                .orElseThrow(() -> new IllegalStateException("Missing material: " + material));
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(name);
        meta.setUnbreakable(true);
        meta.setItemModel(new NamespacedKey("nemesis", id));
        meta.getPersistentDataContainer().set(itemKey, PersistentDataType.STRING, id);
        if (armor != 0) addAttribute(meta, "armor", id + "_armor", armor, slot);
        if (toughness != 0) addAttribute(meta, "armor_toughness", id + "_toughness", toughness, slot);
        if (health != 0) addAttribute(meta, "max_health", id + "_health", health, slot);
        item.setItemMeta(meta);
        return item;
    }

    private void addAttribute(ItemMeta meta, String attribute, String key, double amount, EquipmentSlot slot) {
        XAttribute.of(attribute).ifPresent(value -> meta.addAttributeModifier(value.get(),
                XAttribute.createModifier("nemesis:" + key, amount, AttributeModifier.Operation.ADD_NUMBER, slot)));
    }

    private boolean isItem(ItemStack item, String id) {
        if (item == null || !item.hasItemMeta()) return false;
        return id.equals(item.getItemMeta().getPersistentDataContainer().get(itemKey, PersistentDataType.STRING));
    }

    private void effect(Player player, String type, int duration, int amplifier) {
        XPotion.matchXPotion(type).map(potion -> potion.buildPotionEffect(duration, amplifier)).ifPresent(player::addPotionEffect);
    }

    private void updatePlayers() {
        tick++;
        for (Player player : Bukkit.getOnlinePlayers()) {
            UUID id = player.getUniqueId();
            if (tick % 20 == 0) {
                if (isItem(player.getInventory().getHelmet(), "nemesis_helmet")) effect(player, "NIGHT_VISION", 240, 0);
                if (isItem(player.getInventory().getChestplate(), "nemesis_chestplate")) effect(player, "STRENGTH", 60, 1);
                if (isItem(player.getInventory().getLeggings(), "nemesis_leggings")) {
                    effect(player, "RESISTANCE", 60, 1);
                    effect(player, "INVISIBILITY", 60, 0);
                }
                if (isItem(player.getInventory().getBoots(), "nemesis_boots")) effect(player, "SPEED", 60, 2);
            }
            if (isItem(player.getInventory().getChestplate(), "nemesis_chestplate")) {
                long start = chestCycles.computeIfAbsent(id, ignored -> tick);
                long cycle = (tick - start) % 600;
                if (tick % 10 == 0) {
                    boolean immune = cycle >= 400;
                    long remaining = ((immune ? 600 : 400) - cycle + 19) / 20;
                    String status = immune ? "§bImmunity: " + remaining + "s" : "§7Immunity recharge: " + remaining + "s";
                    Long cooldown = saturationCooldowns.get(id);
                    if (cooldown != null && cooldown > tick) status += " §6| Saturation: " + ((cooldown - tick + 19) / 20) + "s";
                    actionBar(player, status);
                }
            } else {
                chestCycles.remove(id);
                Long until = saturationCooldowns.get(id);
                if (until != null && until > tick && tick % 10 == 0) {
                    actionBar(player, "§6Saturation cooldown: " + ((until - tick + 19) / 20) + "s");
                }
            }
        }
    }

    private void actionBar(Player player, String text) {
        player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(text));
    }

    @EventHandler(ignoreCancelled = true)
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)) return;
        Player player = event.getPlayer();
        UUID id = player.getUniqueId();
        ItemStack held = player.getInventory().getItemInMainHand();
        if (isItem(held, "laser_blaster")) {
            event.setCancelled(true);
            if (tick < blasterCooldowns.getOrDefault(id, 0L)) return;
            blasterCooldowns.put(id, tick + 5);
            fireLaser(player);
        } else if (held.getType().isAir() && player.isSneaking() && isItem(player.getInventory().getHelmet(), "nemesis_helmet")) {
            event.setCancelled(true);
            long until = saturationCooldowns.getOrDefault(id, 0L);
            if (tick < until) {
                actionBar(player, "§6Saturation cooldown: " + ((until - tick + 19) / 20) + "s");
                return;
            }
            saturationCooldowns.put(id, tick + 300);
            effect(player, "SATURATION", 100, 2);
            actionBar(player, "§6Saturation activated!");
        }
    }

    private void fireLaser(Player player) {
        Location origin = player.getEyeLocation();
        Vector direction = origin.getDirection().normalize();
        RayTraceResult result = player.getWorld().rayTrace(origin, direction, 50, FluidCollisionMode.NEVER, true, 0.2,
                entity -> entity instanceof LivingEntity && !entity.equals(player));
        double distance = result == null ? 50 : result.getHitPosition().distance(origin.toVector());
        Particle.DustOptions dust = new Particle.DustOptions(Color.RED, 1.2F);
        XParticle.of("DUST").ifPresent(particle -> {
            for (double d = 0; d <= distance; d += 0.25) {
                Location point = origin.clone().add(direction.clone().multiply(d));
                player.getWorld().spawnParticle(particle.get(), point, 1, 0, 0, 0, 0, dust);
            }
        });
        if (result != null && result.getHitEntity() instanceof LivingEntity) {
            LivingEntity target = (LivingEntity) result.getHitEntity();
            target.damage(16.0, player);
            target.setFireTicks(60);
        }
    }

    @EventHandler(ignoreCancelled = true)
    public void onDamage(EntityDamageEvent event) {
        if (!(event.getEntity() instanceof Player)) return;
        Player player = (Player) event.getEntity();
        if (!isItem(player.getInventory().getChestplate(), "nemesis_chestplate")) return;
        long start = chestCycles.computeIfAbsent(player.getUniqueId(), ignored -> tick);
        if ((tick - start) % 600 >= 400) {
            event.setCancelled(true);
            XSound.matchXSound("BLOCK_ANVIL_LAND").ifPresent(sound -> sound.play(player));
            actionBar(player, "§bDamage blocked!");
        }