Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ configurations {
}
}

sourceSets.create("launcher")

dependencies {
// Fabric
minecraft(libs.minecraft)
Expand Down Expand Up @@ -100,6 +102,16 @@ dependencies {
jij(libs.waybackauthlib)
}

sourceSets {
val launcher = getByName("launcher")

launcher.apply {
java {
srcDir("src/launcher/java")
}
}
}

// Handle transitive dependencies for jar-in-jar
// Based on implementation from BaseProject by FlorianMichael/EnZaXD
// Source: https://github.com/FlorianMichael/BaseProject/blob/main/src/main/kotlin/de/florianmichael/baseproject/Fabric.kt
Expand All @@ -113,7 +125,6 @@ afterEvaluate {
"jsr305" // Compile time annotations only
)


jijConfig.incoming.resolutionResult.allDependencies.forEach { dep ->
val requested = dep.requested.displayName

Expand All @@ -135,12 +146,6 @@ loom {
accessWidenerPath = file("src/main/resources/meteor-client.accesswidener")
}

afterEvaluate {
tasks.migrateMappings.configure {
outputDir.set(project.file("src/main/java"))
}
}

tasks {
processResources {
val buildNumber = project.findProperty("build_number")?.toString() ?: ""
Expand All @@ -160,16 +165,24 @@ tasks {
}
}

// Compile launcher with Java 8 for backwards compatibility
getByName<JavaCompile>("compileLauncherJava") {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
options.compilerArgs.add("-Xlint:-options")
}

jar {
inputs.property("archivesName", project.base.archivesName.get())

from("LICENSE") {
rename { "${it}_${inputs.properties["archivesName"]}" }
}

// Launch sub project
dependsOn(":launch:compileJava")
from(project(":launch").layout.buildDirectory.dir("classes/java/main"))
// Include launcher classes
val launcher = sourceSets.getByName("launcher")
from(launcher.output.classesDirs)
from(launcher.output.resourcesDir)

manifest {
attributes["Main-Class"] = "meteordevelopment.meteorclient.Main"
Expand All @@ -187,7 +200,6 @@ tasks {
}

withType<JavaCompile> {
options.release = 21
options.compilerArgs.add("-Xlint:deprecation")
options.compilerArgs.add("-Xlint:unchecked")
}
Expand Down
13 changes: 0 additions & 13 deletions launch/build.gradle.kts

This file was deleted.

2 changes: 0 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ pluginManagement {
}

rootProject.name = "meteor-client"

include("launch")
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,45 @@ public static void main(String[] args) throws UnsupportedLookAndFeelException, C
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

int option = JOptionPane.showOptionDialog(
null,
"To install Meteor Client you need to put it in your mods folder and run Fabric for latest Minecraft version.",
"Meteor Client",
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
new String[] { "Open Wiki", "Open Mods Folder" },
null
null,
"To install Meteor Client you need to put it in your mods folder and run Fabric for latest Minecraft version.",
"Meteor Client",
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
new String[]{"Open Wiki", "Open Mods Folder"},
null
);

switch (option) {
case 0: getOS().open("https://meteorclient.com/faq/installation"); break;
case 0:
getOS().open("https://meteorclient.com/faq/installation");
break;
case 1: {
String path;

switch (getOS()) {
case WINDOWS: path = System.getenv("AppData") + "/.minecraft/mods"; break;
case OSX: path = System.getProperty("user.home") + "/Library/Application Support/minecraft/mods"; break;
default: path = System.getProperty("user.home") + "/.minecraft"; break;
}

File mods = new File(path);
File mods = new File(getModsFolder());
if (!mods.exists()) mods.mkdirs();

getOS().open(mods);
break;
}
}
}

private static String getModsFolder() {
String userHome = System.getProperty("user.home");
switch (getOS()) {
case WINDOWS:
return System.getenv("AppData") + "/.minecraft/mods";
case OSX:
return userHome + "/Library/Application Support/minecraft/mods";
default:
return userHome + "/.minecraft/mods";
}
}

private static OperatingSystem getOS() {
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);

if (os.contains("linux") || os.contains("unix")) return OperatingSystem.LINUX;
if (os.contains("linux") || os.contains("unix")) return OperatingSystem.LINUX;
if (os.contains("mac")) return OperatingSystem.OSX;
if (os.contains("win")) return OperatingSystem.WINDOWS;

Expand All @@ -64,13 +69,13 @@ private enum OperatingSystem {
WINDOWS {
@Override
protected String[] getURLOpenCommand(URL url) {
return new String[] { "rundll32", "url.dll,FileProtocolHandler", url.toString() };
return new String[]{"rundll32", "url.dll,FileProtocolHandler", url.toString()};
}
},
OSX {
@Override
protected String[] getURLOpenCommand(URL url) {
return new String[] { "open", url.toString() };
return new String[]{"open", url.toString()};
}
},
UNKNOWN;
Expand Down Expand Up @@ -106,7 +111,7 @@ protected String[] getURLOpenCommand(URL url) {
string = string.replace("file:", "file://");
}

return new String[] { "xdg-open", string };
return new String[]{"xdg-open", string};
}
}
}