Skip to content

Commit

Permalink
Make fully V10-compatible, including new fields in module.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ipsi committed Sep 4, 2022
1 parent 8fb449a commit 3cf3bbf
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 5 deletions.
65 changes: 65 additions & 0 deletions src/main/java/name/ipsi/project/fwbp/foundry/Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package name.ipsi.project.fwbp.foundry;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;

public class Author {
private final String name;
private final String url;
private final String discord;
private final Map<String, Object> flags;

public Author(String name, String url, String discord) {
this.name = name;
this.url = url;
this.discord = discord;
this.flags = Collections.emptyMap();
}

public Author(String name, String url, String discord, Map<String, Object> flags) {
this.name = name;
this.url = url;
this.discord = discord;
this.flags = flags;
}

public String getName() {
return name;
}

public String getUrl() {
return url;
}

public String getDiscord() {
return discord;
}

public Map<String, Object> getFlags() {
return flags;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Author author = (Author) o;
return Objects.equals(name, author.name) && Objects.equals(url, author.url) && Objects.equals(discord, author.discord) && Objects.equals(flags, author.flags);
}

@Override
public int hashCode() {
return Objects.hash(name, url, discord, flags);
}

@Override
public String toString() {
return "Author{" +
"name='" + name + '\'' +
", url='" + url + '\'' +
", discord='" + discord + '\'' +
", flags=" + flags +
'}';
}
}
49 changes: 49 additions & 0 deletions src/main/java/name/ipsi/project/fwbp/foundry/Compatibility.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package name.ipsi.project.fwbp.foundry;

import java.util.Objects;

public class Compatibility {
private final String minimum;
private final String verified;
private final String maximum;

public Compatibility(String minimum, String verified, String maximum) {
this.minimum = minimum;
this.verified = verified;
this.maximum = maximum;
}

public String getMinimum() {
return minimum;
}

public String getVerified() {
return verified;
}

public String getMaximum() {
return maximum;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Compatibility that = (Compatibility) o;
return Objects.equals(minimum, that.minimum) && Objects.equals(verified, that.verified) && Objects.equals(maximum, that.maximum);
}

@Override
public int hashCode() {
return Objects.hash(minimum, verified, maximum);
}

@Override
public String toString() {
return "Compatibility{" +
"minimum='" + minimum + '\'' +
", verified='" + verified + '\'' +
", maximum='" + maximum + '\'' +
'}';
}
}
48 changes: 47 additions & 1 deletion src/main/java/name/ipsi/project/fwbp/foundry/Module.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
package name.ipsi.project.fwbp.foundry;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.List;
import java.util.Objects;

@JsonInclude(JsonInclude.Include.NON_NULL)
public final class Module {
private final String name;
private final String title;
private final String description;
private final String version;
@Deprecated
private final String author;
private final List<Author> authors;
@Deprecated
private final String minimumCoreVersion;
@Deprecated
private final String compatibleCoreVersion;
private final Compatibility compatibility;
private final List<ModulePack> packs;

public Module(
String name,
String title,
String description,
String version,
List<Author> authors,
Compatibility compatibility,
List<ModulePack> packs
) {
this.name = name;
this.title = title;
this.description = description;
this.version = version;
this.author = null;
this.authors = authors;
this.minimumCoreVersion = null;
this.compatibleCoreVersion = null;
this.compatibility = compatibility;
this.packs = packs;
}

public Module(
String name,
String title,
Expand All @@ -28,8 +57,10 @@ public Module(
this.description = description;
this.version = version;
this.author = author;
this.authors = null;
this.minimumCoreVersion = minimumCoreVersion;
this.compatibleCoreVersion = compatibleCoreVersion;
this.compatibility = null;
this.packs = packs;
}

Expand All @@ -49,18 +80,29 @@ public String getVersion() {
return version;
}

@Deprecated
public String getAuthor() {
return author;
}

public List<Author> getAuthors() {
return authors;
}

@Deprecated
public String getMinimumCoreVersion() {
return minimumCoreVersion;
}

@Deprecated
public String getCompatibleCoreVersion() {
return compatibleCoreVersion;
}

public Compatibility getCompatibility() {
return compatibility;
}

public List<ModulePack> getPacks() {
return packs;
}
Expand All @@ -75,14 +117,16 @@ public boolean equals(Object obj) {
Objects.equals(this.description, that.description) &&
Objects.equals(this.version, that.version) &&
Objects.equals(this.author, that.author) &&
Objects.equals(this.authors, that.authors) &&
Objects.equals(this.minimumCoreVersion, that.minimumCoreVersion) &&
Objects.equals(this.compatibleCoreVersion, that.compatibleCoreVersion) &&
Objects.equals(this.compatibility, that.compatibility) &&
Objects.equals(this.packs, that.packs);
}

@Override
public int hashCode() {
return Objects.hash(name, title, description, version, author, minimumCoreVersion, compatibleCoreVersion, packs);
return Objects.hash(name, title, description, version, author, authors, minimumCoreVersion, compatibleCoreVersion, compatibility, packs);
}

@Override
Expand All @@ -93,8 +137,10 @@ public String toString() {
"description=" + description + ", " +
"version=" + version + ", " +
"author=" + author + ", " +
"authors=" + authors + ", " +
"minimumCoreVersion=" + minimumCoreVersion + ", " +
"compatibleCoreVersion=" + compatibleCoreVersion + ", " +
"compatibility=" + compatibility + ", " +
"packs=" + packs + ']';
}

Expand Down
14 changes: 11 additions & 3 deletions src/main/java/name/ipsi/project/fwbp/foundry/ModuleGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.stream.Stream;

public final class ModuleGenerator {
Expand Down Expand Up @@ -81,9 +82,16 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
title,
description,
version,
author,
minVersion,
compatibleVersion,
Collections.singletonList(new Author(
"Andrew Thorburn",
"",
"ipsi#2461"
)),
new Compatibility(
"10",
"10",
"10"
),
modulePacks
);

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/name/ipsi/project/fwbp/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void testMainMethod() throws Exception {
Main.main(new String[]{});

var expectedFiles = new TreeMap<Path, String>();
expectedFiles.put(Path.of("modules", "wod-werewolf-20-core", "module.json"), "f8f7a74891abea8ba9c649aa97223ac18f94173218a9902cf0a4541e1c96e9a6870c2fb98a3917db79bddad2e4a334ca234100ca4936b6ba2009529d83503bde");
expectedFiles.put(Path.of("modules", "wod-werewolf-20-core", "module.json"), "f79bddaadad4b45444b91ffab880eacfe091dc49edc4e5b92d9641a66dca321d5ab32460ae1204d1905186bf2d6f90903a1e6088fba4b60cb679b3eecf661dec");
expectedFiles.put(Path.of("modules", "wod-werewolf-20-core", "packs", "auspices.db"), "614157c2c41b18a9ce7d16405c48c3dc0e814690eca875fc3b0635ff599682ca622e26fbc8a0a00c406c9ce469a0efee88aeb903e83d42b31c892745185e2f0c");
expectedFiles.put(Path.of("modules", "wod-werewolf-20-core", "packs", "breeds.db"), "845067b391529bb99dd30f3676ee84534faf4b92d8907f8be880c990c7c442a63c2c057fe1e7132b9a7bc95999282b57412717cfa5a6d715e608836cb994aa86");
expectedFiles.put(Path.of("modules", "wod-werewolf-20-core", "packs", "gifts.db"), "dcceddf58db10eb31339bf6ee2e3c6494361039d3b3026bf2204942691718a1c9cf3fd6391632601d933689b1484a4a5cce6c2ded8607f5a2c53ad57e0d3828c");
Expand Down

0 comments on commit 3cf3bbf

Please sign in to comment.