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; package org.ecorous.esnesnon.nonsense.loader.api.env;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@Getter @Getter
@AllArgsConstructor
public enum Env { public enum Env {
CLIENT("CLIENT"), CLIENT("CLIENT", "client"),
SERVER("SERVER"), SERVER("SERVER", "server"),
; ;
final String mixinName; final String mixinName, identifier;
Env(String mixinName){
this.mixinName = mixinName;
}
} }

View file

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