diff --git a/src/main/java/name/ipsi/project/fwbp/foundry/Author.java b/src/main/java/name/ipsi/project/fwbp/foundry/Author.java new file mode 100644 index 0000000..051dd98 --- /dev/null +++ b/src/main/java/name/ipsi/project/fwbp/foundry/Author.java @@ -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 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 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 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 + + '}'; + } +} diff --git a/src/main/java/name/ipsi/project/fwbp/foundry/Compatibility.java b/src/main/java/name/ipsi/project/fwbp/foundry/Compatibility.java new file mode 100644 index 0000000..043d08c --- /dev/null +++ b/src/main/java/name/ipsi/project/fwbp/foundry/Compatibility.java @@ -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 + '\'' + + '}'; + } +} diff --git a/src/main/java/name/ipsi/project/fwbp/foundry/Module.java b/src/main/java/name/ipsi/project/fwbp/foundry/Module.java index 2defbcf..3447c8f 100644 --- a/src/main/java/name/ipsi/project/fwbp/foundry/Module.java +++ b/src/main/java/name/ipsi/project/fwbp/foundry/Module.java @@ -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 authors; + @Deprecated private final String minimumCoreVersion; + @Deprecated private final String compatibleCoreVersion; + private final Compatibility compatibility; private final List packs; + public Module( + String name, + String title, + String description, + String version, + List authors, + Compatibility compatibility, + List 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, @@ -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; } @@ -49,18 +80,29 @@ public String getVersion() { return version; } + @Deprecated public String getAuthor() { return author; } + public List getAuthors() { + return authors; + } + + @Deprecated public String getMinimumCoreVersion() { return minimumCoreVersion; } + @Deprecated public String getCompatibleCoreVersion() { return compatibleCoreVersion; } + public Compatibility getCompatibility() { + return compatibility; + } + public List getPacks() { return packs; } @@ -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 @@ -93,8 +137,10 @@ public String toString() { "description=" + description + ", " + "version=" + version + ", " + "author=" + author + ", " + + "authors=" + authors + ", " + "minimumCoreVersion=" + minimumCoreVersion + ", " + "compatibleCoreVersion=" + compatibleCoreVersion + ", " + + "compatibility=" + compatibility + ", " + "packs=" + packs + ']'; } diff --git a/src/main/java/name/ipsi/project/fwbp/foundry/ModuleGenerator.java b/src/main/java/name/ipsi/project/fwbp/foundry/ModuleGenerator.java index 97093a5..d891749 100644 --- a/src/main/java/name/ipsi/project/fwbp/foundry/ModuleGenerator.java +++ b/src/main/java/name/ipsi/project/fwbp/foundry/ModuleGenerator.java @@ -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 { @@ -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 ); diff --git a/src/test/java/name/ipsi/project/fwbp/MainTest.java b/src/test/java/name/ipsi/project/fwbp/MainTest.java index c898550..5c8cfe0 100644 --- a/src/test/java/name/ipsi/project/fwbp/MainTest.java +++ b/src/test/java/name/ipsi/project/fwbp/MainTest.java @@ -25,7 +25,7 @@ void testMainMethod() throws Exception { Main.main(new String[]{}); var expectedFiles = new TreeMap(); - 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");