add error in case no plugin applicable to current state is found

This commit is contained in:
moehreag 2024-05-27 12:22:44 +02:00
parent f8c6b88d8f
commit 0e826dac3a
2 changed files with 12 additions and 7 deletions

View file

@ -129,6 +129,11 @@ public class LoaderImpl implements Loader {
LOGGER.error("Error during plugin initialisation: ", e); LOGGER.error("Error during plugin initialisation: ", e);
} }
} }
if (plugins.isEmpty()){
// TODO display error
throw new IllegalStateException("No plugin applicable to the current state was found!");
}
} }
public String getArgument(String name){ public String getArgument(String name){

View file

@ -27,16 +27,16 @@ import org.spongepowered.asm.mixin.Mixins;
public class Minecraft implements NonsensePlugin { public class Minecraft implements NonsensePlugin {
private static final Logger LOGGER = LoggerFactory.getLogger("Plugin/Minecraft"); private static final Logger LOGGER = LoggerFactory.getLogger("Plugin/Minecraft");
private static final String[] MINECRAFT_CLASSES = new String[]{ protected 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.class" "net/minecraft/server/Main.class"
}; };
private final List<ModProperties> modProperties = new ArrayList<>(); protected final List<ModProperties> modProperties = new ArrayList<>();
private String version; private String version;
private Path gamePath; protected Path gamePath;
private String foundMainClass; protected String foundMainClass;
@Override @Override
public boolean isApplicable() { public boolean isApplicable() {
@ -113,7 +113,7 @@ public class Minecraft implements NonsensePlugin {
LoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL()); LoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL());
} }
private void findJiJMods(Path mod, Collection<Path> mods) throws IOException { protected void findJiJMods(Path mod, Collection<Path> mods) throws IOException {
Optional<ModProperties> opt = ModPropertiesReader.read(mod); Optional<ModProperties> opt = ModPropertiesReader.read(mod);
if (opt.isPresent()) { if (opt.isPresent()) {
ModProperties p = opt.get(); ModProperties p = opt.get();
@ -139,7 +139,7 @@ public class Minecraft implements NonsensePlugin {
return modProperties; return modProperties;
} }
private Path findGame() { protected Path findGame() {
LOGGER.info("Locating game.."); LOGGER.info("Locating game..");
String jar = System.getProperty("nonsense.plugin.minecraft.gameJar"); String jar = System.getProperty("nonsense.plugin.minecraft.gameJar");
if (jar != null) { if (jar != null) {
@ -159,7 +159,7 @@ public class Minecraft implements NonsensePlugin {
return null; return null;
} }
private boolean checkLocation(Path jar) { protected boolean checkLocation(Path jar) {
if (!Files.exists(jar) || Files.isDirectory(jar)) { if (!Files.exists(jar) || Files.isDirectory(jar)) {
return false; return false;
} }