Кирпич2

He must turn me into TV Mena and give me his abilities.He must turn me into TV Mena and give me his abilities.

Kodari AI
KodariOct 12 at 8:31 pm 1
TVMenaTransform
A Minecraft plugin that transforms the player into TV Mena, granting them unique abilities. When activated, the player's appearance changes to resemble TV Mena with a custom skin and glowing effect. The plugin provides special powers including enhanced speed, jump boost, and a unique attack that emits a blinding flash to nearby enemies. Players can toggle the transformation with a command or item, and the effect includes particle trails and sound effects. The transformation has a configurable duration and cooldown, with permissions for use and admin control.

I’ll create a Paper plugin that lets players transform into TV Man, gain a defensive speed boost, and use flash and dash abilities.

Created the TV Man plugin. Use /tvman (or /tvmena) to transform, /tvman flash to knock back nearby players, and /tvman dash to surge forward. While transformed, you glow, move faster, and take 20% less damage. The transformation is gameplay-only; it doesn’t add a TV-head model.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 182
src/main/java/com/kodari/tvman/TvManPlugin.java
package com.kodari.tvman;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

public final class TvManPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private final Map<UUID, TransformationState> transformedPlayers = new HashMap<>();
    private final Map<UUID, Long> flashCooldowns = new HashMap<>();
    private final Map<UUID, Long> dashCooldowns = new HashMap<>();

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("tvman").setExecutor(this);
    }

    @Override
    public void onDisable() {
        for (UUID playerId : transformedPlayers.keySet().toArray(new UUID[0])) {
            Player player = Bukkit.getPlayer(playerId);
            if (player != null) {
                restorePlayer(player);
            }
        }
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("This command can only be used by a player.");
            return true;
        }

        if (args.length == 0) {
            toggleTransformation(player);
            return true;
        }

        if (!transformedPlayers.containsKey(player.getUniqueId())) {
            player.sendMessage("&cTransform into TV Man first with /tvman.");
            return true;
        }

        switch (args[0].toLowerCase()) {
            case "flash" -> useFlash(player);
            case "dash" -> useDash(player);
            default -> player.sendMessage("&eUsage: /tvman [flash|dash]");
        }
        return true;
    }

    private void toggleTransformation(Player player) {
        if (transformedPlayers.containsKey(player.getUniqueId())) {
            restorePlayer(player);
            player.sendMessage("&7You returned to normal.");
            return;
        }

        transformedPlayers.put(player.getUniqueId(), new TransformationState(player.getWalkSpeed(), player.isGlowing()));
        player.setWalkSpeed(0.3F);
        player.setGlowing(true);
        player.sendMessage("&bYou transformed into TV Man! Use /tvman flash or /tvman dash.");
    }

    private void restorePlayer(Player player) {
        TransformationState state = transformedPlayers.remove(player.getUniqueId());
        if (state != null) {
            player.setWalkSpeed(state.walkSpeed());
            player.setGlowing(state.glowing());
        }
        flashCooldowns.remove(player.getUniqueId());
        dashCooldowns.remove(player.getUniqueId());
    }

    private void useFlash(Player player) {
        if (checkCooldown(player, flashCooldowns, 10)) {
            return;
        }
        flashCooldowns.put(player.getUniqueId(), System.currentTimeMillis() + 10_000L);

        int affected = 0;
        for (Entity entity : player.getNearbyEntities(8, 8, 8)) {
            if (!(entity instanceof Player target) || target.getLocation().distanceSquared(player.getLocation()) > 64) {
                continue;
            }

            Vector knockback = target.getLocation().toVector().subtract(player.getLocation().toVector());
            if (knockback.lengthSquared() == 0) {
                knockback = player.getLocation().getDirection();
            }
            target.setVelocity(knockback.normalize().multiply(1.1).setY(0.45));
            target.sendTitle("&f", "&fTV FLASH", 0, 15, 0);
            affected++;
        }

        player.sendMessage("&bTV flash released! &7Affected players: " + affected);
    }

    private void useDash(Player player) {
        if (checkCooldown(player, dashCooldowns, 3)) {
            return;
        }
        dashCooldowns.put(player.getUniqueId(), System.currentTimeMillis() + 3_000L);
        Vector velocity = player.getLocation().getDirection().normalize().multiply(1.7).setY(0.35);
        player.setVelocity(velocity);
        player.sendMessage("&bYou dashed forward!");
    }

    private boolean checkCooldown(Player player, Map<UUID, Long> cooldowns, int cooldownSeconds) {
        long remaining = cooldowns.getOrDefault(player.getUniqueId(), 0L) - System.currentTimeMillis();
        if (remaining <= 0) {
            return false;
        }
        player.sendMessage("&cAbility ready in " + ((remaining + 999) / 1000) + "s.");
        return true;
    }

    @EventHandler
    public void onPlayerDamage(EntityDamageEvent event) {
        if (event.getEntity() instanceof Player player && transformedPlayers.containsKey(player.getUniqueId())) {
            event.setDamage(event.getDamage() * 0.8);
        }
    }

    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        restorePlayer(event.getPlayer());
    }

    private record TransformationState(float walkSpeed, boolean glowing) {
    }
}