Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ repositories {
dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.2'
implementation group: 'io.javalin', name: 'javalin', version: '3.13.13'
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.32'
implementation group: 'org.tinylog', name: 'slf4j-tinylog', version: '2.7.0'
implementation group: 'org.tinylog', name: 'tinylog-api', version: '2.7.0'
implementation group: 'org.tinylog', name: 'tinylog-impl', version: '2.7.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.14.0'
implementation group: 'com.vdurmont', name: 'semver4j', version: '3.1.0'
implementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.5.13'
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/ornithemc/meta/OrnitheMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.ornithemc.meta.data.VersionDatabase;
import net.ornithemc.meta.data.VersionDatabaseOld;
import net.ornithemc.meta.web.WebServer;
import org.tinylog.Logger;
import org.tinylog.TaggedLogger;

import javax.xml.stream.XMLStreamException;
import java.io.IOException;
Expand All @@ -36,8 +38,10 @@ public class OrnitheMeta
public static volatile VersionDatabaseOld databaseOld;
public static volatile VersionDatabase database;
public static final ObjectMapper MAPPER = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
public static final TaggedLogger LOGGER = Logger.tag("ornithe-meta");

public static void main(String[] args) {
LOGGER.warn("Starting up!");

update();

Expand All @@ -52,7 +56,7 @@ private static void update(){
databaseOld = VersionDatabaseOld.generate();
database = VersionDatabase.generate();
} catch (IOException | XMLStreamException e) {
e.printStackTrace();
Logger.error(e);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/ornithemc/meta/data/VersionDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static VersionDatabase generate() throws IOException, XMLStreamException
database.oslModules.put(module, parser.getMeta(MavenVersion::new, "net.ornithemc.osl:" + module + ":"));
}
database.loadMcData();
System.out.println("DB update took " + (System.currentTimeMillis() - start) + "ms");
OrnitheMeta.LOGGER.info("DB update took {}ms", System.currentTimeMillis() - start);
return database;
}

Expand Down Expand Up @@ -205,7 +205,7 @@ private void loadMcData() throws IOException {
// Remove entries that do not match a valid mc version.
value.removeIf(o -> {
if (launcherMeta.getVersions().stream().noneMatch(metaVersion -> metaVersion.getId().equals(o.getVersionNoSide()))) {
System.out.println("Removing " + o.getVersion() + " from intermediary v3" + (gen < 1 ? "" : " gen" + gen) + " as it does not match a mc version");
OrnitheMeta.LOGGER.info("Removing {} from intermediary v3{} as it does not match a mc version", o.getVersion(), (gen < 1 ? "" : " gen" + gen));
return true;
}
return false;
Expand All @@ -222,7 +222,7 @@ private void loadMcData() throws IOException {
// Remove entries that do not match a valid mc version.
value.removeIf(o -> {
if (launcherMeta.getVersions().stream().noneMatch(metaVersion -> metaVersion.getId().equals(o.getVersionNoSide()))) {
System.out.println("Removing " + o.getGameVersion() + " from v3 feather" + " gen" + gen + " as it does not match a mc version");
OrnitheMeta.LOGGER.info("Removing {} from v3 feather gen{} as it does not match a mc version", o.getGameVersion(), gen);
return true;
}
return false;
Expand All @@ -248,7 +248,7 @@ private void loadMcData() throws IOException {
return false;
}
}
System.out.println("Removing " + o.getGameVersion() + " from " + src + " as it does not match a mc version");
OrnitheMeta.LOGGER.info("Removing {} from {} as it does not match a mc version", o.getGameVersion(), src);
return true;
};
};
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/ornithemc/meta/data/VersionDatabaseOld.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package net.ornithemc.meta.data;

import net.ornithemc.meta.OrnitheMeta;
import net.ornithemc.meta.utils.MinecraftLauncherMeta;
import net.ornithemc.meta.utils.PomParser;
import net.ornithemc.meta.web.models.BaseVersion;
Expand Down Expand Up @@ -63,7 +64,7 @@ public static VersionDatabaseOld generate() throws IOException, XMLStreamExcepti
});
database.installer = INSTALLER_PARSER.getMeta(MavenUrlVersion::new, "net.ornithemc:ornithe-installer-old:");
database.loadMcData();
System.out.println("DB update took " + (System.currentTimeMillis() - start) + "ms");
OrnitheMeta.LOGGER.info("DB update took {}ms", System.currentTimeMillis() - start);
return database;
}

Expand All @@ -88,7 +89,7 @@ private void loadMcData() throws IOException {
}

if (launcherMeta.getVersions().stream().noneMatch(metaVersion -> metaVersion.getId().equals(iVersion))) {
System.out.println("Removing " + o.getVersion() + " as it is not match an mc version (v2)");
OrnitheMeta.LOGGER.info("Removing {} as it is not match an mc version (v2)", o.getVersion());
return true;
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/ornithemc/meta/utils/LoaderMetaV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ public static JsonNode getMeta(LoaderInfoBase loaderInfo) {
if (!launcherMetaFile.exists()) {
try {
String url = String.format("%s%s/%s", VersionDatabaseOld.ORNITHE_MAVEN_URL, path, filename);
System.out.println("Downloading " + url);
OrnitheMeta.LOGGER.info("Downloading {}", url);
FileUtils.copyURLToFile(new URL(url), launcherMetaFile);
} catch (IOException e) {
e.printStackTrace();
OrnitheMeta.LOGGER.error(e);
return null;
}
}

try {
return OrnitheMeta.MAPPER.readTree(new FileReader(launcherMetaFile));
} catch (IOException e) {
e.printStackTrace();
OrnitheMeta.LOGGER.error(e);
return null;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/ornithemc/meta/utils/LoaderMetaV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ public static JsonNode getMeta(LoaderInfoBase loaderInfo) {
if (!launcherMetaFile.exists()) {
try {
String url = String.format("%s%s/%s", loaderMavenUrl, path, filename);
System.out.println("Downloading " + url);
OrnitheMeta.LOGGER.info("Downloading {}", url);
FileUtils.copyURLToFile(new URL(url), launcherMetaFile);
} catch (IOException e) {
e.printStackTrace();
OrnitheMeta.LOGGER.error(e);
return null;
}
}

try {
return OrnitheMeta.MAPPER.readTree(new FileReader(launcherMetaFile));
} catch (IOException e) {
e.printStackTrace();
OrnitheMeta.LOGGER.error(e);
return null;
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/tinylog.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
writer1 = console
writer1.level = info
writer1.format = {date} {level}: {message}

writer2 = rolling file
writer2.level = info
writer2.format = {date} {level}: {class}.{method}()\t{message}
writer2.file = logs/info-{date}.log
writer2.latest = logs/info-latest.log
writer2.policies = startup, size: 10mb
writer2.backups = 100
writer2.convert = gzip
writer2.writingthread = true

writer3 = rolling file
writer3.level = warn
writer3.format = {date} {level}: {class}.{method}()\t{message}
writer3.file = logs/warn-{date}.log
writer3.latest = logs/warn-latest.log
writer3.policies = startup, monthly
writer3.writingthread = true