Skip to content

Commit e2c3a06

Browse files
committed
Use JsonArray for warps & Pacts
1 parent 0a5defa commit e2c3a06

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/main/java/net/earthmc/emcapi/endpoint/towny/NationsEndpoint.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,15 @@ private JsonObject getPactsObject(Nation nation) {
134134
return json;
135135
}
136136

137-
JsonObject active = new JsonObject();
138-
JsonObject pending = new JsonObject();
137+
JsonArray active = new JsonArray();
138+
JsonArray pending = new JsonArray();
139139

140140
for (Pact pact : integration.getActivePacts(nation)) {
141-
Nation other = nation.equals(pact.getSenderNation()) ? pact.getReceivingNation() : pact.getSenderNation();
142-
active.add(other.getName(), EndpointUtils.getPactObject(pact));
141+
active.add(EndpointUtils.getPactObject(pact));
143142
}
144143

145144
for (Pact pact : integration.getPendingPacts(nation)) {
146-
Nation other = nation.equals(pact.getSenderNation()) ? pact.getReceivingNation() : pact.getSenderNation();
147-
pending.add(other.getName(), EndpointUtils.getPactObject(pact));
145+
pending.add(EndpointUtils.getPactObject(pact));
148146
}
149147

150148
json.add("active", active);

src/main/java/net/earthmc/emcapi/endpoint/towny/TownsEndpoint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ public JsonElement getJsonElement(Town town, @Nullable String key) {
129129
return townObject;
130130
}
131131

132-
private JsonObject getWarpsObject(Town town) {
133-
JsonObject json = new JsonObject();
132+
private JsonArray getWarpsObject(Town town) {
133+
JsonArray json = new JsonArray();
134134
WarpsIntegration integration = Integrations.getIntegration("lynchpin-towny-warps");
135135
if (integration == null || !integration.isEnabled()) {
136136
return json;
137137
}
138138

139139
for (Warp warp : integration.getWarps(town)) {
140-
json.add(warp.getName(), EndpointUtils.getWarpObject(warp));
140+
json.add(EndpointUtils.getWarpObject(warp));
141141
}
142142

143143
return json;

0 commit comments

Comments
 (0)