If we couldn't find a jail from the prisoner, get the first jail.

Also, don't try to load prisoners if there are no jails.
This commit is contained in:
graywolf336 2014-04-28 22:27:41 -05:00
parent cb88948c29
commit 998c7bd824

View File

@ -103,6 +103,7 @@ public class OldInputOutput {
}
public void LoadPrisoners() throws SQLException {
if(pl.getJailManager().getJails().size() != 0) {
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_prisoners");
ResultSet set = ps.executeQuery();
while (set.next()) {
@ -116,21 +117,24 @@ public class OldInputOutput {
transfer = true;
}
//Check if the jail exists, if not then we refuse to load it
if(j != null) {
//In the event the jail is null (jail didn't transfer or the prisoner was jailed offline and no jail specified
if(j == null) {
j = pl.getJailManager().getJails().iterator().next();
}
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), (long) set.getInt("RemainTime"), set.getString("Jailer"), set.getString("reason"));
p.setOfflinePending(set.getBoolean("Offline"));
p.setToBeTransferred(transfer);
j.addPrisoner(p);
//String permissions = set.getString("Permissions"); TODO
}else {
pl.getLogger().warning("Failed to load the prisoner " + name + " from the old database as the Jail doesn't exist.");
}
}
set.close();
ps.close();
}else {
pl.getLogger().warning("No prisoners were transferred from the old database since there aren't any jails defined.");
}
}
public void LoadCells() throws SQLException {