feat(Socket): support for all type
All checks were successful
Build the Docker Image / docker (push) Successful in 4m43s
All checks were successful
Build the Docker Image / docker (push) Successful in 4m43s
This commit is contained in:
parent
bc6b14498d
commit
c48956563d
1 changed files with 44 additions and 0 deletions
|
@ -54,6 +54,26 @@ public class CosmeticSocket implements SocketHandler, ListenerAdapter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.contains("all")) {
|
||||||
|
|
||||||
|
String type = data.getString("all");
|
||||||
|
|
||||||
|
JsonObject cosmetic = allServerCosmetics(type);
|
||||||
|
System.out.println(cosmetic);
|
||||||
|
|
||||||
|
Json result = JsonParser.parse("{}");
|
||||||
|
result.set("id", data.getLong("id"));
|
||||||
|
result.set("all", type);
|
||||||
|
result.set("result", false);
|
||||||
|
|
||||||
|
if (cosmetic != null) {
|
||||||
|
result.set("result", cosmetic);
|
||||||
|
}
|
||||||
|
|
||||||
|
exchange.client().sendMessage(result.toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.contains("cosmetics") && data.contains("uuid")) {
|
if (data.contains("cosmetics") && data.contains("uuid")) {
|
||||||
UUID uuid = UUID.fromString(data.getString("uuid"));
|
UUID uuid = UUID.fromString(data.getString("uuid"));
|
||||||
|
|
||||||
|
@ -112,6 +132,30 @@ public class CosmeticSocket implements SocketHandler, ListenerAdapter {
|
||||||
.getObject();
|
.getObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JsonObject allServerCosmetics(String type) {
|
||||||
|
Json serverCosmetics = CosmeticServer.instance().getServerCosmetics();
|
||||||
|
if (!serverCosmetics.contains(type + ".")) return null;
|
||||||
|
|
||||||
|
Json allCosmetics = Json.empty();
|
||||||
|
|
||||||
|
for (String cosmeticName : serverCosmetics.getJson(type).keySet()) {
|
||||||
|
Json cosmetic = serverCosmetics.getJson(type + "." + cosmeticName);
|
||||||
|
|
||||||
|
String id = cosmetic.contains("id") ? cosmetic.getString("id") : cosmeticName;
|
||||||
|
|
||||||
|
Json cosmeticObject = JsonParser.parse("{}")
|
||||||
|
.set("display", cosmetic.contains("display") ? cosmetic.get("display") : cosmeticName)
|
||||||
|
.set("name", cosmeticName)
|
||||||
|
.set("delay", cosmetic.contains("delay") ? cosmetic.getInt("delay") : 30)
|
||||||
|
.set("frames", cosmetic.contains("frames") ? cosmetic.getStringList("frames").size() : 1)
|
||||||
|
.set("url", "https://cosmetic.airclient.pauljako.de/v1/cosmetic/assets/" + type + "/" + cosmeticName + "/frame_" + id);
|
||||||
|
|
||||||
|
allCosmetics.set(cosmeticName, cosmeticObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
return allCosmetics.getObject().getAsJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
private JsonElement bakeData(ConcurrentHashMap<String, Object> elements) {
|
private JsonElement bakeData(ConcurrentHashMap<String, Object> elements) {
|
||||||
Json object = JsonParser.parse("{}");
|
Json object = JsonParser.parse("{}");
|
||||||
elements.forEach(object::set);
|
elements.forEach(object::set);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue