correct server main class

This commit is contained in:
moehreag 2024-05-20 14:32:20 +02:00
parent 56ceb7c2cf
commit 6fd6c3ab34
3 changed files with 8 additions and 9 deletions

View file

@ -1,15 +1,14 @@
package org.ecorous.esnesnon.nonsense.loader.api.env;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum Env {
CLIENT("CLIENT"),
SERVER("SERVER"),
CLIENT("CLIENT", "client"),
SERVER("SERVER", "server"),
;
final String mixinName;
Env(String mixinName){
this.mixinName = mixinName;
}
final String mixinName, identifier;
}

View file

@ -105,7 +105,7 @@ public class LoaderImpl implements Loader {
break;
}
} catch (Throwable e) {
LOGGER.error("Failed to instantiate plugin: ", e);
LOGGER.error("Error during plugin initialisation: ", e);
}
}
}

View file

@ -30,7 +30,7 @@ public class Minecraft implements NonsensePlugin {
private static final String[] MINECRAFT_CLASSES = new String[]{
"net/minecraft/client/main/Main.class",
"net/minecraft/client/MinecraftApplet.class",
"net/minecraft/server/main/Main.class"
"net/minecraft/server/Main.class"
};
private final List<ModProperties> modProperties = new ArrayList<>();
@ -122,7 +122,7 @@ public class Minecraft implements NonsensePlugin {
}
try (FileSystem fs = FileSystems.newFileSystem(jar)) {
for (String n : MINECRAFT_CLASSES) {
if (Files.exists(fs.getPath(n))){
if (Files.exists(fs.getPath(n)) && n.contains(LoaderImpl.getInstance().getEnv().getIdentifier())){
LOGGER.info("Found game: {}", jar);
foundMainClass = n.substring(0, n.length()-6).replace("/", ".");
version = LoaderImpl.getInstance().getGson().fromJson(Files.readString(fs.getPath("version.json")), JsonObject.class).get("id").getAsString();