Skip to content

Commit

Permalink
Add support for aliases in the mod dependency graph
Browse files Browse the repository at this point in the history
  • Loading branch information
maddie480 committed Nov 12, 2023
1 parent 83c9d62 commit 08c86a2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Files and images are uploaded to [0x0ade's server](https://celestemodupdater.0x0
This file is generated at `uploads/moddependencygraph.yaml` and lists what each mod in `everestupdate.yaml` depends on:
```yaml
WitheredPassage:
Aliases: {}
OptionalDependencies: {}
Dependencies:
FrostHelper: 1.17.8
Expand Down Expand Up @@ -202,7 +203,7 @@ Get Maven, then run the following command at the project root:
mvn clean package
```

This will build the project to `target/update-checker-0.4.12.jar`.
This will build the project to `target/update-checker-0.5.0.jar`.

### Running the project

Expand All @@ -213,7 +214,7 @@ First, follow these steps to set it up:
Then, to run the project, browse to where the JAR is in a terminal / command prompt, then run

```
java -jar update-checker-0.4.12.jar [minutes]
java -jar update-checker-0.5.0.jar [minutes]
```
[minutes] is the wait delay in minutes between two GameBanana checks (defaults to 30). Be aware that the program makes ~13 API calls per check, and that the GameBanana API has a cap at 250 requests/hour.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ovh.maddie480.everest.updatechecker</groupId>
<artifactId>update-checker</artifactId>
<version>0.4.12</version>
<version>0.5.0</version>

<properties>
<jdk.version>21</jdk.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static HttpURLConnection openConnectionWithTimeout(String url) throws IOE
throw new IOException(e);
}

con.setRequestProperty("User-Agent", "Everest-Update-Checker/0.4.12 (+https://github.com/maddie480/EverestUpdateCheckerServer)");
con.setRequestProperty("User-Agent", "Everest-Update-Checker/0.5.0 (+https://github.com/maddie480/EverestUpdateCheckerServer)");
con.setRequestProperty("Accept-Encoding", "gzip");

con.setConnectTimeout(10000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ static void updateDependencyGraph() throws IOException {
// read its everest.yaml
Map<String, String> dependencies = new HashMap<>();
Map<String, String> optionalDependencies = new HashMap<>();
Map<String, String> aliases = new HashMap<>();
try (ZipFile zipFile = ZipFileWithAutoEncoding.open("mod-dependencytree.zip")) {
checkZipSignature(new File("mod-dependencytree.zip").toPath());

Expand All @@ -88,10 +89,14 @@ static void updateDependencyGraph() throws IOException {
if (yamlEntry.containsKey("OptionalDependencies")) {
addDependenciesFromList(optionalDependencies, (List<Map<String, Object>>) yamlEntry.get("OptionalDependencies"), everestYamlContents);
}
if (yamlEntry.containsKey("Aliases")) {
addDependenciesFromList(aliases, (List<Map<String, Object>>) yamlEntry.get("Aliases"), everestYamlContents);
}
}

log.info("Found {} dependencies and {} optional dependencies for {}.", dependencies.size(), optionalDependencies.size(), mod.getKey());
EventListener.handle(listener -> listener.scannedModDependencies(mod.getKey(), dependencies.size(), optionalDependencies.size()));
log.info("Found {} dependencies, {} optional dependencies and {} aliases for for {}.",
dependencies.size(), optionalDependencies.size(), aliases.size(), mod.getKey());
EventListener.handle(listener -> listener.scannedModDependencies(mod.getKey(), dependencies.size(), optionalDependencies.size(), aliases.size()));
} catch (Exception e) {
// if a file cannot be read as a zip, no need to worry about it.
// we will just write an empty array.
Expand All @@ -104,6 +109,7 @@ static void updateDependencyGraph() throws IOException {
graphEntry.put("URL", url);
graphEntry.put("Dependencies", dependencies);
graphEntry.put("OptionalDependencies", optionalDependencies);
graphEntry.put("Aliases", aliases);
newDependencyGraph.put(mod.getKey(), graphEntry);

FileUtils.forceDelete(new File("mod-dependencytree.zip"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void handle(Consumer<EventListener> functionCall) {

public abstract void scannedLoennEntities(String fileUrl, int entityCount, int triggerCount, int effectCount);

public abstract void scannedModDependencies(String modId, int dependencyCount, int optionalDependencyCount);
public abstract void scannedModDependencies(String modId, int dependencyCount, int optionalDependencyCount, int aliasCount);

public abstract void modUpdatedIncrementally(String gameBananaType, int gameBananaId, String modName);

Expand Down

0 comments on commit 08c86a2

Please sign in to comment.