Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored and shartte committed Apr 12, 2024
1 parent 2fd84bd commit c58948c
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 18 deletions.
1 change: 1 addition & 0 deletions loader/src/main/java/net/neoforged/fml/ModLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.fml.loading.ImmediateWindowHandler;
import net.neoforged.fml.loading.LoadingModList;
import net.neoforged.fml.loading.moddiscovery.JarModsDotTomlModProvider;
import net.neoforged.fml.loading.moddiscovery.ModFileInfo;
import net.neoforged.fml.loading.moddiscovery.ModInfo;
import net.neoforged.fml.loading.progress.ProgressMeter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static net.neoforged.fml.loading.LogMarkers.CORE;

import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar;
import cpw.mods.modlauncher.api.IEnvironment;
import cpw.mods.modlauncher.api.IModuleLayerManager;
import cpw.mods.modlauncher.api.ITransformationService;
Expand All @@ -24,6 +25,10 @@
import joptsimple.OptionSpecBuilder;
import net.neoforged.fml.loading.moddiscovery.ModFile;
import net.neoforged.neoforgespi.Environment;
import net.neoforged.neoforgespi.locating.IModFile;
import net.neoforged.neoforgespi.locating.IModProvider;
import net.neoforged.neoforgespi.locating.InvalidModFileException;
import net.neoforged.neoforgespi.locating.ModFileFactory;
import org.slf4j.Logger;

public class FMLServiceProvider implements ITransformationService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package net.neoforged.fml.loading.moddiscovery;

import cpw.mods.jarhandling.SecureJar;
import cpw.mods.jarhandling.JarContents;
import cpw.mods.jarhandling.JarContentsBuilder;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
Expand All @@ -26,7 +27,7 @@ public String name() {
public void initArguments(Map<String, ?> arguments) {}

@Override
public Stream<SecureJar> scanCandidates() {
public Stream<JarContents> scanCandidates() {
String gameLibrariesStr = System.getProperty("fml.gameLayerLibraries");
if (gameLibrariesStr == null || gameLibrariesStr.isBlank())
return Stream.of();
Expand All @@ -39,6 +40,6 @@ public Stream<SecureJar> scanCandidates() {
paths.add(path);
}

return paths.build().map(SecureJar::from);
return paths.build().map(p -> new JarContentsBuilder().paths(p).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
package net.neoforged.fml.loading.moddiscovery;

import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar;
import cpw.mods.jarhandling.JarContents;
import cpw.mods.jarhandling.JarContentsBuilder;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -34,7 +35,7 @@ public String name() {
}

@Override
public Stream<SecureJar> scanCandidates() {
public Stream<JarContents> scanCandidates() {
if (!enabled)
return Stream.of();

Expand All @@ -45,7 +46,7 @@ public Stream<SecureJar> scanCandidates() {
findPaths(claimed, JarModsDotTomlModProvider.MODS_TOML).forEach(paths::add);
findPaths(claimed, JarModsDotTomlModProvider.MANIFEST).forEach(paths::add);

return paths.build().map(SecureJar::from);
return paths.build().map(p -> new JarContentsBuilder().paths(p).build());
} catch (IOException e) {
LOGGER.error(LogMarkers.SCAN, "Error trying to find resources", e);
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package net.neoforged.fml.loading.moddiscovery;

import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.JarContents;
import cpw.mods.jarhandling.JarContentsBuilder;
import cpw.mods.jarhandling.SecureJar;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -24,10 +24,9 @@ public record ExplodedMod(String modid, List<Path> paths) {}
private final List<ExplodedMod> explodedMods = new ArrayList<>();

@Override
public Stream<SecureJar> scanCandidates() {
public Stream<JarContents> scanCandidates() {
return explodedMods.stream().map(explodedMod -> {
var jarContents = new JarContentsBuilder().paths(explodedMod.paths().toArray(Path[]::new)).build();
return SecureJar.from(jarContents);
return new JarContentsBuilder().paths(explodedMod.paths().toArray(Path[]::new)).build();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ public List<IModFile> scanMods(Iterable<IModFile> loadedMods, Function<JarConten
final List<IModFile> sources = Lists.newArrayList();
loadedMods.forEach(sources::add);

final List<IModFile> dependenciesToLoad = JarSelector.detectAndSelect(sources, this::loadResourceFromModFile, this::loadModFileFrom, this::identifyMod, this::exception);
final List<IModFile> dependenciesToLoad = JarSelector.detectAndSelect(
sources,
this::loadResourceFromModFile,
(file, path) -> loadModFileFrom(file, path, provider),
this::identifyMod,
this::exception);

if (dependenciesToLoad.isEmpty()) {
LOGGER.info("No dependencies to load found. Skipping!");
Expand All @@ -78,7 +83,6 @@ public List<IModFile> scanMods(Iterable<IModFile> loadedMods, Function<JarConten
}

@SuppressWarnings("resource")
@Override
protected Optional<IModFile> loadModFileFrom(final IModFile file, final Path path, Function<JarContents, Optional<IModProvider.ModFileOrException>> provider) {
try {
final Path pathInModFile = file.findResource(path.toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright (c) NeoForged and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.fml.loading.moddiscovery;

import com.mojang.logging.LogUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package net.neoforged.fml.loading.moddiscovery;

import cpw.mods.jarhandling.SecureJar;
import cpw.mods.jarhandling.JarContents;
import cpw.mods.jarhandling.JarContentsBuilder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
Expand All @@ -20,8 +21,8 @@ public class MavenDirectoryLocator implements IModLocator {
private List<Path> modCoords;

@Override
public Stream<SecureJar> scanCandidates() {
return modCoords.stream().map(SecureJar::from);
public Stream<JarContents> scanCandidates() {
return modCoords.stream().map(p -> new JarContentsBuilder().paths(p).build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
package net.neoforged.fml.loading.moddiscovery;

import com.mojang.logging.LogUtils;
import cpw.mods.jarhandling.SecureJar;
import cpw.mods.jarhandling.JarContents;
import cpw.mods.jarhandling.JarContentsBuilder;
import cpw.mods.modlauncher.api.LambdaExceptionUtils;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -42,14 +43,14 @@ public ModsFolderLocator() {
}

@Override
public Stream<SecureJar> scanCandidates() {
public Stream<JarContents> scanCandidates() {
LOGGER.debug(LogMarkers.SCAN, "Scanning mods dir {} for mods", this.modFolder);
var excluded = ModDirTransformerDiscoverer.allExcluded();

return LambdaExceptionUtils.uncheck(() -> Files.list(this.modFolder))
.filter(p -> !excluded.contains(p) && StringUtils.toLowerCase(p.getFileName().toString()).endsWith(SUFFIX))
.sorted(Comparator.comparing(path -> StringUtils.toLowerCase(path.getFileName().toString())))
.map(SecureJar::from);
.map(p -> new JarContentsBuilder().paths(p).build());
}

@Override
Expand Down

0 comments on commit c58948c

Please sign in to comment.