Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
private final Fraud fraud;
private final Configuration.DatabaseSection.Type type;

private final long cacheRefreshInterval = 60000; // Intervalle de rafraîchissement du cache en millisecondes (par exemple, 1 minute)

Check warning on line 54 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Field can be local

Field can be converted to a local variable
private long lastCacheRefreshTime = System.currentTimeMillis();
private final Map<String, List<String>> cache = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -138,7 +138,7 @@
}
}
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 141 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
}

Expand All @@ -149,7 +149,7 @@
* @throws ClassNotFoundException if the driver is not found.
*/
public Connection connect() throws SQLException, ClassNotFoundException {
/*

Check notice on line 152 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Commented out code

Commented out code (19 lines)

//Old system without pool connection

Expand Down Expand Up @@ -180,11 +180,11 @@
try {
putPlayer(p, connection);
} catch (SQLException e) {
e.printStackTrace();

Check warning on line 183 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
});
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 187 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
}

Expand Down Expand Up @@ -244,7 +244,7 @@
try (Connection connection = connect()) {
putPlayer(p, connection);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 247 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
}

Expand All @@ -252,14 +252,22 @@

public void forgotPlayer(String name) {
String ip = getIP(name);
cache.get(ip).remove(name);
if (ip != null) {
List<String> cached = cache.get(ip);
if (cached != null) {
cached.remove(name);
if (cached.isEmpty()) {
cache.remove(ip);
}
}
}
String sql = MessageFormat.format("DELETE FROM `{0}` WHERE pseudo = ?", TABLE_NAME.ips.getName());
try(Connection connection = connect();
PreparedStatement psst = connection.prepareStatement(sql)) {
psst.setString(1, name);
psst.executeUpdate();
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 270 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
}

Expand All @@ -273,7 +281,7 @@
return rs.getLong("first");
}
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 284 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
return 0;
}
Expand All @@ -288,7 +296,7 @@
return rs.getLong("last");
}
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 299 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
return 0;
}
Expand Down Expand Up @@ -337,7 +345,7 @@
if(!rs.next()) return false;
return rs.getString("pseudo").equals(name);
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 348 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
return false;
}
Expand All @@ -358,7 +366,7 @@
return rs.getString("ip");
}
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 369 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
System.err.println("Error while getting the ip of " + name + " in the database.");
return null;
Expand All @@ -380,7 +388,7 @@
}
return getList(ipFromPseudo);
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 391 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
return Lists.newArrayList();
}
Expand Down Expand Up @@ -434,7 +442,7 @@
cache.put(address, pseudos);
return pseudos;
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();

Check warning on line 445 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Call to 'printStackTrace()'

Call to `printStackTrace()` should probably be replaced with more robust logging
}
return new ArrayList<>();
}
Expand Down Expand Up @@ -492,7 +500,7 @@
output.put(Utils.getAddress(p.getAddress()), Lists.newArrayList());
}
for(String alt: alts) {
output.get(Utils.getAddress(p.getAddress())).add(Bukkit.getOfflinePlayer(alt));

Check warning on line 503 in src/main/java/fr/Rgld_/Fraud/Spigot/Storage/Data.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Deprecated API usage

'getOfflinePlayer(java.lang.String)' is deprecated
}
}
}
Expand Down
Loading