veryunspecialperson12513
📎 1 file 11,689 chars
📄
pasted-code-1774754923800.txt
txt 295 lines
▶
package me.limited.core;

import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.*;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

import java.util.*;

public class Limited extends JavaPlugin implements Listener, CommandExecutor {

    public final Map abilityMap = new HashMap<>();
    public final Map levelMap = new HashMap<>();
    public final Map killsMap = new HashMap<>();
    public final Map cooldownMap = new HashMap<>();
    public final Map> cosmicFrozen = new HashMap<>();
    public final Map pvpBlockMap = new HashMap<>();

    private final Random random = new Random();

    public enum AbilityType { FIREBALL, ICE, LIGHTNING, DASH, COSMIC }

    private final int MAX_LEVEL = 5;
    private final int LEVEL5_KILLS = 20;

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
        getCommand("ability").setExecutor(this);
        getCommand("randomize").setExecutor(this);
        getLogger().info("Limited plugin (Kodari-ready) enabled!");
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        Player player = e.getPlayer();
        if (!abilityMap.containsKey(player.getUniqueId())) {
            assignRandomAbility(player);
        }
    }

    public void assignRandomAbility(Player player) {
        AbilityType ability = getRandomAbility();
        abilityMap.put(player.getUniqueId(), ability);
        levelMap.put(player.getUniqueId(), 1);
        killsMap.put(player.getUniqueId(), 0);
        sendAbilityTitle(player, ability);
    }

    public void sendAbilityTitle(Player player, AbilityType ability) {
        player.sendTitle(ChatColor.GOLD + "LIMITED", ChatColor.AQUA + ability.name(), 10, 60, 20);
        player.sendMessage(ChatColor.GRAY + "Press F (swap hand) to use your ability!");
    }

    public AbilityType getRandomAbility() {
        AbilityType[] values = AbilityType.values();
        return values[random.nextInt(values.length)];
    }

    @EventHandler
    public void onKill(EntityDeathEvent e) {
        if (!(e.getEntity() instanceof Player victim)) return;
        if (!(e.getEntity().getKiller() instanceof Player killer)) return;

        UUID id = killer.getUniqueId();
        int kills = killsMap.getOrDefault(id, 0) + 1;
        killsMap.put(id, kills);

        int level = calculateLevel(id);
        levelMap.put(id, level);

        killer.sendMessage(ChatColor.LIGHT_PURPLE + "Kills: " + kills + " | Ability Level: " + level);
    }

    public int calculateLevel(UUID playerId) {
        int kills = killsMap.getOrDefault(playerId, 0);
        if (kills >= LEVEL5_KILLS) return MAX_LEVEL;
        return Math.min(1 + kills / 5, MAX_LEVEL);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (cmd.getName().equalsIgnoreCase("ability")) {
            if (!(sender instanceof Player p)) return true;
            executeAbility(p);
            return true;
        }

        if (cmd.getName().equalsIgnoreCase("randomize")) {
            if (!sender.isOp()) {
                sender.sendMessage(ChatColor.RED + "Only operators can use this.");
                return true;
            }
            if (args.length < 1) {
                sender.sendMessage(ChatColor.RED + "Usage: /randomize ");
                return true;
            }

            Player target = Bukkit.getPlayerExact(args[0]);
            if (target == null) {
                sender.sendMessage(ChatColor.RED + "Player not found.");
                return true;
            }

            assignRandomAbility(target);
            showAbilityTextFront(target, ChatColor.AQUA + abilityMap.get(target.getUniqueId()).name());
            target.sendMessage(ChatColor.GOLD + "Your ability has been randomized!");
            sender.sendMessage(ChatColor.GREEN + "Randomized " + target.getName() + "'s ability.");
            return true;
        }

        return true;
    }

    // RANDOMIZE TEXT IN FRONT
    public void showAbilityTextFront(Player target, String text) {
        Location loc = target.getLocation().add(target.getLocation().getDirection().multiply(2)).add(0,1,0);
        ArmorStand hologram = target.getWorld().spawn(loc, ArmorStand.class, stand -> {
            stand.setVisible(false);
            stand.setMarker(true);
            stand.setGravity(false);
            stand.setCustomName(text);
            stand.setCustomNameVisible(true);
        });

        new BukkitRunnable() {
            int ticks = 0;
            @Override
            public void run() {
                if (ticks > 40) {
                    hologram.remove();
                    cancel();
                    return;
                }
                hologram.teleport(hologram.getLocation().add(target.getLocation().getDirection().multiply(0.05)));
                ticks++;
            }
        }.runTaskTimer(this,0L,1L);
    }

    // PvP BLOCK & COSMIC
    @EventHandler
    public void onPvP(EntityDamageByEntityEvent e) {
        if (!(e.getDamager() instanceof Player attacker)) return;
        if (!(e.getEntity() instanceof Player victim)) return;

        for (Map.Entry> entry : cosmicFrozen.entrySet()) {
            if (entry.getValue().contains(victim.getUniqueId()) && entry.getKey().equals(attacker.getUniqueId())) {
                e.setCancelled(true);
            }
        }

        Long blockedUntil = pvpBlockMap.get(victim.getUniqueId());
        if (blockedUntil != null && System.currentTimeMillis() < blockedUntil) e.setCancelled(true);
    }

    // ===== KEYBIND F TRIGGER =====
    @EventHandler
    public void onSwap(PlayerSwapHandItemsEvent e) {
        e.setCancelled(true); // cancel normal swap
        executeAbility(e.getPlayer());
    }

    // EXECUTE ABILITY
    public void executeAbility(Player player) {
        UUID id = player.getUniqueId();
        if (!abilityMap.containsKey(id)) return;

        long now = System.currentTimeMillis();
        if (cooldownMap.containsKey(id) && now - cooldownMap.get(id) < 5000) {
            player.sendMessage(ChatColor.RED + "Ability on cooldown...");
            return;
        }
        cooldownMap.put(id, now);

        AbilityType ability = abilityMap.get(id);
        int level = levelMap.getOrDefault(id,1);

        switch (ability) {
            case FIREBALL -> abilityFireball(player, level);
            case ICE -> abilityIce(player, level);
            case LIGHTNING -> abilityLightning(player, level);
            case DASH -> abilityDash(player, level);
            case COSMIC -> abilityCosmic(player, level);
        }
    }

    // ================= ABILITIES =================
    public void abilityFireball(Player p, int level) {
        Fireball fb = p.launchProjectile(Fireball.class);
        fb.setVelocity(p.getLocation().getDirection().multiply(1.0 + level*0.1));
        fb.setYield(0F);

        new BukkitRunnable() {
            @Override
            public void run() {
                if (!fb.isValid()) {
                    Block b = fb.getLocation().getBlock();
                    if (b.getType().isAir()) b.setType(Material.MAGMA_BLOCK);
                    cancel();
                }
            }
        }.runTaskTimer(this,0L,1L);

        p.getWorld().spawnParticle(Particle.FLAME,p.getLocation(),5,0.2,0.2,0.2);
        p.sendMessage("🔥 Fireball Lv." + level);
    }

    public void abilityIce(Player p, int level) {
        for (Entity e : p.getNearbyEntities(3+level,3,3+level)) {
            if (e instanceof Player target && target != p) {
                target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60+level*20, 2,false,false,false));
                target.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60+level*20, 1,false,false,false));
                target.setFreezeTicks(60+level*20);

                Block b = target.getLocation().getBlock().getRelative(0,-1,0);
                if (b.getType().isAir()) b.setType(Material.BLUE_ICE);
            }
        }
        p.getWorld().spawnParticle(Particle.SNOW_SHOVEL,p.getLocation(),5,0.2,0.2,0.2);
        p.sendMessage("❄️ Ice Lv." + level);
    }

    public void abilityLightning(Player p, int level) {
        Block targetBlock = p.getTargetBlockExact(30);
        Location loc = targetBlock != null ? targetBlock.getLocation() : p.getLocation().add(p.getLocation().getDirection().multiply(10));
        p.getWorld().strikeLightningEffect(loc);
        p.getWorld().spawnParticle(Particle.ELECTRIC_SPARK,loc,5,0.3,0.3,0.3);
        p.sendMessage("⚡ Lightning Lv." + level);
    }

    public void abilityDash(Player p, int level) {
        Vector v = p.getLocation().getDirection().multiply(0.8 + level*0.2);
        p.setVelocity(v);
        p.getWorld().spawnParticle(Particle.CLOUD,p.getLocation(),5,0.2,0.2,0.2);
        p.sendMessage("💨 Dash Lv." + level);
    }

    public void abilityCosmic(Player user, int level) {
        Location center = user.getLocation();
        double radius = 3 + level;
        double height = 2;

        Set frozenPlayers = new HashSet<>();
        for (Entity e : center.getWorld().getNearbyEntities(center,radius,height,radius)) {
            if (e instanceof Player p && p != user) {
                frozenPlayers.add(p.getUniqueId());
                p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,60+level*20,2,false,false,false));
                p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,60+level*20,1,false,false,false));
            }
        }
        cosmicFrozen.put(user.getUniqueId(), frozenPlayers);

        new BukkitRunnable() {
            int ticks = 0;
            @Override
            public void run() {
                if (ticks>40) {
                    for (UUID id : frozenPlayers) {
                        Player p = Bukkit.getPlayer(id);
                        if (p!=null) {
                            p.removePotionEffect(PotionEffectType.SLOW);
                            p.removePotionEffect(PotionEffectType.JUMP);
                            pvpBlockMap.put(p.getUniqueId(), System.currentTimeMillis()+3000);
                        }
                    }
                    cancel();
                    return;
                }

                for (double y=0;y<=height;y+=0.5) {
                    int points = 15;
                    for (int i=0;i
Kodari AI
KodariMar 29 at 3:30 am 16,618 (v2)

I’ll convert this single-file plugin into a proper multi-file Kodari structure with managers, data classes, XSeries compatibility, and better organization.

Limited
A PvP abilities plugin that assigns each player a random combat ability (Fireball, Ice, Lightning, Dash, or Cosmic) with a kill-based leveling system. Players level up their abilities through kills, unlock stronger effects at higher levels, and can use abilities via keybind. Features include cooldown management, cosmic freeze mechanics, and PvP protection systems.

Project restructured successfully! The single-file plugin has been converted into a professional multi-file architecture with:

  • Data layer: PlayerData with Lombok annotations for clean data management

  • Manager layer: Separate managers for player data, abilities, cooldowns, and combat mechanics

  • Command layer: Dedicated command classes for /ability and /randomize

  • Listener layer: Event handlers split by responsibility

  • Ability system: AbilityExecutor handles all 5 ability types with configurable values

  • XSeries integration: All Bukkit enums converted to cross-version compatible XSeries calls

  • Configuration: Comprehensive config.yml with customizable settings and messages

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
17 820
src/main/java/me/limited/core/Limited.java
package me.limited.core;

import lombok.Getter;
import me.limited.core.command.AbilityCommand;
import me.limited.core.command.RandomizeCommand;
import me.limited.core.listener.EntityDamageListener;
import me.limited.core.listener.EntityDeathListener;
import me.limited.core.listener.PlayerJoinListener;
import me.limited.core.listener.PlayerSwapHandItemsListener;
import me.limited.core.manager.AbilityManager;
import me.limited.core.manager.CombatManager;
import me.limited.core.manager.CooldownManager;
import me.limited.core.manager.PlayerDataManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class Limited extends JavaPlugin {
    private PlayerDataManager playerDataManager;
    private AbilityManager abilityManager;
    private CooldownManager cooldownManager;
    private CombatManager combatManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        int cooldownSeconds = getConfig().getInt("settings.ability-cooldown-seconds", 5);

        this.playerDataManager = new PlayerDataManager();
        this.cooldownManager = new CooldownManager(cooldownSeconds);
        this.combatManager = new CombatManager();
        this.abilityManager = new AbilityManager(this);

        registerListeners();
        registerCommands();

        getLogger().info("Limited plugin enabled!");
    }

    @Override
    public void onDisable() {
        getLogger().info("Limited plugin disabled!");
    }

    private void registerListeners() {
        Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
        Bukkit.getPluginManager().registerEvents(new EntityDeathListener(this), this);
        Bukkit.getPluginManager().registerEvents(new PlayerSwapHandItemsListener(this), this);
        Bukkit.getPluginManager().registerEvents(new EntityDamageListener(this), this);
    }

    private void registerCommands() {
        getCommand("ability").setExecutor(new AbilityCommand(this));
        getCommand("randomize").setExecutor(new RandomizeCommand(this));
    }
}