Compare commits

...

8 commits

Author SHA1 Message Date
owlsys 52306daa09 Merge branch 'main' into TheKodeToad/simplify-env 2024-09-02 12:33:18 -04:00
moehreag bb255e3612 complete javadoc
Some checks failed
Publish to snapshot maven / build (push) Failing after 17s
2024-09-02 18:22:12 +02:00
owlsys b3085264ee Merge pull request 'Convert ModDependencies to an interface' (#15) from TheKodeToad/mod-dependencies-iface into main
Some checks failed
Publish to snapshot maven / build (push) Failing after 17s
Reviewed-on: #15
Reviewed-by: owlsys <owlsys@noreply.localhost>
2024-09-02 12:09:57 -04:00
TheKodeToad 7a7d454a16 Merge branch 'main' into TheKodeToad/mod-dependencies-iface 2024-09-02 12:09:12 -04:00
owlsys bc520da577 Merge pull request 'Require extensions to be namespaced' (#14) from TheKodeToad/extension-namespace into main
Some checks failed
Publish to snapshot maven / build (push) Failing after 22s
Reviewed-on: #14
Reviewed-by: owlsys <owlsys@noreply.localhost>
2024-09-02 12:08:59 -04:00
TheKodeToad c84e2c0a9e Merge branch 'main' into TheKodeToad/extension-namespace 2024-09-02 12:08:13 -04:00
moehreag aeb621d704 fix not adding game to classpath after remapping
All checks were successful
Publish to snapshot maven / build (push) Successful in 33s
2024-08-28 22:30:45 +02:00
moehreag 136cda8eb4 use MappingData.reverse() instead of MappingBundle.reverse()
All checks were successful
Publish to snapshot maven / build (push) Successful in 25s
2024-08-28 22:08:00 +02:00
5 changed files with 35 additions and 15 deletions

View file

@ -7,7 +7,7 @@ plugins {
}
group = "dev.frogmc"
version = "0.0.1-alpha.27"
version = "0.0.1-alpha.29"
repositories {
maven {

View file

@ -1,5 +1,5 @@
#Sat May 11 16:50:23 CEST 2024
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists

View file

@ -1,15 +1,31 @@
package dev.frogmc.frogloader.api.exception;
/**
* Exception if an extension cannot be resolved or instantiated
*/
public class ModExtensionResolutionException extends Exception {
/**
* Instantiate this exception
* @param message A message describing this exception
*/
public ModExtensionResolutionException(String message) {
super(message);
}
/**
* Instantiate this exception
* @param cause The cause of this exception
*/
public ModExtensionResolutionException(Throwable cause) {
super(cause);
}
/**
* Instantiate this exception
* @param message A message describing this exception
* @param cause The cause of this exception
*/
public ModExtensionResolutionException(String message, Throwable cause) {
super(message, cause);
}

View file

@ -4,6 +4,11 @@ import java.util.Collection;
import org.jetbrains.annotations.Nullable;
/**
* Represents dependencies declared by a mod at runtime.
* @see ModProperties
* @see ModExtensions
*/
public interface ModDependencies {
/**

View file

@ -26,7 +26,7 @@ import dev.frogmc.frogloader.impl.mod.ModPropertiesImpl;
import dev.frogmc.frogloader.impl.util.SystemProperties;
import dev.frogmc.thyroxine.HttpHelper;
import dev.frogmc.thyroxine.Thyroxine;
import dev.frogmc.thyroxine.api.data.MappingBundle;
import dev.frogmc.thyroxine.api.data.MappingData;
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser;
import dev.frogmc.thyroxine.provider.MojmapProvider;
import org.jetbrains.annotations.NotNull;
@ -135,7 +135,7 @@ public class MinecraftGamePlugin implements GamePlugin {
if (!loader.isDevelopment()) {
if (!Files.exists(remappedGamePath)) {
LOGGER.atInfo().setMessage("Remapping game, this may take a moment...").log();
MappingBundle mappings;
MappingData mappings;
String mappingPath = System.getProperty(SystemProperties.INTERMEDIARY_MAPPINGS);
try {
if (mappingPath != null) {
@ -143,7 +143,7 @@ public class MinecraftGamePlugin implements GamePlugin {
} else {
try {
mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt"))
.reverse();
.flattenData().reverse();
} catch (NullPointerException e) { // NPE is only thrown if the mappings for this version can't be found
LOGGER.info("Mojmap is not available for version {}, using ornithe's calamus as a fallback!", version);
Path file = remappedGamePath.resolveSibling("calamus-"+version+".tiny");
@ -155,30 +155,29 @@ public class MinecraftGamePlugin implements GamePlugin {
location.replaceAll("[.:]", "/")+"/"+groups[1]+"-"+groups[2]+".jar"),
file);
}
mappings = TinyV2Parser.parse(Files.readString(file));
mappings = TinyV2Parser.parse(Files.readString(file)).flattenData();
}
}
if (mappings == null) {
mappings = readIntemediaryMappings("/mappings/mappings.tiny");
}
if (mappings != null) {
Thyroxine.remap(mappings.flattenData(), gamePath, remappedGamePath, true, false);
return;
Thyroxine.remap(mappings, gamePath, remappedGamePath, true, false);
} else {
runtimePath = gamePath;
LOGGER.error("No intermediary mappings found! The game will be launched obfuscated. Mods are likely to error! " +
"You may need to specify the path of your mappings manually. " +
"Use -D" + SystemProperties.INTERMEDIARY_MAPPINGS + " to specify a file!");
}
} catch (Exception e) {
throw new IllegalStateException("Failed to remap game: ", e);
}
runtimePath = gamePath;
LOGGER.error("No intermediary mappings found! The game will be launched obfuscated. Mods are likely to error! " +
"You may need to specify the path of your mappings manually. " +
"Use -D" + SystemProperties.INTERMEDIARY_MAPPINGS + " to specify a file!");
}
}
FrogLoaderImpl.getInstance().getClassloader().addURL(runtimePath.toUri().toURL());
}
private MappingBundle readIntemediaryMappings(String path) throws IOException {
private MappingData readIntemediaryMappings(String path) throws IOException {
URL resource = this.getClass().getResource(path);
String data;
if (resource != null) {
@ -187,7 +186,7 @@ public class MinecraftGamePlugin implements GamePlugin {
data = Files.readString(Paths.get(path));
}
try {
MappingBundle mappings = TinyV2Parser.parse(data);
MappingData mappings = TinyV2Parser.parse(data).flattenData();
LOGGER.warn("Using non-standard intermediary mappings! Mods may not work!");
return mappings;
} catch (IllegalStateException e) {