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");
|
String transferDest = set.getString("TransferDest");
|
||||||
boolean transfer = false;
|
boolean transfer = false;
|
||||||
if(!transferDest.isEmpty()) {
|
if(!transferDest.isEmpty()) {
|
||||||
j = pl.getJailManager().getJail(transferDest);
|
j = pl.getJailManager().getJail(transferDest);
|
||||||
transfer = true;
|
transfer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if the jail exists, if not then we refuse to load it
|
//In the event the jail is null (jail didn't transfer or the prisoner was jailed offline and no jail specified
|
||||||
if(j != null) {
|
if(j == null) {
|
||||||
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), (long) set.getInt("RemainTime"), set.getString("Jailer"), set.getString("reason"));
|
j = pl.getJailManager().getJails().iterator().next();
|
||||||
p.setOfflinePending(set.getBoolean("Offline"));
|
}
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set.close();
|
j.addPrisoner(p);
|
||||||
ps.close();
|
//String permissions = set.getString("Permissions"); TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
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