package dev.okenote.advancement;

import dev.okenote.JediCraft;
import dev.okenote.database.User;
import dev.okenote.database.UserData;
import dev.okenote.entities.player.JediPlayer;
import dev.okenote.managers.ChatManager;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.Command;
import net.minestom.server.command.builder.CommandContext;
import net.minestom.server.command.builder.arguments.Argument;
import net.minestom.server.entity.Player;
import net.minestom.server.network.player.PlayerConnection;
import net.minestom.server.utils.entity.EntityFinder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Getter
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public abstract class JediCommand extends Command {

    JediCraft jediCraft;
    String permission;

    public JediCommand(@NotNull JediCraft jediCraft, String permission, @NotNull String name, @Nullable String... aliases) {
        super(name, aliases);
        this.jediCraft = jediCraft;
        this.permission = permission == null ? "jc.user" : permission;
    }

    public JediCommand(@NotNull JediCraft jediCraft, String permission, @NotNull String name) {
        super(name);
        this.jediCraft = jediCraft;
        this.permission = permission == null ? "jc.user" : permission;
    }

    public void defaultExecutor(@NotNull JediExecutor executor) {
        setDefaultExecutor((sender, context) -> {
            if (sender instanceof Player player) {
                JediPlayer jediPlayer = new JediPlayer(player);
                User user = jediPlayer.getUser();
                UserData userData = jediPlayer.getUserData();
                ChatManager chatManager = jediCraft.getManagerLayer().getChatManager();

                jediPlayer.hasPermission(permission);

                executor.execute(player, jediPlayer, user, userData, chatManager, context);
            } else System.out.println("Команды может отправлять только игрок!");
        });
    }

    public void syntax(@NotNull JediExecutor executor, @NotNull Argument<?>... arguments) {
        addSyntax((sender, context) -> {
            if (sender instanceof Player player) {
                JediPlayer jediPlayer = new JediPlayer(player);
                User user = jediPlayer.getUser();
                UserData userData = jediPlayer.getUserData();
                ChatManager chatManager = jediCraft.getManagerLayer().getChatManager();

                jediPlayer.hasPermission(permission);

                executor.execute(player, jediPlayer, user, userData, chatManager, context);
            } else System.out.println("Команды может отправлять только игрок!");
        }, arguments);
    }

    @FunctionalInterface
    public interface JediExecutor {
        void execute(Player player,
                     JediPlayer jediPlayer,
                     User user,
                     UserData userData,

                     ChatManager chat,
                     CommandContext context);
    }
}

Класс полностью работоспособен, сделай его проще и понятнее