Skip to content

Commit

Permalink
Update DatabaseManager.java
Browse files Browse the repository at this point in the history
  • Loading branch information
XXJNOTFOUND authored Dec 1, 2024
1 parent 24c709f commit 15b6c4b
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/main/java/com/ixiangpro/longtimenosee/DatabaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,14 @@ public void saveLogoutTime(String playerName, LocalDateTime time) {
}
}

public String getFirstLoginTime(String playerName) {
String query = "SELECT player_firstlogin FROM players WHERE player_name = ?";
try (PreparedStatement statement = connection.prepareStatement(query)) {
statement.setString(1, playerName);
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
return resultSet.getString("player_firstlogin");
}
} catch (SQLException e) {
plugin.getLogger().severe("查询首次登录时间失败:" + e.getMessage());
}
return null;
}

public String getLastLogoutTime(String playerName) {
public LocalDateTime getLastLogoutDateTime(String playerName) {
String query = "SELECT player_lastoffline FROM players WHERE player_name = ?";
try (PreparedStatement statement = connection.prepareStatement(query)) {
statement.setString(1, playerName);
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
return resultSet.getString("player_lastoffline");
String lastLogoutTime = resultSet.getString("player_lastoffline");
return LocalDateTime.parse(lastLogoutTime, DATE_FORMATTER);
}
} catch (SQLException e) {
plugin.getLogger().severe("查询下线时间失败:" + e.getMessage());
Expand Down

0 comments on commit 15b6c4b

Please sign in to comment.