public boolean canJoin(Player p)
{
return (sql.getReserveMethod(p) != null);
}
Co zwroci ta funkcja, jeśli sql.getReserveMethod(p) == null
, a co jeśli sql.getReserveMethod(p) == CosInnego
? Funkcja getReserveMethod wygląda tak:
public String getReserveMethod(Player player) {
Connection conn = getSQLConnection();
PreparedStatement ps = null;
ResultSet rs = null;
String mysqlTable = plugin.getConfig().getString("mysql-table");
try {
ps = conn.prepareStatement("SELECT * FROM " + mysqlTable + " WHERE name = ? ORDER BY id DESC LIMIT 1");
String p = player.toString();
ps.setString(1, p);
rs = ps.executeQuery();
while (rs.next()){
String type = rs.getString("type");
return type;
}
} catch (SQLException ex) {
SimpleReserve.log.log(Level.SEVERE, "[SimpleReserve] Couldn't execute MySQL statement: ", ex);
} finally {
try {
if (ps != null)
ps.close();
if (conn != null)
conn.close();
} catch (SQLException ex) {
SimpleReserve.log.log(Level.SEVERE, "[SimpleReserve] Failed to close MySQL connection: ", ex);
}
}
return null;
}
Dodam, ze jest to plugin do gry Minecraft.