package com.mingliqiye.minecraft.enchantment.conflict.mixin;

import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;
import com.mingliqiye.minecraft.enchantment.conflict.network.ConfigPayload;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(PlayerManager.class)
public abstract class PlayerManagerMixin {

    @Inject(method = "onPlayerConnect", at = @At("RETURN"))
    private void onPlayerConnect(
            ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData,
            CallbackInfo ci
    ) {
        ConfigPayload.sendToPlayer(player);
    }
}
