<commit_before>package uk.co.rx14.jmclaunchlib

import groovy.transform.CompileStatic
import groovy.transform.Immutable
import groovy.transform.ToString
import groovy.transform.TypeCheckingMode
import uk.co.rx14.jmclaunchlib.auth.Credentials
import uk.co.rx14.jmclaunchlib.auth.MinecraftAuthResult
import uk.co.rx14.jmclaunchlib.auth.YggdrasilAuth
import uk.co.rx14.jmclaunchlib.caches.MinecraftCaches
import uk.co.rx14.jmclaunchlib.util.Strings
import uk.co.rx14.jmclaunchlib.util.Zip

import java.nio.file.FileSystems
import java.nio.file.Path
import java.util.function.Supplier
import java.util.logging.Logger

@CompileStatic
@ToString(includePackage = false, includeNames = true)
@Immutable(knownImmutableClasses = [Path.class, MinecraftVersion.class])
class MCInstance {

	private static final Logger LOGGER = Logger.getLogger(MCInstance.class.getName())

	Path minecraftDirectory
	MinecraftCaches caches
	MinecraftVersion minecraftVersion
	private Supplier<Credentials> credentialsSupplier

	static MCInstance create(String MCVersion, Path MCDir, Path cachesDir, Supplier<Credentials> credentialsSupplier) {
		def caches = MinecraftCaches.create(cachesDir)
		def instance = new MCInstance(
			caches: caches,
			minecraftVersion: new MinecraftVersion(MCVersion, caches.versions),
			credentialsSupplier: credentialsSupplier,
			minecraftDirectory: MCDir
		)

		LOGGER.fine "Created $instance"

		instance
	}

	static MCInstance create(String MCVersion, String MCDir, String cachesDir, Supplier<Credentials> credentialsSupplier) {
		create(MCVersion, FileSystems.default.getPath(MCDir), FileSystems.default.getPath(cachesDir), credentialsSupplier)
	}

	static MCInstance createForge(String MCVersion, String forgeVersion, Path MCDir, Path cachesDir, Supplier<Credentials> credentialsSupplier) {
		def caches = MinecraftCaches.create(cachesDir)

		def forgeJson = Zip.extractSingleFile(
			caches.libs.resolve("net.minecraftforge:forge:jar:universal:$forgeVersion", "http://files.minecraftforge.net/maven/"),
			"version.json"
		)

		def instance = new MCInstance(
			caches: caches,
			minecraftVersion: new MinecraftVersion(MCVersion, caches.versions, new String(forgeJson)),
			credentialsSupplier: credentialsSupplier,
			minecraftDirectory: MCDir
		)

		LOGGER.fine "Created $instance"

		instance
	}

	static MCInstance createForge(String MCVersion, String forgeVersion, String MCDir, String cachesDir, Supplier<Credentials> credentialsSupplier) {
		createForge(MCVersion, forgeVersion, FileSystems.default.getPath(MCDir), FileSystems.default.getPath(cachesDir), credentialsSupplier)
	}

	LaunchSpec getOfflineLaunchSpec(String username) {
		def spec = new LaunchSpec()

		spec.offline = true

		spec.auth = new MinecraftAuthResult(
			accessToken: '',
			clientToken: '',
			valid: true,
			selectedProfile: new MinecraftAuthResult.Profile(
				name: username,
				id: ''
			)
		)

		_commonTasks(spec)

		spec
	}

	LaunchSpec getLaunchSpec() {
		def spec = new LaunchSpec()

		spec.offline = false

		LOGGER.info "Logging in..."
		spec.auth = new YggdrasilAuth().auth(credentialsSupplier)

		_commonTasks(spec)

		spec
	}
<commit_msg>Supply fake access token<commit_after>package uk.co.rx14.jmclaunchlib

import groovy.transform.CompileStatic
import groovy.transform.Immutable
import groovy.transform.ToString
import groovy.transform.TypeCheckingMode
import uk.co.rx14.jmclaunchlib.auth.Credentials
import uk.co.rx14.jmclaunchlib.auth.MinecraftAuthResult
import uk.co.rx14.jmclaunchlib.auth.YggdrasilAuth
import uk.co.rx14.jmclaunchlib.caches.MinecraftCaches
import uk.co.rx14.jmclaunchlib.util.Strings
import uk.co.rx14.jmclaunchlib.util.Zip

import java.nio.file.FileSystems
import java.nio.file.Path
import java.util.function.Supplier
import java.util.logging.Logger

@CompileStatic
@ToString(includePackage = false, includeNames = true)
@Immutable(knownImmutableClasses = [Path.class, MinecraftVersion.class])
class MCInstance {

	private static final Logger LOGGER = Logger.getLogger(MCInstance.class.getName())

	Path minecraftDirectory
	MinecraftCaches caches
	MinecraftVersion minecraftVersion
	private Supplier<Credentials> credentialsSupplier

	static MCInstance create(String MCVersion, Path MCDir, Path cachesDir, Supplier<Credentials> credentialsSupplier) {
		def caches = MinecraftCaches.create(cachesDir)
		def instance = new MCInstance(
			caches: caches,
			minecraftVersion: new MinecraftVersion(MCVersion, caches.versions),
			credentialsSupplier: credentialsSupplier,
			minecraftDirectory: MCDir
		)

		LOGGER.fine "Created $instance"

		instance
	}

	static MCInstance create(String MCVersion, String MCDir, String cachesDir, Supplier<Credentials> credentialsSupplier) {
		create(MCVersion, FileSystems.default.getPath(MCDir), FileSystems.default.getPath(cachesDir), credentialsSupplier)
	}

	static MCInstance createForge(String MCVersion, String forgeVersion, Path MCDir, Path cachesDir, Supplier<Credentials> credentialsSupplier) {
		def caches = MinecraftCaches.create(cachesDir)

		def forgeJson = Zip.extractSingleFile(
			caches.libs.resolve("net.minecraftforge:forge:jar:universal:$forgeVersion", "http://files.minecraftforge.net/maven/"),
			"version.json"
		)

		def instance = new MCInstance(
			caches: caches,
			minecraftVersion: new MinecraftVersion(MCVersion, caches.versions, new String(forgeJson)),
			credentialsSupplier: credentialsSupplier,
			minecraftDirectory: MCDir
		)

		LOGGER.fine "Created $instance"

		instance
	}

	static MCInstance createForge(String MCVersion, String forgeVersion, String MCDir, String cachesDir, Supplier<Credentials> credentialsSupplier) {
		createForge(MCVersion, forgeVersion, FileSystems.default.getPath(MCDir), FileSystems.default.getPath(cachesDir), credentialsSupplier)
	}

	LaunchSpec getOfflineLaunchSpec(String username) {
		def spec = new LaunchSpec()

		spec.offline = true

		spec.auth = new MinecraftAuthResult(
			accessToken: 'fakeAccessToken',
			clientToken: '',
			valid: true,
			selectedProfile: new MinecraftAuthResult.Profile(
				name: username,
				id: ''
			)
		)

		_commonTasks(spec)

		spec
	}

	LaunchSpec getLaunchSpec() {
		def spec = new LaunchSpec()

		spec.offline = false

		LOGGER.info "Logging in..."
		spec.auth = new YggdrasilAuth().auth(credentialsSupplier)

		_commonTasks(spec)

		spec
	}

{'fraction_non_alphanumeric': 0.08958531180753403, 'fraction_numerical': 0.004431782209559987, 'mean_word_length': 5.637605042016807, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3432758', 'n_tokens_mistral': 2189, 'n_tokens_neox': 1990, 'n_words': 400}