mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-09 04:02:10 +01:00
commit
9957cfe570
@ -121,6 +121,7 @@ public class MySQL implements DataSource {
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
config.addDataSourceProperty("autoReconnect", true);
|
||||
config.setMaxLifetime(12000);
|
||||
config.setInitializationFailFast(false);
|
||||
ds = new HikariDataSource(config);
|
||||
ConsoleLogger.info("Connection pool ready");
|
||||
@ -196,7 +197,7 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
return rs.next();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -246,7 +247,7 @@ public class MySQL implements DataSource {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return null;
|
||||
} finally {
|
||||
@ -456,7 +457,7 @@ public class MySQL implements DataSource {
|
||||
if (rs != null && !rs.isClosed())
|
||||
rs.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -501,7 +502,7 @@ public class MySQL implements DataSource {
|
||||
if (rs != null && !rs.isClosed())
|
||||
rs.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -523,7 +524,7 @@ public class MySQL implements DataSource {
|
||||
pst.setString(3, auth.getRealName());
|
||||
pst.setString(4, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -542,7 +543,7 @@ public class MySQL implements DataSource {
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
return pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return 0;
|
||||
} finally {
|
||||
@ -570,7 +571,7 @@ public class MySQL implements DataSource {
|
||||
pst.setLong(1, until);
|
||||
pst.executeUpdate();
|
||||
return list;
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
@ -606,7 +607,7 @@ public class MySQL implements DataSource {
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -629,7 +630,7 @@ public class MySQL implements DataSource {
|
||||
pst.setString(4, auth.getWorld());
|
||||
pst.setString(5, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -654,7 +655,7 @@ public class MySQL implements DataSource {
|
||||
countIp++;
|
||||
}
|
||||
return countIp;
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return 0;
|
||||
} finally {
|
||||
@ -674,7 +675,7 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, auth.getEmail());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -697,7 +698,7 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, auth.getSalt());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -732,7 +733,7 @@ public class MySQL implements DataSource {
|
||||
if (st != null) {
|
||||
try {
|
||||
st.close();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
@ -742,7 +743,7 @@ public class MySQL implements DataSource {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
@ -752,7 +753,7 @@ public class MySQL implements DataSource {
|
||||
if (con != null) {
|
||||
try {
|
||||
con.close();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
@ -773,7 +774,7 @@ public class MySQL implements DataSource {
|
||||
countIp.add(rs.getString(columnName));
|
||||
}
|
||||
return countIp;
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
@ -798,7 +799,7 @@ public class MySQL implements DataSource {
|
||||
countIp.add(rs.getString(columnName));
|
||||
}
|
||||
return countIp;
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
@ -823,7 +824,7 @@ public class MySQL implements DataSource {
|
||||
countEmail.add(rs.getString(columnName));
|
||||
}
|
||||
return countEmail;
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
@ -844,7 +845,7 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, name);
|
||||
pst.executeUpdate();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} finally {
|
||||
close(pst);
|
||||
@ -890,7 +891,7 @@ public class MySQL implements DataSource {
|
||||
while (con == null)
|
||||
try {
|
||||
con = ds.getConnection();
|
||||
} catch (SQLException e) {
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
reconnect(false);
|
||||
con = ds.getConnection();
|
||||
@ -914,6 +915,7 @@ public class MySQL implements DataSource {
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
config.addDataSourceProperty("autoReconnect", true);
|
||||
config.setInitializationFailFast(false);
|
||||
config.setMaxLifetime(12000);
|
||||
config.setPoolName("AuthMeMYSQLPool");
|
||||
ds = new HikariDataSource(config);
|
||||
if (!reload)
|
||||
@ -937,7 +939,7 @@ public class MySQL implements DataSource {
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next())
|
||||
return (rs.getInt(columnLogged) == 1);
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -958,7 +960,7 @@ public class MySQL implements DataSource {
|
||||
pst.setInt(1, 1);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -979,7 +981,7 @@ public class MySQL implements DataSource {
|
||||
pst.setInt(1, 0);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -999,7 +1001,7 @@ public class MySQL implements DataSource {
|
||||
pst.setInt(1, 0);
|
||||
pst.setInt(2, 1);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -1022,7 +1024,7 @@ public class MySQL implements DataSource {
|
||||
if (rs != null && rs.next()) {
|
||||
result = rs.getInt(1);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return result;
|
||||
} finally {
|
||||
@ -1042,7 +1044,7 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, newone);
|
||||
pst.setString(2, oldone);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -1092,7 +1094,7 @@ public class MySQL implements DataSource {
|
||||
if (pAuth != null)
|
||||
auths.add(pAuth);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} finally {
|
||||
@ -1143,7 +1145,7 @@ public class MySQL implements DataSource {
|
||||
if (pAuth != null)
|
||||
auths.add(pAuth);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} finally {
|
||||
|
@ -21,7 +21,7 @@ public class AsyncronousQuit {
|
||||
|
||||
protected AuthMe plugin;
|
||||
protected DataSource database;
|
||||
protected Player p;
|
||||
protected Player player;
|
||||
protected Utils utils = Utils.getInstance();
|
||||
private String name;
|
||||
private ItemStack[] armor = null;
|
||||
@ -33,7 +33,7 @@ public class AsyncronousQuit {
|
||||
|
||||
public AsyncronousQuit(Player p, AuthMe plugin, DataSource database,
|
||||
boolean isKick) {
|
||||
this.p = p;
|
||||
this.player = p;
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
this.name = p.getName().toLowerCase();
|
||||
@ -41,7 +41,8 @@ public class AsyncronousQuit {
|
||||
}
|
||||
|
||||
public void process() {
|
||||
final Player player = p;
|
||||
if (player == null)
|
||||
return;
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
@ -64,6 +65,7 @@ public class AsyncronousQuit {
|
||||
inv = limbo.getInventory();
|
||||
armor = limbo.getArmour();
|
||||
}
|
||||
if (limbo.getGroup() != null && !limbo.getGroup().equals(""))
|
||||
utils.addNormal(player, limbo.getGroup());
|
||||
needToChange = true;
|
||||
isOp = limbo.getOperator();
|
||||
@ -94,6 +96,7 @@ public class AsyncronousQuit {
|
||||
database.setUnlogged(name);
|
||||
}
|
||||
AuthMePlayerListener.gameMode.remove(name);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, inv, armor, isOp, isFlying, needToChange));
|
||||
final Player p = player;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, p, inv, armor, isOp, isFlying, needToChange));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user