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:
parent
cb88948c29
commit
998c7bd824
@ -103,34 +103,38 @@ public class OldInputOutput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void LoadPrisoners() throws SQLException {
|
public void LoadPrisoners() throws SQLException {
|
||||||
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_prisoners");
|
if(pl.getJailManager().getJails().size() != 0) {
|
||||||
ResultSet set = ps.executeQuery();
|
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_prisoners");
|
||||||
while (set.next()) {
|
ResultSet set = ps.executeQuery();
|
||||||
Jail j = pl.getJailManager().getJail(set.getString("JailName"));
|
while (set.next()) {
|
||||||
String name = set.getString("PlayerName").toLowerCase();
|
Jail j = pl.getJailManager().getJail(set.getString("JailName"));
|
||||||
|
String name = set.getString("PlayerName").toLowerCase();
|
||||||
String transferDest = set.getString("TransferDest");
|
|
||||||
boolean transfer = false;
|
String transferDest = set.getString("TransferDest");
|
||||||
if(!transferDest.isEmpty()) {
|
boolean transfer = false;
|
||||||
j = pl.getJailManager().getJail(transferDest);
|
if(!transferDest.isEmpty()) {
|
||||||
transfer = true;
|
j = pl.getJailManager().getJail(transferDest);
|
||||||
}
|
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
|
||||||
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), (long) set.getInt("RemainTime"), set.getString("Jailer"), set.getString("reason"));
|
if(j == null) {
|
||||||
p.setOfflinePending(set.getBoolean("Offline"));
|
j = pl.getJailManager().getJails().iterator().next();
|
||||||
p.setToBeTransferred(transfer);
|
}
|
||||||
|
|
||||||
j.addPrisoner(p);
|
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), (long) set.getInt("RemainTime"), set.getString("Jailer"), set.getString("reason"));
|
||||||
//String permissions = set.getString("Permissions"); TODO
|
p.setOfflinePending(set.getBoolean("Offline"));
|
||||||
}else {
|
p.setToBeTransferred(transfer);
|
||||||
pl.getLogger().warning("Failed to load the prisoner " + name + " from the old database as the Jail doesn't exist.");
|
|
||||||
}
|
j.addPrisoner(p);
|
||||||
}
|
//String permissions = set.getString("Permissions"); TODO
|
||||||
|
}
|
||||||
set.close();
|
|
||||||
ps.close();
|
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 {
|
public void LoadCells() throws SQLException {
|
||||||
|
Loading…
Reference in New Issue
Block a user