Skip to content

Commit

Permalink
change VersionDatabase to not spam console with "Removing ..." messag…
Browse files Browse the repository at this point in the history
…es (FabricMC#21)

* change VersionDatabase to not spam console with "Removing ..." messages

* change the message from intermediary to mc version

* use LoggerFactory, rearrange static fields, don't use string concat
  • Loading branch information
BluCobalt authored Apr 17, 2023
1 parent 5b695e1 commit 1b896f5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/net/fabricmc/meta/data/VersionDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.fabricmc.meta.utils.MinecraftLauncherMeta;
import net.fabricmc.meta.utils.PomParser;
import net.fabricmc.meta.web.models.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.stream.XMLStreamException;
import java.io.IOException;
Expand All @@ -37,6 +39,9 @@ public class VersionDatabase {
public static final PomParser LOADER_PARSER = new PomParser(MAVEN_URL + "net/fabricmc/fabric-loader/maven-metadata.xml");
public static final PomParser INSTALLER_PARSER = new PomParser(MAVEN_URL + "net/fabricmc/fabric-installer/maven-metadata.xml");

private static final ArrayList<String> incorrectVersions = new ArrayList<>();
private static final Logger LOGGER = LoggerFactory.getLogger(VersionDatabase.class);

public List<BaseVersion> game;
public List<MavenBuildGameVersion> mappings;
public List<MavenVersion> intermediary;
Expand All @@ -61,7 +66,7 @@ public static VersionDatabase generate() throws IOException, XMLStreamException
});
database.installer = INSTALLER_PARSER.getMeta(MavenUrlVersion::new, "net.fabricmc:fabric-installer:");
database.loadMcData();
System.out.println("DB update took " + (System.currentTimeMillis() - start) + "ms");
LOGGER.info("DB update took {} ms", (System.currentTimeMillis() - start));
return database;
}

Expand All @@ -79,7 +84,11 @@ private void loadMcData() throws IOException {
// Remove entries that do not match a valid mc version.
intermediary.removeIf(o -> {
if (launcherMeta.getVersions().stream().noneMatch(version -> version.getId().equals(o.getVersion()))) {
System.out.println("Removing " + o.getVersion() + " as it is not match an mc version");
// only print unmatched versions once so that it doesn't spam the console with "Removing ..." messages
if (incorrectVersions.stream().noneMatch(o.getVersion()::equals)) {
LOGGER.warn("Removing {} as it doesn't match a valid mc version", o.getVersion());
incorrectVersions.add(o.getVersion());
}
return true;
}
return false;
Expand Down

0 comments on commit 1b896f5

Please sign in to comment.