Duy Luân Lê

Hãy tạo cho tôi plugin 26.2 sẽ cho tôi lệnh /giveob nuke / stab / wither giống unstable smp orbital strike cannon

Kodari AI
KodariOct 11 at 7:11 am 1
OrbitalStrikeCannon
A Minecraft plugin that adds three devastating weapon commands: /giveob nuke creates a massive explosion with fire and shockwave damage, /giveob stab launches a lightning-infused blade that strikes targets with electric fury, and /giveob wither summons a withering plague that spreads decay and destruction. Each weapon has configurable power levels, cooldowns, and visual effects. The nuke creates a mushroom cloud with intense damage radius, the stab delivers a piercing lightning strike with chain damage, and the wither applies progressive withering effects to all nearby entities. Includes admin permission controls, particle effects, sound effects, and server performance optimization. Perfect for PvP servers, event battles, and dramatic gameplay moments. Features include configurable damage multipliers, explosion radius settings, cooldown timers, and particle intensity options for server customization.
  1. Tạo cấu hình plugin Paper cho Minecraft 26.2.

  2. Thêm /giveob <nuke|stab|wither> [người chơi] để cấp pháo quỹ đạo theo chế độ.

  3. Cho chuột phải ngắm khối trong tầm 100 block để gọi tia đánh và hiệu ứng riêng từng chế độ.

Đã tạo plugin OrbitalStrike cho Paper 26.2.

Dùng /giveob nuke, /giveob stab hoặc /giveob wither; thêm tên người chơi để đưa pháo cho họ, ví dụ /giveob nuke Steve. Chuột phải khi ngắm khối trong tầm 100 block để khai hỏa. Nuke gây nổ lớn, phá block và tạo lửa.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 255
src/main/java/com/kodari/orbitalstrike/OrbitalStrikePlugin.java
package com.kodari.orbitalstrike;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import com.cryptomorin.xseries.particles.XParticle;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
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.block.Action;
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 org.bukkit.scheduler.BukkitRunnable;

import java.util.Locale;

public final class OrbitalStrikePlugin extends JavaPlugin implements Listener, CommandExecutor {
    private NamespacedKey modeKey;

    @Override
    public void onEnable() {
        modeKey = new NamespacedKey(this, "orbital_mode");
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("giveob").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length < 1 || args.length > 2) {
            sender.sendMessage("&cDùng: /giveob <nuke|stab|wither> [người chơi]");
            return true;
        }

        Mode mode = Mode.fromName(args[0]);
        if (mode == null) {
            sender.sendMessage("&cChế độ hợp lệ: nuke, stab, wither.");
            return true;
        }

        Player recipient;
        if (args.length == 2) {
            recipient = getServer().getPlayerExact(args[1]);
            if (recipient == null) {
                sender.sendMessage("&cKhông tìm thấy người chơi đang trực tuyến đó.");
                return true;
            }
        } else if (sender instanceof Player player) {
            recipient = player;
        } else {
            sender.sendMessage("&cConsole cần chỉ định người chơi: /giveob <nuke|stab|wither> <người chơi>");
            return true;
        }

        recipient.getInventory().addItem(createCannon(mode)).values()
                .forEach(item -> recipient.getWorld().dropItemNaturally(recipient.getLocation(), item));
        recipient.sendMessage("&aBạn nhận được Orbital Strike Cannon &f(" + mode.displayName + "&f). Chuột phải để khai hỏa.");
        if (sender != recipient) {
            sender.sendMessage("&aĐã đưa Orbital Strike Cannon " + mode.displayName + " &acho " + recipient.getName() + ".");
        }
        return true;
    }

    @EventHandler
    public void onUseCannon(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)) {
            return;
        }

        ItemStack item = event.getItem();
        if (item == null || !item.hasItemMeta()) {
            return;
        }

        String storedMode = item.getItemMeta().getPersistentDataContainer().get(modeKey, PersistentDataType.STRING);
        Mode mode = storedMode == null ? null : Mode.fromName(storedMode);
        if (mode == null) {
            return;
        }

        event.setCancelled(true);
        Player player = event.getPlayer();
        Block target = player.getTargetBlockExact(100);
        if (target == null) {
            player.sendMessage("&cKhông có mục tiêu trong tầm 100 block.");
            return;
        }

        Location impact = target.getLocation().add(0.5, 1.0, 0.5);
        player.sendMessage("&eĐã khóa mục tiêu &6" + mode.displayName + "&e!");
        launchStrike(player, impact, mode);
    }

    private ItemStack createCannon(Mode mode) {
        String materialName = switch (mode) {
            case NUKE -> "FIRE_CHARGE";
            case STAB -> "TRIDENT";
            case WITHER -> "WITHER_SKELETON_SKULL";
        };
        ItemStack item = XMaterial.matchXMaterial(materialName).map(XMaterial::parseItem).orElse(null);
        if (item == null) {
            item = XMaterial.matchXMaterial("BLAZE_ROD").map(XMaterial::parseItem).orElseThrow();
        }

        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("&6&lOrbital Strike Cannon &8[" + mode.displayName + "&8]");
        meta.setLore(java.util.List.of("&7Chuột phải để khóa mục tiêu.", "&7Tầm bắn: &f100 block", "&8Chế độ: " + mode.displayName));
        meta.getPersistentDataContainer().set(modeKey, PersistentDataType.STRING, mode.name());
        item.setItemMeta(meta);
        return item;
    }

    private void launchStrike(Player shooter, Location impact, Mode mode) {
        double impactY = impact.getY();
        double startY = Math.min(impactY + 80.0, impact.getWorld().getMaxHeight() - 2.0);
        startY = Math.max(startY, impactY + 20.0);
        double beamStartY = startY;
        double step = (beamStartY - impactY) / 20.0;

        new BukkitRunnable() {
            private int tick;

            @Override
            public void run() {
                if (tick >= 20) {
                    detonate(shooter, impact, mode);
                    cancel();
                    return;
                }

                double y = beamStartY - step * tick;
                Location beamPoint = new Location(impact.getWorld(), impact.getX(), y, impact.getZ());
                XParticle.of("END_ROD").ifPresent(particle -> impact.getWorld().spawnParticle(particle.get(), beamPoint, 8, 0.18, step / 2.0, 0.18, 0.02));
                XParticle.of("FLAME").ifPresent(particle -> impact.getWorld().spawnParticle(particle.get(), beamPoint, 5, 0.12, step / 2.0, 0.12, 0.01));
                tick++;
            }
        }.runTaskTimer(this, 0L, 1L);
    }

    private void detonate(Player shooter, Location impact, Mode mode) {
        double x = impact.getX();
        double y = impact.getY();
        double z = impact.getZ();

        switch (mode) {
            case NUKE -> {
                impact.getWorld().createExplosion(x, y, z, 8.0f, true, true);
                spawnImpactParticles(impact, "EXPLOSION", 30);
                playSound(impact, "ENTITY_GENERIC_EXPLODE");
            }
            case STAB -> {
                impact.getWorld().strikeLightningEffect(impact);
                for (Entity entity : impact.getWorld().getNearbyEntities(impact, 3.0, 4.0, 3.0)) {
                    if (entity instanceof LivingEntity living && entity.getLocation().distanceSquared(impact) <= 16.0) {
                        living.damage(20.0, shooter);
                    }
                }
                spawnImpactParticles(impact, "CRIT", 24);
                playSound(impact, "ENTITY_LIGHTNING_BOLT_THUNDER");
            }
            case WITHER -> {
                impact.getWorld().createExplosion(x, y, z, 2.0f, false, false);
                for (Entity entity : impact.getWorld().getNearbyEntities(impact, 7.0, 5.0, 7.0)) {
                    if (entity instanceof LivingEntity living) {
                        living.damage(4.0, shooter);
                        XPotion.matchXPotion("WITHER")
                                .map(potion -> potion.buildPotionEffect(200, 1))
                                .ifPresent(living::addPotionEffect);
                    }
                }
                spawnImpactParticles(impact, "SOUL", 35);
                playSound(impact, "ENTITY_WITHER_SHOOT");
            }
        }
    }

    private void spawnImpactParticles(Location location, String particleName, int count) {
        XParticle.of(particleName).ifPresent(particle -> location.getWorld().spawnParticle(particle.get(), location, count, 0.8, 0.8, 0.8, 0.1));
    }

    private void playSound(Location location, String soundName) {
        com.cryptomorin.xseries.XSound.matchXSound(soundName).ifPresent(sound -> sound.play(location));
    }

    private enum Mode {
        NUKE("&cNuke"),
        STAB("&bStab"),
        WITHER("&5Wither");

        private final String displayName;