Skip to content

Commit d57e408

Browse files
Merge branch 'MeteorDevelopment:master' into feat/classgraph
2 parents 51bd348 + ec60aed commit d57e408

File tree

108 files changed

+3459
-918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3459
-918
lines changed

build.gradle.kts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ configurations {
6969
}
7070
}
7171

72+
sourceSets.create("launcher")
73+
7274
dependencies {
7375
// Fabric
7476
minecraft(libs.minecraft)
@@ -77,11 +79,10 @@ dependencies {
7779

7880
val fapiVersion = libs.versions.fabric.api.get()
7981
modInclude(fabricApi.module("fabric-api-base", fapiVersion))
80-
modInclude(fabricApi.module("fabric-resource-loader-v0", fapiVersion))
8182
modInclude(fabricApi.module("fabric-resource-loader-v1", fapiVersion))
8283

8384
// Compat fixes
84-
// modCompileOnly(fabricApi.module("fabric-renderer-indigo", fapiVersion)) TODO: re-enable when available
85+
modCompileOnly(fabricApi.module("fabric-renderer-indigo", fapiVersion))
8586
modCompileOnly(libs.sodium) { isTransitive = false }
8687
modCompileOnly(libs.lithium) { isTransitive = false }
8788
modCompileOnly(libs.iris) { isTransitive = false }
@@ -101,6 +102,16 @@ dependencies {
101102
jij(libs.waybackauthlib)
102103
}
103104

105+
sourceSets {
106+
val launcher = getByName("launcher")
107+
108+
launcher.apply {
109+
java {
110+
srcDir("src/launcher/java")
111+
}
112+
}
113+
}
114+
104115
// Handle transitive dependencies for jar-in-jar
105116
// Based on implementation from BaseProject by FlorianMichael/EnZaXD
106117
// Source: https://github.com/FlorianMichael/BaseProject/blob/main/src/main/kotlin/de/florianmichael/baseproject/Fabric.kt
@@ -114,7 +125,6 @@ afterEvaluate {
114125
"jsr305" // Compile time annotations only
115126
)
116127

117-
118128
jijConfig.incoming.resolutionResult.allDependencies.forEach { dep ->
119129
val requested = dep.requested.displayName
120130

@@ -136,12 +146,6 @@ loom {
136146
accessWidenerPath = file("src/main/resources/meteor-client.accesswidener")
137147
}
138148

139-
afterEvaluate {
140-
tasks.migrateMappings.configure {
141-
outputDir.set(project.file("src/main/java"))
142-
}
143-
}
144-
145149
tasks {
146150
processResources {
147151
val buildNumber = project.findProperty("build_number")?.toString() ?: ""
@@ -161,16 +165,24 @@ tasks {
161165
}
162166
}
163167

168+
// Compile launcher with Java 8 for backwards compatibility
169+
getByName<JavaCompile>("compileLauncherJava") {
170+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
171+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
172+
options.compilerArgs.add("-Xlint:-options")
173+
}
174+
164175
jar {
165176
inputs.property("archivesName", project.base.archivesName.get())
166177

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

171-
// Launch sub project
172-
dependsOn(":launch:compileJava")
173-
from(project(":launch").layout.buildDirectory.dir("classes/java/main"))
182+
// Include launcher classes
183+
val launcher = sourceSets.getByName("launcher")
184+
from(launcher.output.classesDirs)
185+
from(launcher.output.resourcesDir)
174186

175187
manifest {
176188
attributes["Main-Class"] = "meteordevelopment.meteorclient.Main"
@@ -188,7 +200,6 @@ tasks {
188200
}
189201

190202
withType<JavaCompile> {
191-
options.release = 21
192203
options.compilerArgs.add("-Xlint:deprecation")
193204
options.compilerArgs.add("-Xlint:unchecked")
194205
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
minecraft = "1.21.11"
44
yarn-mappings = "1.21.11+build.3"
55
fabric-loader = "0.18.2"
6-
fabric-api = "0.139.5+1.21.11"
6+
fabric-api = "0.140.0+1.21.11"
77

88
# Plugins
99
# Loom (https://github.com/FabricMC/fabric-loom)

launch/build.gradle.kts

Lines changed: 0 additions & 13 deletions
This file was deleted.

settings.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ pluginManagement {
1010
}
1111

1212
rootProject.name = "meteor-client"
13-
14-
include("launch")

launch/src/main/java/meteordevelopment/meteorclient/Main.java renamed to src/launcher/java/meteordevelopment/meteorclient/Main.java

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,45 @@ public static void main(String[] args) throws UnsupportedLookAndFeelException, C
1919
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
2020

2121
int option = JOptionPane.showOptionDialog(
22-
null,
23-
"To install Meteor Client you need to put it in your mods folder and run Fabric for latest Minecraft version.",
24-
"Meteor Client",
25-
JOptionPane.YES_NO_OPTION,
26-
JOptionPane.ERROR_MESSAGE,
27-
null,
28-
new String[] { "Open Wiki", "Open Mods Folder" },
29-
null
22+
null,
23+
"To install Meteor Client you need to put it in your mods folder and run Fabric for latest Minecraft version.",
24+
"Meteor Client",
25+
JOptionPane.YES_NO_OPTION,
26+
JOptionPane.ERROR_MESSAGE,
27+
null,
28+
new String[]{"Open Wiki", "Open Mods Folder"},
29+
null
3030
);
3131

3232
switch (option) {
33-
case 0: getOS().open("https://meteorclient.com/faq/installation"); break;
33+
case 0:
34+
getOS().open("https://meteorclient.com/faq/installation");
35+
break;
3436
case 1: {
35-
String path;
36-
37-
switch (getOS()) {
38-
case WINDOWS: path = System.getenv("AppData") + "/.minecraft/mods"; break;
39-
case OSX: path = System.getProperty("user.home") + "/Library/Application Support/minecraft/mods"; break;
40-
default: path = System.getProperty("user.home") + "/.minecraft"; break;
41-
}
42-
43-
File mods = new File(path);
37+
File mods = new File(getModsFolder());
4438
if (!mods.exists()) mods.mkdirs();
45-
4639
getOS().open(mods);
4740
break;
4841
}
4942
}
5043
}
5144

45+
private static String getModsFolder() {
46+
String userHome = System.getProperty("user.home");
47+
switch (getOS()) {
48+
case WINDOWS:
49+
return System.getenv("AppData") + "/.minecraft/mods";
50+
case OSX:
51+
return userHome + "/Library/Application Support/minecraft/mods";
52+
default:
53+
return userHome + "/.minecraft/mods";
54+
}
55+
}
56+
5257
private static OperatingSystem getOS() {
5358
String os = System.getProperty("os.name").toLowerCase(Locale.ROOT);
5459

55-
if (os.contains("linux") || os.contains("unix")) return OperatingSystem.LINUX;
60+
if (os.contains("linux") || os.contains("unix")) return OperatingSystem.LINUX;
5661
if (os.contains("mac")) return OperatingSystem.OSX;
5762
if (os.contains("win")) return OperatingSystem.WINDOWS;
5863

@@ -64,13 +69,13 @@ private enum OperatingSystem {
6469
WINDOWS {
6570
@Override
6671
protected String[] getURLOpenCommand(URL url) {
67-
return new String[] { "rundll32", "url.dll,FileProtocolHandler", url.toString() };
72+
return new String[]{"rundll32", "url.dll,FileProtocolHandler", url.toString()};
6873
}
6974
},
7075
OSX {
7176
@Override
7277
protected String[] getURLOpenCommand(URL url) {
73-
return new String[] { "open", url.toString() };
78+
return new String[]{"open", url.toString()};
7479
}
7580
},
7681
UNKNOWN;
@@ -106,7 +111,7 @@ protected String[] getURLOpenCommand(URL url) {
106111
string = string.replace("file:", "file://");
107112
}
108113

109-
return new String[] { "xdg-open", string };
114+
return new String[]{"xdg-open", string};
110115
}
111116
}
112117
}

src/main/java/meteordevelopment/meteorclient/commands/Commands.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public static void init() {
6767
add(new InputCommand());
6868
add(new WaspCommand());
6969
add(new LocateCommand());
70+
add(new HelpCommand());
7071

7172
COMMANDS.sort(Comparator.comparing(Command::getName));
7273

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3+
* Copyright (c) Meteor Development.
4+
*/
5+
6+
package meteordevelopment.meteorclient.commands.arguments;
7+
8+
import com.mojang.brigadier.StringReader;
9+
import com.mojang.brigadier.arguments.ArgumentType;
10+
import com.mojang.brigadier.context.CommandContext;
11+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
12+
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
13+
import com.mojang.brigadier.suggestion.Suggestions;
14+
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
15+
import meteordevelopment.meteorclient.commands.Command;
16+
import meteordevelopment.meteorclient.commands.Commands;
17+
import net.minecraft.command.CommandSource;
18+
import net.minecraft.text.Text;
19+
20+
import java.util.Collection;
21+
import java.util.LinkedHashSet;
22+
import java.util.Set;
23+
import java.util.concurrent.CompletableFuture;
24+
import java.util.stream.Collectors;
25+
26+
public class CommandArgumentType implements ArgumentType<Command> {
27+
private static final CommandArgumentType INSTANCE = new CommandArgumentType();
28+
private static final DynamicCommandExceptionType NO_SUCH_COMMAND = new DynamicCommandExceptionType(name -> Text.literal("Command with name " + name + " doesn't exist."));
29+
private static final Collection<String> EXAMPLES = Commands.COMMANDS.stream().limit(3).map(Command::getName).collect(Collectors.toList());
30+
31+
private CommandArgumentType() {
32+
}
33+
34+
public static CommandArgumentType create() {
35+
return INSTANCE;
36+
}
37+
38+
public static Command get(CommandContext<?> context) {
39+
return context.getArgument("command", Command.class);
40+
}
41+
42+
@Override
43+
public Command parse(StringReader reader) throws CommandSyntaxException {
44+
String name = reader.readString();
45+
46+
Command command = Commands.get(name);
47+
48+
if (command == null) {
49+
for (Command c : Commands.COMMANDS) {
50+
for (String alias : c.getAliases()) {
51+
if (alias.equals(name)) {
52+
command = c;
53+
break;
54+
}
55+
}
56+
if (command != null) break;
57+
}
58+
}
59+
60+
if (command == null) throw NO_SUCH_COMMAND.create(name);
61+
return command;
62+
}
63+
64+
@Override
65+
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
66+
Set<String> suggestions = new LinkedHashSet<>();
67+
for (Command c : Commands.COMMANDS) {
68+
suggestions.add(c.getName());
69+
suggestions.addAll(c.getAliases());
70+
}
71+
return CommandSource.suggestMatching(suggestions, builder);
72+
}
73+
74+
@Override
75+
public Collection<String> getExamples() {
76+
return EXAMPLES;
77+
}
78+
}

src/main/java/meteordevelopment/meteorclient/commands/arguments/SettingArgumentType.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.mojang.brigadier.suggestion.Suggestions;
1515
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
1616
import meteordevelopment.meteorclient.settings.Setting;
17+
import meteordevelopment.meteorclient.settings.Settings;
1718
import meteordevelopment.meteorclient.systems.modules.Module;
1819
import net.minecraft.command.CommandSource;
1920
import net.minecraft.text.Text;
@@ -31,9 +32,14 @@ public static SettingArgumentType create() {
3132

3233
public static Setting<?> get(CommandContext<?> context) throws CommandSyntaxException {
3334
Module module = context.getArgument("module", Module.class);
35+
36+
return get(context, module.settings);
37+
}
38+
39+
public static Setting<?> get(CommandContext<?> context, Settings settings) throws CommandSyntaxException {
3440
String settingName = context.getArgument("setting", String.class);
3541

36-
Setting<?> setting = module.settings.get(settingName);
42+
Setting<?> setting = settings.get(settingName);
3743
if (setting == null) throw NO_SUCH_SETTING.create(settingName);
3844

3945
return setting;
@@ -48,9 +54,13 @@ public String parse(StringReader reader) throws CommandSyntaxException {
4854

4955
@Override
5056
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
51-
Stream<String> stream = Streams.stream(context.getArgument("module", Module.class).settings.iterator())
52-
.flatMap(settings -> Streams.stream(settings.iterator()))
53-
.map(setting -> setting.name);
57+
return listSuggestions(builder, context.getArgument("module", Module.class).settings);
58+
}
59+
60+
public static CompletableFuture<Suggestions> listSuggestions(SuggestionsBuilder builder, Settings settings) {
61+
Stream<String> stream = Streams.stream(settings.iterator())
62+
.flatMap(sg -> Streams.stream(sg.iterator()))
63+
.map(setting -> setting.name);
5464

5565
return CommandSource.suggestMatching(stream, builder);
5666
}

src/main/java/meteordevelopment/meteorclient/commands/arguments/SettingValueArgumentType.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
import com.mojang.brigadier.suggestion.Suggestions;
1313
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
1414
import meteordevelopment.meteorclient.settings.Setting;
15+
import meteordevelopment.meteorclient.settings.Settings;
1516
import net.minecraft.command.CommandSource;
1617
import net.minecraft.util.Identifier;
18+
import org.jetbrains.annotations.NotNull;
1719

1820
import java.util.concurrent.CompletableFuture;
1921

@@ -47,6 +49,22 @@ public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> cont
4749
return Suggestions.empty();
4850
}
4951

52+
return suggest(builder, setting);
53+
}
54+
55+
public static <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder, Settings settings) {
56+
Setting<?> setting;
57+
58+
try {
59+
setting = SettingArgumentType.get(context, settings);
60+
} catch (CommandSyntaxException ignored) {
61+
return Suggestions.empty();
62+
}
63+
64+
return suggest(builder, setting);
65+
}
66+
67+
public static CompletableFuture<Suggestions> suggest(SuggestionsBuilder builder, @NotNull Setting<?> setting) {
5068
Iterable<Identifier> identifiers = setting.getIdentifierSuggestions();
5169
if (identifiers != null) {
5270
return CommandSource.suggestIdentifiers(identifiers, builder);

0 commit comments

Comments
 (0)