Skip to content

Commit 3cf3bbf

Browse files
committed
Make fully V10-compatible, including new fields in module.json
1 parent 8fb449a commit 3cf3bbf

File tree

5 files changed

+173
-5
lines changed

5 files changed

+173
-5
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package name.ipsi.project.fwbp.foundry;
2+
3+
import java.util.Collections;
4+
import java.util.Map;
5+
import java.util.Objects;
6+
7+
public class Author {
8+
private final String name;
9+
private final String url;
10+
private final String discord;
11+
private final Map<String, Object> flags;
12+
13+
public Author(String name, String url, String discord) {
14+
this.name = name;
15+
this.url = url;
16+
this.discord = discord;
17+
this.flags = Collections.emptyMap();
18+
}
19+
20+
public Author(String name, String url, String discord, Map<String, Object> flags) {
21+
this.name = name;
22+
this.url = url;
23+
this.discord = discord;
24+
this.flags = flags;
25+
}
26+
27+
public String getName() {
28+
return name;
29+
}
30+
31+
public String getUrl() {
32+
return url;
33+
}
34+
35+
public String getDiscord() {
36+
return discord;
37+
}
38+
39+
public Map<String, Object> getFlags() {
40+
return flags;
41+
}
42+
43+
@Override
44+
public boolean equals(Object o) {
45+
if (this == o) return true;
46+
if (o == null || getClass() != o.getClass()) return false;
47+
Author author = (Author) o;
48+
return Objects.equals(name, author.name) && Objects.equals(url, author.url) && Objects.equals(discord, author.discord) && Objects.equals(flags, author.flags);
49+
}
50+
51+
@Override
52+
public int hashCode() {
53+
return Objects.hash(name, url, discord, flags);
54+
}
55+
56+
@Override
57+
public String toString() {
58+
return "Author{" +
59+
"name='" + name + '\'' +
60+
", url='" + url + '\'' +
61+
", discord='" + discord + '\'' +
62+
", flags=" + flags +
63+
'}';
64+
}
65+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package name.ipsi.project.fwbp.foundry;
2+
3+
import java.util.Objects;
4+
5+
public class Compatibility {
6+
private final String minimum;
7+
private final String verified;
8+
private final String maximum;
9+
10+
public Compatibility(String minimum, String verified, String maximum) {
11+
this.minimum = minimum;
12+
this.verified = verified;
13+
this.maximum = maximum;
14+
}
15+
16+
public String getMinimum() {
17+
return minimum;
18+
}
19+
20+
public String getVerified() {
21+
return verified;
22+
}
23+
24+
public String getMaximum() {
25+
return maximum;
26+
}
27+
28+
@Override
29+
public boolean equals(Object o) {
30+
if (this == o) return true;
31+
if (o == null || getClass() != o.getClass()) return false;
32+
Compatibility that = (Compatibility) o;
33+
return Objects.equals(minimum, that.minimum) && Objects.equals(verified, that.verified) && Objects.equals(maximum, that.maximum);
34+
}
35+
36+
@Override
37+
public int hashCode() {
38+
return Objects.hash(minimum, verified, maximum);
39+
}
40+
41+
@Override
42+
public String toString() {
43+
return "Compatibility{" +
44+
"minimum='" + minimum + '\'' +
45+
", verified='" + verified + '\'' +
46+
", maximum='" + maximum + '\'' +
47+
'}';
48+
}
49+
}

src/main/java/name/ipsi/project/fwbp/foundry/Module.java

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,47 @@
11
package name.ipsi.project.fwbp.foundry;
22

3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
35
import java.util.List;
46
import java.util.Objects;
57

8+
@JsonInclude(JsonInclude.Include.NON_NULL)
69
public final class Module {
710
private final String name;
811
private final String title;
912
private final String description;
1013
private final String version;
14+
@Deprecated
1115
private final String author;
16+
private final List<Author> authors;
17+
@Deprecated
1218
private final String minimumCoreVersion;
19+
@Deprecated
1320
private final String compatibleCoreVersion;
21+
private final Compatibility compatibility;
1422
private final List<ModulePack> packs;
1523

24+
public Module(
25+
String name,
26+
String title,
27+
String description,
28+
String version,
29+
List<Author> authors,
30+
Compatibility compatibility,
31+
List<ModulePack> packs
32+
) {
33+
this.name = name;
34+
this.title = title;
35+
this.description = description;
36+
this.version = version;
37+
this.author = null;
38+
this.authors = authors;
39+
this.minimumCoreVersion = null;
40+
this.compatibleCoreVersion = null;
41+
this.compatibility = compatibility;
42+
this.packs = packs;
43+
}
44+
1645
public Module(
1746
String name,
1847
String title,
@@ -28,8 +57,10 @@ public Module(
2857
this.description = description;
2958
this.version = version;
3059
this.author = author;
60+
this.authors = null;
3161
this.minimumCoreVersion = minimumCoreVersion;
3262
this.compatibleCoreVersion = compatibleCoreVersion;
63+
this.compatibility = null;
3364
this.packs = packs;
3465
}
3566

@@ -49,18 +80,29 @@ public String getVersion() {
4980
return version;
5081
}
5182

83+
@Deprecated
5284
public String getAuthor() {
5385
return author;
5486
}
5587

88+
public List<Author> getAuthors() {
89+
return authors;
90+
}
91+
92+
@Deprecated
5693
public String getMinimumCoreVersion() {
5794
return minimumCoreVersion;
5895
}
5996

97+
@Deprecated
6098
public String getCompatibleCoreVersion() {
6199
return compatibleCoreVersion;
62100
}
63101

102+
public Compatibility getCompatibility() {
103+
return compatibility;
104+
}
105+
64106
public List<ModulePack> getPacks() {
65107
return packs;
66108
}
@@ -75,14 +117,16 @@ public boolean equals(Object obj) {
75117
Objects.equals(this.description, that.description) &&
76118
Objects.equals(this.version, that.version) &&
77119
Objects.equals(this.author, that.author) &&
120+
Objects.equals(this.authors, that.authors) &&
78121
Objects.equals(this.minimumCoreVersion, that.minimumCoreVersion) &&
79122
Objects.equals(this.compatibleCoreVersion, that.compatibleCoreVersion) &&
123+
Objects.equals(this.compatibility, that.compatibility) &&
80124
Objects.equals(this.packs, that.packs);
81125
}
82126

83127
@Override
84128
public int hashCode() {
85-
return Objects.hash(name, title, description, version, author, minimumCoreVersion, compatibleCoreVersion, packs);
129+
return Objects.hash(name, title, description, version, author, authors, minimumCoreVersion, compatibleCoreVersion, compatibility, packs);
86130
}
87131

88132
@Override
@@ -93,8 +137,10 @@ public String toString() {
93137
"description=" + description + ", " +
94138
"version=" + version + ", " +
95139
"author=" + author + ", " +
140+
"authors=" + authors + ", " +
96141
"minimumCoreVersion=" + minimumCoreVersion + ", " +
97142
"compatibleCoreVersion=" + compatibleCoreVersion + ", " +
143+
"compatibility=" + compatibility + ", " +
98144
"packs=" + packs + ']';
99145
}
100146

src/main/java/name/ipsi/project/fwbp/foundry/ModuleGenerator.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.nio.file.attribute.BasicFileAttributes;
1414
import java.util.ArrayList;
1515
import java.util.Collection;
16+
import java.util.Collections;
1617
import java.util.stream.Stream;
1718

1819
public final class ModuleGenerator {
@@ -81,9 +82,16 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
8182
title,
8283
description,
8384
version,
84-
author,
85-
minVersion,
86-
compatibleVersion,
85+
Collections.singletonList(new Author(
86+
"Andrew Thorburn",
87+
"",
88+
"ipsi#2461"
89+
)),
90+
new Compatibility(
91+
"10",
92+
"10",
93+
"10"
94+
),
8795
modulePacks
8896
);
8997

src/test/java/name/ipsi/project/fwbp/MainTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void testMainMethod() throws Exception {
2525
Main.main(new String[]{});
2626

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

0 commit comments

Comments
 (0)