package top.r3944realms.lib39.platform;

import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.loading.FMLLoader;
import top.r3944realms.lib39.Lib39;
import top.r3944realms.lib39.platform.services.IHelpCommandHook;
import top.r3944realms.lib39.platform.services.IPlatformHelper;
import top.r3944realms.lib39.platform.services.IUtilHelper;

/**
 * The type Forge platform helper.
 */
public class NeoForgePlatformHelper implements IPlatformHelper {

    @Override
    public String getPlatformName() {
        return "Forge";
    }

    @Override
    public boolean isModLoaded(String modId) {
        return ModList.get().isLoaded(modId);
    }

    @Override
    public boolean isDevelopmentEnvironment() {
        return !FMLLoader.isProduction();
    }

    @Override
    public boolean isClientEnvironment() {
        return FMLEnvironment.dist.isClient();
    }

    @Override
    public String getModVersion() {
        return ModList.get()
                .getModContainerById(Lib39.MOD_ID)
                .map(c -> c.getModInfo().getVersion().toString())
                .orElse("UNKNOWN");
    }

    @Override
    public IUtilHelper getUtilHelper() {
        return NeoForgeUtilHelper.INSTANCE;
    }

    @Override
    public IHelpCommandHook getHelpCommandHook() {
        return NeoForgeHelpCommandHook.INSTANCE;
    }
}
