Skip to content

Commit

Permalink
Custom progress bar API
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Sep 18, 2023
1 parent 209ffaf commit 6793274
Show file tree
Hide file tree
Showing 9 changed files with 421 additions and 129 deletions.
100 changes: 0 additions & 100 deletions build.gradle

This file was deleted.

96 changes: 96 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
plugins {
id("fabric-loom") version "1.0.17"
id("io.github.juuxel.loom-quiltflower") version "1.8.0"
`maven-publish`
}

operator fun Project.get(prop: String) = extra[prop] as String

version = project["mod_version"]
group = project["maven_group"]
base.archivesName.set(project["archives_base_name"])

val api by sourceSets.registering {
compileClasspath += sourceSets.main.get().compileClasspath
}

repositories {
maven("https://maven.lenni0451.net/releases")
}

dependencies {
// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.extra["minecraft_version"]}")
mappings("net.fabricmc:yarn:${project.extra["yarn_mappings"]}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.extra["loader_version"]}")

include(implementation("net.lenni0451:Reflect:1.0.2")!!)
include(implementation("com.formdev:flatlaf:3.0")!!)
}

tasks.jar {
includeEmptyDirs = false
}

val apiJar by tasks.registering(Jar::class) {
from(api.get().output)
archiveClassifier.set("api")
}
tasks.build {
dependsOn(apiJar)
}

tasks.processResources {
inputs.property("version", project.version)
filteringCharset = "UTF-8"

filesMatching("fabric.mod.json") {
expand("version" to project.version)
}
}

val targetJavaVersion = 8
tasks.withType<JavaCompile>().configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
options.encoding = "UTF-8"
if (JavaVersion.current().isJava10Compatible) {
options.release.set(targetJavaVersion)
}
}

java {
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
}
withSourcesJar()
}

tasks.named<Jar>("sourcesJar") {
from(api.get().allSource)
}

tasks.jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}" }
}
}

// configure the maven publication
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(apiJar.get().archiveFile) {
classifier = "api"
}
}
}

repositories {
mavenLocal()
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.14.12
# Mod Properties
mod_version=1.0.3
mod_version=1.0.4
maven_group=io.github.gaming32
archives_base_name=mod-loading-screen
9 changes: 0 additions & 9 deletions settings.gradle

This file was deleted.

10 changes: 10 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
maven("https://maven.fabricmc.net/") {
name = "Fabric"
}
gradlePluginPortal()
}
}

rootProject.name = "mod-loading-screen"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.StringJoiner;

public class AvailableFeatures {
public final class AvailableFeatures {
/**
* @since 1.0.3
* @see LoadingScreenApi#getFinalEntrypoints
Expand Down Expand Up @@ -36,15 +36,32 @@ public class AvailableFeatures {
*/
public static final long OPEN_CHECK = 1L << 4;

/**
* @since 1.0.4
* @see LoadingScreenApi#getCustomProgressBar
* @see CustomProgressBar
*/
public static final long CUSTOM_PROGRESS_BARS = 1L << 5;

/**
* All the features that should be available on version 1.0.3.
*
* @since 1.0.3
*/
public static final long V1_0_3 = FINAL_ENTRYPOINTS | HEADLESS_CHECK | IPC_CHECK | GET_PROGRESS | OPEN_CHECK;

/**
* All the features that should be available on version 1.0.4.
*
* @since 1.0.4
*/
public static final long V1_0_4 = V1_0_3 | CUSTOM_PROGRESS_BARS;

private static final long MIN_FEATURE = FINAL_ENTRYPOINTS;
private static final long MAX_FEATURE = OPEN_CHECK;
private static final long MAX_FEATURE = CUSTOM_PROGRESS_BARS;

private AvailableFeatures() {
}

public static String toString(long features) {
if (Long.bitCount(features) <= 1L) {
Expand All @@ -59,6 +76,8 @@ public static String toString(long features) {
return "GET_PROGRESS";
case (int)OPEN_CHECK:
return "OPEN_CHECK";
case (int)CUSTOM_PROGRESS_BARS:
return "CUSTOM_PROGRESS_BARS";
}
return "";
}
Expand Down
Loading

0 comments on commit 6793274

Please sign in to comment.