Simplify Env

This commit is contained in:
TheKodeToad 2024-09-02 17:16:37 +01:00
parent 730d8573a5
commit c8440cbb53
3 changed files with 9 additions and 17 deletions

View file

@ -15,31 +15,21 @@ public enum Env {
/**
* The physical client environment
*/
CLIENT("CLIENT", "client"),
CLIENT("client"),
/**
* The physical (dedicated) server environment
*/
SERVER("SERVER", "server")
;
SERVER("server");
private final String mixinName, identifier;
/**
* Get this environment's name, in the format Mixin understands.
*
* @return This environment's mixin name
*/
public String getMixinName() {
return this.mixinName;
}
private final String id;
/**
* Get this environment's identifier
*
* @return This environment's identifier
*/
public String getIdentifier() {
return this.identifier;
public String getId() {
return this.id;
}
/**

View file

@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import dev.frogmc.frogloader.api.env.Env;
import dev.frogmc.frogloader.impl.launch.FrogLauncher;
import lombok.Getter;
import org.objectweb.asm.ClassReader;
@ -19,6 +20,7 @@ import org.spongepowered.asm.mixin.transformer.IMixinTransformer;
import org.spongepowered.asm.mixin.transformer.IMixinTransformerFactory;
import org.spongepowered.asm.service.*;
import org.spongepowered.asm.transformers.MixinClassReader;
import org.spongepowered.asm.util.Constants;
import org.spongepowered.asm.util.ReEntranceLock;
public class FrogMixinService implements IMixinService, IClassProvider, IClassBytecodeProvider, ITransformerProvider, IClassTracker {
@ -120,7 +122,7 @@ public class FrogMixinService implements IMixinService, IClassProvider, IClassBy
@Override
public String getSideName() {
return FrogLauncher.getInstance().getEnv().getMixinName();
return FrogLauncher.getInstance().getEnv().name();
}
@Override

View file

@ -53,7 +53,7 @@ public class MinecraftGamePlugin implements GamePlugin {
}
try (FileSystem fs = FileSystems.newFileSystem(jar)) {
for (String n : MINECRAFT_CLASSES) {
if (Files.exists(fs.getPath(n)) && n.contains(FrogLoaderImpl.getInstance().getEnv().getIdentifier())) {
if (Files.exists(fs.getPath(n)) && n.contains(FrogLoaderImpl.getInstance().getEnv().getId())) {
LOGGER.info("Found game: {}", jar);
foundMainClass = n.substring(0, n.length() - 6).replace("/", ".");
try {