use of org.jsolf.JSONObject in project Emolga by TecToast.
the class Draft method getLeague.
public JSONObject getLeague() {
JSONObject drafts = getEmolgaJSON().getJSONObject("drafts");
Pattern aslpattern = Pattern.compile("^S\\d");
return aslpattern.matcher(name).find() ? drafts.getJSONObject("ASLS9").getJSONObject(name) : drafts.getJSONObject(name);
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class Draft method getTeamMembers.
public static List<Long> getTeamMembers(long userid) {
JSONObject asl = getEmolgaJSON().getJSONObject("drafts").getJSONObject("ASLS9");
int index = getIndex(userid);
LinkedList<Long> l = new LinkedList<>();
if (index == -1)
return l;
for (int i = 1; i <= 4; i++) {
l.add(asl.getJSONObject("S" + i).getLongList("table").get(index));
}
return l;
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class Draft method getTeamAsArray.
public JSONArray getTeamAsArray(long mem) {
JSONArray arr = new JSONArray();
for (DraftPokemon mon : picks.get(mem)) {
JSONObject obj = new JSONObject();
obj.put("name", mon.name);
obj.put("tier", mon.tier);
arr.put(obj);
}
return arr;
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class BanManager method getBans.
public JSONArray getBans(Guild g) {
try {
ResultSet set = GUILDID.getAll(g.getIdLong());
JSONArray arr = new JSONArray();
List<JSONObject> l = new LinkedList<>();
while (set.next()) {
l.add(new JSONObject().put("userid", USERID.getValue(set)).put("username", USERNAME.getValue(set)).put("modid", MODID.getValue(set)).put("reason", REASON.getValue(set)).put("timestamp", TIMESTAMP.getValue(set).getTime()));
}
Set<Long> idstocheck = new HashSet<>();
l.stream().map(j -> j.getLong("modid")).forEach(idstocheck::add);
HashMap<Long, String> names = new HashMap<>();
g.retrieveMembersByIds(idstocheck).get().forEach(mem -> names.put(mem.getIdLong(), mem.getEffectiveName()));
for (JSONObject j : l) {
long uid = j.getLong("userid");
arr.put(new JSONObject().put("name", j.getString("username")).put("id", String.valueOf(uid)).put("reason", j.getString("reason")).put("mod", names.get(j.getLong("modid"))).put("timestamp", j.getLong("timestamp")));
}
return arr;
} catch (Exception ex) {
ex.printStackTrace();
}
return new JSONArray().put(new JSONObject().put("name", "ERROR"));
}
use of org.jsolf.JSONObject in project Emolga by TecToast.
the class Database method init.
public static void init() {
JSONObject cred = Command.tokens.getJSONObject("database");
instance = new Database(cred.getString("username"), cred.getString("password"));
}
Aggregations