Skip to content

Commit

Permalink
Rename ModCandidate to ModCandidateImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
sfPlayer1 committed Aug 15, 2024
1 parent d9a0006 commit da94132
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 233 deletions.
30 changes: 15 additions & 15 deletions src/main/java/net/fabricmc/loader/impl/FabricLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import net.fabricmc.loader.impl.discovery.ArgumentModCandidateFinder;
import net.fabricmc.loader.impl.discovery.ClasspathModCandidateFinder;
import net.fabricmc.loader.impl.discovery.DirectoryModCandidateFinder;
import net.fabricmc.loader.impl.discovery.ModCandidate;
import net.fabricmc.loader.impl.discovery.ModCandidateImpl;
import net.fabricmc.loader.impl.discovery.ModDiscoverer;
import net.fabricmc.loader.impl.discovery.ModResolutionException;
import net.fabricmc.loader.impl.discovery.ModResolver;
Expand Down Expand Up @@ -84,7 +84,7 @@ public final class FabricLoaderImpl extends net.fabricmc.loader.FabricLoader {
private static final String TMP_DIR_NAME = "tmp"; // relative to cache dir

protected final Map<String, ModContainerImpl> modMap = new HashMap<>();
private List<ModCandidate> modCandidates;
private List<ModCandidateImpl> modCandidates;
protected List<ModContainerImpl> mods = new ArrayList<>();

private final Map<String, LanguageAdapter> adapterMap = new HashMap<>();
Expand Down Expand Up @@ -212,7 +212,7 @@ private void setup() throws ModResolutionException {
discoverer.addCandidateFinder(new DirectoryModCandidateFinder(getModsDirectory0(), remapRegularMods));
discoverer.addCandidateFinder(new ArgumentModCandidateFinder(remapRegularMods));

Map<String, Set<ModCandidate>> envDisabledMods = new HashMap<>();
Map<String, Set<ModCandidateImpl>> envDisabledMods = new HashMap<>();
modCandidates = discoverer.discoverMods(this, envDisabledMods);

// dump version and dependency overrides info
Expand Down Expand Up @@ -255,8 +255,8 @@ private void setup() throws ModResolutionException {

if (modsToLoadLate != null) {
for (String modId : modsToLoadLate.split(",")) {
for (Iterator<ModCandidate> it = modCandidates.iterator(); it.hasNext(); ) {
ModCandidate mod = it.next();
for (Iterator<ModCandidateImpl> it = modCandidates.iterator(); it.hasNext(); ) {
ModCandidateImpl mod = it.next();

if (mod.getId().equals(modId)) {
it.remove();
Expand All @@ -269,7 +269,7 @@ private void setup() throws ModResolutionException {

// add mods

for (ModCandidate mod : modCandidates) {
for (ModCandidateImpl mod : modCandidates) {
if (!mod.hasPath() && !mod.isBuiltin()) {
try {
mod.setPaths(Collections.singletonList(mod.copyToDir(outputdir, false)));
Expand Down Expand Up @@ -297,11 +297,11 @@ public void dumpNonFabricMods(List<Path> nonFabricMods) {
Log.warn(LogCategory.GENERAL, "Found %d non-fabric mod%s:%s", modsCount, modsCount != 1 ? "s" : "", outputText);
}

private void dumpModList(List<ModCandidate> mods) {
private void dumpModList(List<ModCandidateImpl> mods) {
StringBuilder modListText = new StringBuilder();

boolean[] lastItemOfNestLevel = new boolean[mods.size()];
List<ModCandidate> topLevelMods = mods.stream()
List<ModCandidateImpl> topLevelMods = mods.stream()
.filter(mod -> mod.getParentMods().isEmpty())
.collect(Collectors.toList());
int topLevelModsCount = topLevelMods.size();
Expand All @@ -318,7 +318,7 @@ private void dumpModList(List<ModCandidate> mods) {
Log.info(LogCategory.GENERAL, "Loading %d mod%s:%n%s", modsCount, modsCount != 1 ? "s" : "", modListText);
}

private void dumpModList0(ModCandidate mod, StringBuilder log, int nestLevel, boolean[] lastItemOfNestLevel) {
private void dumpModList0(ModCandidateImpl mod, StringBuilder log, int nestLevel, boolean[] lastItemOfNestLevel) {
if (log.length() > 0) log.append('\n');

for (int depth = 0; depth < nestLevel; depth++) {
Expand All @@ -332,12 +332,12 @@ private void dumpModList0(ModCandidate mod, StringBuilder log, int nestLevel, bo
log.append(' ');
log.append(mod.getVersion().getFriendlyString());

List<ModCandidate> nestedMods = new ArrayList<>(mod.getNestedMods());
List<ModCandidateImpl> nestedMods = new ArrayList<>(mod.getNestedMods());
nestedMods.sort(Comparator.comparing(nestedMod -> nestedMod.getMetadata().getId()));

if (!nestedMods.isEmpty()) {
Iterator<ModCandidate> iterator = nestedMods.iterator();
ModCandidate nestedMod;
Iterator<ModCandidateImpl> iterator = nestedMods.iterator();
ModCandidateImpl nestedMod;
boolean lastItem;

while (iterator.hasNext()) {
Expand Down Expand Up @@ -430,10 +430,10 @@ public ObjectShare getObjectShare() {
return objectShare;
}

public ModCandidate getModCandidate(String id) {
public ModCandidateImpl getModCandidate(String id) {
if (modCandidates == null) return null;

for (ModCandidate mod : modCandidates) {
for (ModCandidateImpl mod : modCandidates) {
if (mod.getId().equals(id)) return mod;
}

Expand Down Expand Up @@ -464,7 +464,7 @@ public boolean isDevelopmentEnvironment() {
return FabricLauncherBase.getLauncher().isDevelopment();
}

private void addMod(ModCandidate candidate) throws ModResolutionException {
private void addMod(ModCandidateImpl candidate) throws ModResolutionException {
ModContainerImpl container = new ModContainerImpl(candidate);
mods.add(container);
modMap.put(candidate.getId(), container);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/fabricmc/loader/impl/ModContainerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import net.fabricmc.loader.api.ModContainer;
import net.fabricmc.loader.api.metadata.ModOrigin;
import net.fabricmc.loader.impl.discovery.ModCandidate;
import net.fabricmc.loader.impl.discovery.ModCandidateImpl;
import net.fabricmc.loader.impl.metadata.LoaderModMetadata;
import net.fabricmc.loader.impl.metadata.ModOriginImpl;
import net.fabricmc.loader.impl.util.FileSystemUtil;
Expand All @@ -47,13 +47,13 @@ public class ModContainerImpl extends net.fabricmc.loader.ModContainer {

private volatile List<Path> roots;

public ModContainerImpl(ModCandidate candidate) {
public ModContainerImpl(ModCandidateImpl candidate) {
this.info = candidate.getMetadata();
this.codeSourcePaths = candidate.getPaths();
this.parentModId = candidate.getParentMods().isEmpty() ? null : candidate.getParentMods().iterator().next().getId();
this.childModIds = candidate.getNestedMods().isEmpty() ? Collections.emptyList() : new ArrayList<>(candidate.getNestedMods().size());

for (ModCandidate c : candidate.getNestedMods()) {
for (ModCandidateImpl c : candidate.getNestedMods()) {
if (c.getParentMods().size() <= 1 || c.getParentMods().iterator().next() == candidate) {
childModIds.add(c.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ class Explanation implements Comparable<Explanation> {
private static int nextCmpId;

final ErrorKind error;
final ModCandidate mod;
final ModCandidateImpl mod;
final ModDependency dep;
final String data;
private final int cmpId;

Explanation(ErrorKind error, ModCandidate mod) {
Explanation(ErrorKind error, ModCandidateImpl mod) {
this(error, mod, null, null);
}

Explanation(ErrorKind error, ModCandidate mod, ModDependency dep) {
Explanation(ErrorKind error, ModCandidateImpl mod, ModDependency dep) {
this(error, mod, dep, null);
}

Explanation(ErrorKind error, String data) {
this(error, null, data);
}

Explanation(ErrorKind error, ModCandidate mod, String data) {
Explanation(ErrorKind error, ModCandidateImpl mod, String data) {
this(error, mod, null, data);
}

private Explanation(ErrorKind error, ModCandidate mod, ModDependency dep, String data) {
private Explanation(ErrorKind error, ModCandidateImpl mod, ModDependency dep, String data) {
this.error = error;
this.mod = mod;
this.dep = dep;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
import net.fabricmc.loader.impl.metadata.LoaderModMetadata;
import net.fabricmc.loader.impl.metadata.VersionOverrides;

public final class ModCandidate implements DomainObject.Mod {
static final Comparator<ModCandidate> ID_VERSION_COMPARATOR = new Comparator<ModCandidate>() {
public final class ModCandidateImpl implements DomainObject.Mod {
static final Comparator<ModCandidateImpl> ID_VERSION_COMPARATOR = new Comparator<ModCandidateImpl>() {
@Override
public int compare(ModCandidate a, ModCandidate b) {
public int compare(ModCandidateImpl a, ModCandidateImpl b) {
int cmp = a.getId().compareTo(b.getId());

return cmp != 0 ? cmp : a.getVersion().compareTo(b.getVersion());
Expand All @@ -57,25 +57,25 @@ public int compare(ModCandidate a, ModCandidate b) {
private final long hash;
private final LoaderModMetadata metadata;
private final boolean requiresRemap;
private final Collection<ModCandidate> nestedMods;
private final Collection<ModCandidate> parentMods;
private final Collection<ModCandidateImpl> nestedMods;
private final Collection<ModCandidateImpl> parentMods;
private int minNestLevel;
private SoftReference<ByteBuffer> dataRef;

static ModCandidate createBuiltin(BuiltinMod mod, VersionOverrides versionOverrides, DependencyOverrides depOverrides) {
static ModCandidateImpl createBuiltin(BuiltinMod mod, VersionOverrides versionOverrides, DependencyOverrides depOverrides) {
LoaderModMetadata metadata = new BuiltinMetadataWrapper(mod.metadata);
versionOverrides.apply(metadata);
depOverrides.apply(metadata);

return new ModCandidate(mod.paths, null, -1, metadata, false, Collections.emptyList());
return new ModCandidateImpl(mod.paths, null, -1, metadata, false, Collections.emptyList());
}

static ModCandidate createPlain(List<Path> paths, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidate> nestedMods) {
return new ModCandidate(paths, null, -1, metadata, requiresRemap, nestedMods);
static ModCandidateImpl createPlain(List<Path> paths, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidateImpl> nestedMods) {
return new ModCandidateImpl(paths, null, -1, metadata, requiresRemap, nestedMods);
}

static ModCandidate createNested(String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidate> nestedMods) {
return new ModCandidate(null, localPath, hash, metadata, requiresRemap, nestedMods);
static ModCandidateImpl createNested(String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidateImpl> nestedMods) {
return new ModCandidateImpl(null, localPath, hash, metadata, requiresRemap, nestedMods);
}

static long hash(ZipEntry entry) {
Expand All @@ -88,7 +88,7 @@ private static long getSize(long hash) {
return hash & 0xffffffffL;
}

private ModCandidate(List<Path> paths, String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidate> nestedMods) {
private ModCandidateImpl(List<Path> paths, String localPath, long hash, LoaderModMetadata metadata, boolean requiresRemap, Collection<ModCandidateImpl> nestedMods) {
this.originPaths = paths;
this.paths = paths;
this.localPath = localPath;
Expand Down Expand Up @@ -165,15 +165,15 @@ public boolean getRequiresRemap() {
return requiresRemap;
}

public Collection<ModCandidate> getNestedMods() {
public Collection<ModCandidateImpl> getNestedMods() {
return nestedMods;
}

public Collection<ModCandidate> getParentMods() {
public Collection<ModCandidateImpl> getParentMods() {
return parentMods;
}

boolean addParent(ModCandidate parent) {
boolean addParent(ModCandidateImpl parent) {
if (minNestLevel == 0) return false;
if (parentMods.contains(parent)) return false;

Expand All @@ -196,7 +196,7 @@ boolean resetMinNestLevel() {
}
}

boolean updateMinNestLevel(ModCandidate parent) {
boolean updateMinNestLevel(ModCandidateImpl parent) {
if (minNestLevel <= parent.minNestLevel) return false;

this.minNestLevel = parent.minNestLevel + 1;
Expand Down Expand Up @@ -290,7 +290,7 @@ private void copyToFile(Path out) throws IOException {
return;
}

ModCandidate parent = getBestSourcingParent();
ModCandidateImpl parent = getBestSourcingParent();

if (parent.paths != null) {
if (parent.paths.size() != 1) throw new UnsupportedOperationException("multiple parent paths for "+this);
Expand Down Expand Up @@ -334,7 +334,7 @@ private ByteBuffer getData() throws IOException {

ret = ByteBuffer.wrap(Files.readAllBytes(paths.get(0)));
} else {
ModCandidate parent = getBestSourcingParent();
ModCandidateImpl parent = getBestSourcingParent();

if (parent.paths != null) {
if (parent.paths.size() != 1) throw new UnsupportedOperationException("multiple parent paths for "+this);
Expand Down Expand Up @@ -369,12 +369,12 @@ private ByteBuffer getData() throws IOException {
return ret;
}

private ModCandidate getBestSourcingParent() {
private ModCandidateImpl getBestSourcingParent() {
if (parentMods.isEmpty()) return null;

ModCandidate ret = null;
ModCandidateImpl ret = null;

for (ModCandidate parent : parentMods) {
for (ModCandidateImpl parent : parentMods) {
if (parent.minNestLevel >= minNestLevel) continue;

if (parent.paths != null && parent.paths.size() == 1
Expand Down
Loading

0 comments on commit da94132

Please sign in to comment.