<commit_before>package com.forgeessentials.commons;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Properties;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;

public abstract class BuildInfo
{

    private static final String BUILD_TYPE_NIGHTLY = "nightly";

    private static String buildHash = "N/A";

    private static int buildNumber = 0;

    private static int buildNumberLatest = 0;

    private static Thread checkVersionThread;

    private static Thread checkBuildTypesThread;

    private static Properties buildTypes = new Properties();

    public static final String MC_BASE_VERSION = "1.8";

    public static final String BASE_VERSION = "1.8.0"; // update manually because gradle is a derp

    static
    {
        // Check for latest version asap
        checkVersionThread = new Thread(new Runnable() {
            @Override
            public void run()
            {
                doCheckLatestVersion();
            }
        });
        checkVersionThread.start();

        checkBuildTypesThread = new Thread(new Runnable() {
            @Override
            public void run()
            {
                doCheckBuildTypes();
            }
        });
        checkBuildTypesThread.start();
    }

    public static void getBuildInfo(File jarFile)
    {
        try
        {
            if (jarFile != null)
            {
                try (JarFile jar = new JarFile(jarFile))
                {
                    Manifest manifest = jar.getManifest();
                    buildHash = manifest.getMainAttributes().getValue("BuildID");
                    try
                    {
                        buildNumber = Integer.parseInt(manifest.getMainAttributes().getValue("BuildNumber"));
                    }
                    catch (NumberFormatException e)
                    {
                        buildNumber = 0;
                    }
                }
            }
            else
            {
                System.err.println(String.format("Unable to get FE version information (dev env / %s)", BASE_VERSION));
            }
        }
        catch (IOException e1)
        {
            System.err.println(String.format("Unable to get FE version information (%s)", BASE_VERSION));
        }
    }

    private static void doCheckLatestVersion()
    {
        try
        {
            URL buildInfoUrl = new URL("http://ci.forgeessentials.com/job/FE/lastSuccessfulBuild/api/json");
            URLConnection con = buildInfoUrl.openConnection();
            con.setConnectTimeout(6000);
            con.setReadTimeout(12000);
            con.connect();
            try (InputStreamReader is = new InputStreamReader(con.getInputStream()))
            {
                JsonObject versionInfo = new GsonBuilder().create().fromJson(is, JsonObject.class);
                buildNumberLatest = versionInfo.get("number").getAsInt();
            }
            // TODO update to support milestone/recommended releases
        }
        catch (JsonSyntaxException | JsonIOException e)
        {
            System.err.println("Unable to parse version info");
        }<commit_msg>Fixed url to correct Jenkins job. Fixes #1694<commit_after>package com.forgeessentials.commons;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Properties;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;

public abstract class BuildInfo
{

    private static final String BUILD_TYPE_NIGHTLY = "nightly";

    private static String buildHash = "N/A";

    private static int buildNumber = 0;

    private static int buildNumberLatest = 0;

    private static Thread checkVersionThread;

    private static Thread checkBuildTypesThread;

    private static Properties buildTypes = new Properties();

    public static final String MC_BASE_VERSION = "1.8";

    public static final String BASE_VERSION = "1.8.0"; // update manually because gradle is a derp

    static
    {
        // Check for latest version asap
        checkVersionThread = new Thread(new Runnable() {
            @Override
            public void run()
            {
                doCheckLatestVersion();
            }
        });
        checkVersionThread.start();

        checkBuildTypesThread = new Thread(new Runnable() {
            @Override
            public void run()
            {
                doCheckBuildTypes();
            }
        });
        checkBuildTypesThread.start();
    }

    public static void getBuildInfo(File jarFile)
    {
        try
        {
            if (jarFile != null)
            {
                try (JarFile jar = new JarFile(jarFile))
                {
                    Manifest manifest = jar.getManifest();
                    buildHash = manifest.getMainAttributes().getValue("BuildID");
                    try
                    {
                        buildNumber = Integer.parseInt(manifest.getMainAttributes().getValue("BuildNumber"));
                    }
                    catch (NumberFormatException e)
                    {
                        buildNumber = 0;
                    }
                }
            }
            else
            {
                System.err.println(String.format("Unable to get FE version information (dev env / %s)", BASE_VERSION));
            }
        }
        catch (IOException e1)
        {
            System.err.println(String.format("Unable to get FE version information (%s)", BASE_VERSION));
        }
    }

    private static void doCheckLatestVersion()
    {
        try
        {
            URL buildInfoUrl = new URL("http://ci.forgeessentials.com/job/FE-1.8/lastSuccessfulBuild/api/json");
            URLConnection con = buildInfoUrl.openConnection();
            con.setConnectTimeout(6000);
            con.setReadTimeout(12000);
            con.connect();
            try (InputStreamReader is = new InputStreamReader(con.getInputStream()))
            {
                JsonObject versionInfo = new GsonBuilder().create().fromJson(is, JsonObject.class);
                buildNumberLatest = versionInfo.get("number").getAsInt();
            }
            // TODO update to support milestone/recommended releases
        }
        catch (JsonSyntaxException | JsonIOException e)
        {
            System.err.println("Unable to parse version info");
        }
{'fraction_non_alphanumeric': 0.08830409356725147, 'fraction_numerical': 0.0061403508771929825, 'mean_word_length': 1.81406828465652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3519474', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1668, 'n_words': 409}