BmAPI Issue
Nokoa opened this issue ยท 1 comments
Hello again,
I have attempted to reduce the amounts of connection into database and close them in-order not to crash it with too many connections. It seems to work fine with MuteRecords, but not Ban, Warning, Records.
if (type == 1) { //Mute All of it works fine
CloseableIterator m = BmAPI.getMuteRecords(tar);
Reason = m.moveRelative(id).getReason();
Admin = m.moveRelative(id).getActor().getName();
Time = format.format(m.moveRelative(id).getPastCreated() * 1000);
TimeExp = format.format(m.moveRelative(id).getExpired() * 1000);
m.close();
} else if (type == 2) { // Ban
CloseableIterator<PlayerBanRecord> b = BmAPI.getBanRecords(tar);
Reason = b.moveRelative(id).getReason(); //works
Admin = b.moveRelative(id).getActor().getName(); //breaks
Time = format.format(b.moveRelative(id).getPastCreated() * 1000); //breaks
TimeExp = format.format(b.moveRelative(id).getExpired() * 1000); //breaks
// Admin = "ADMIN HERE";
// Time = "TIME HERE";
// TimeExp = "Never";
b.close();
} else if (type == 3) { //if warning
CloseableIterator<PlayerWarnData> w = BmAPI.getWarnings(tar);
Reason = w.moveRelative(id).getReason(); //works
Admin = w.moveRelative(id).getActor().getName(); //breaks
Time = format.format(w.moveRelative(id).getCreated() * 1000);//breaks
// Admin = "ADMIN HERE";
// Time = "TIME HERE";
TimeExp = "Never";
TimeExp = "N/A";
w.close();
But when it used to be like the below it worked, but opened way too many connections;
} else if (type == 2) { // ban
Reason = BmAPI.getBanRecords(BmAPI.getPlayer(target))
Admin = BmAPI.getBanRecords(BmAPI.getPlayer(target))
Time = format.format(BmAPI.getBanRecords(BmAPI.getPlayer(target))
TimeExp = format.format(BmAPI.getBanRecords(BmAPI.getPlayer(target)).moveRelative(id)
} else if (type == 3) { // warning
Reason = BmAPI.getWarnings(BmAPI.getPlayer(target))
Admin = BmAPI.getWarnings(BmAPI.getPlayer(target)).moveRelative(id)
Time = format.format(BmAPI.getWarnings(BmAPI.getPlayer(target))
TimeExp = "N/A";
}
Why is it breaking for only Warnings and Bans, but works for Mutes?