46 lines
1.8 KiB
Java
46 lines
1.8 KiB
Java
|
/*
|
||
|
* Copyright (c) 2018 univento.eu - All rights reserved
|
||
|
* You are not allowed to use, distribute or modify this code
|
||
|
*/
|
||
|
|
||
|
package eu.univento.core.api.items;
|
||
|
|
||
|
import eu.univento.core.Core;
|
||
|
import io.vertx.core.json.JsonObject;
|
||
|
import io.vertx.ext.web.client.WebClient;
|
||
|
import lombok.Getter;
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
|
||
|
public class HeadDB {
|
||
|
|
||
|
@Getter private HashMap<String, String> blocks = new HashMap<>();
|
||
|
@Getter private HashMap<String, String> food = new HashMap<>();
|
||
|
@Getter private HashMap<String, String> electronics = new HashMap<>();
|
||
|
@Getter private HashMap<String, String> characters = new HashMap<>();
|
||
|
@Getter private HashMap<String, String> flags = new HashMap<>();
|
||
|
@Getter private HashMap<String, String> letters = new HashMap<>();
|
||
|
@Getter private HashMap<String, String> halloween = new HashMap<>();
|
||
|
@Getter private HashMap<String, String> christmas = new HashMap<>();
|
||
|
|
||
|
public HeadDB() {
|
||
|
get("blocks", blocks);
|
||
|
get("food", food);
|
||
|
get("electronics", electronics);
|
||
|
get("characters", characters);
|
||
|
get("flags", flags);
|
||
|
get("letters", letters);
|
||
|
get("halloween", halloween);
|
||
|
get("christmas", christmas);
|
||
|
}
|
||
|
|
||
|
private void get(String name, HashMap<String, String> map) {
|
||
|
WebClient.create(Core.getCommons().getVertx()).get(443, "headdb.com", "/api/category/" + name).ssl(true).send(event -> {
|
||
|
if (event.failed()) event.cause().printStackTrace();
|
||
|
event.result().bodyAsJsonObject().forEach(stringObjectEntry -> {
|
||
|
JsonObject json = new JsonObject(stringObjectEntry.getValue().toString());
|
||
|
map.put(json.getString("name"), json.getJsonObject("valueDecoded").getJsonObject("textures").getJsonObject("SKIN").getString("url"));
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|