mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2025-02-06 00:04:29 +01:00
Minor cleanup in SessionLookup class
This commit is contained in:
parent
50689604dd
commit
c5d5308753
@ -16,12 +16,16 @@ public class SessionLookup {
|
||||
|
||||
public static final int ID = 0;
|
||||
|
||||
public static List<String[]> performLookup(String user, int offset) {
|
||||
if (!Config.getGlobal().API_ENABLED) {
|
||||
return null;
|
||||
private SessionLookup() {
|
||||
throw new IllegalStateException("API class");
|
||||
}
|
||||
|
||||
public static List<String[]> performLookup(String user, int offset) {
|
||||
List<String[]> result = new ArrayList<>();
|
||||
if (!Config.getGlobal().API_ENABLED) {
|
||||
return result;
|
||||
}
|
||||
|
||||
try (Connection connection = Database.getConnection(false, 1000)) {
|
||||
if (connection == null || user == null) {
|
||||
return result;
|
||||
@ -39,7 +43,7 @@ public class SessionLookup {
|
||||
}
|
||||
int userId = ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT));
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String query = "SELECT time,user,wid,x,y,z,action FROM " + ConfigHandler.prefix + "session WHERE user = '" + userId + "' AND time > '" + checkTime + "' ORDER BY rowid DESC";
|
||||
ResultSet results = statement.executeQuery(query);
|
||||
while (results.next()) {
|
||||
@ -60,7 +64,7 @@ public class SessionLookup {
|
||||
result.add(lookupData);
|
||||
}
|
||||
results.close();
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user