All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.k3nder.core.mc.clients.CustomLoader Maven / Gradle / Ivy

The newest version!
package net.k3nder.core.mc.clients;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;

import net.k3nder.core.mc.Vmc;
import net.k3nder.core.mc.VersionType;
import net.kender.Kjson.Json;

public abstract class CustomLoader extends Vmc {
	public static String API_VERSION_JSON ;
	public static String API_VERSION_LOADER;
	protected static CType type;
	protected CustomLoader(String version, String loader,CType type,String API_VERSION_LOADER,String API_VERSION_JSON) throws URISyntaxException, JsonProcessingException {
        super(generateId(version, loader), VersionType.custom, new URI(generateUrl(version, loader)),generateIdV(version, loader));
		CustomLoader.API_VERSION_LOADER = API_VERSION_LOADER;
		CustomLoader.API_VERSION_JSON = API_VERSION_JSON;
	}
    protected static String generateId(String version, String loader) throws JsonProcessingException {
        String url = generateUrl(version,loader);
        return Json.jContentOf(url).get("id").asText();
    }
    protected static String generateIdV(String version, String loader) throws JsonProcessingException {
        String url = generateUrl(version,loader);
        return Json.jContentOf(url).get("inheritsFrom").asText();
    }
    protected static String generateUrl(String version, String loader) {
		return String.format(API_VERSION_JSON, version,loader);
    }
    
	public static List getLoadersVersions(String version) throws  JsonProcessingException{
		ArrayList l = new ArrayList<>();
		JsonNode root = Json.jContentOf(String.format("", version));
		for(JsonNode s:root) {
			l.add(s.get("loader").get("version").asText());
		}
		return l;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy