mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-09 04:02:10 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0cc98a839c
69
pom.xml
69
pom.xml
@ -13,6 +13,11 @@
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/authme-reloaded/</url>
|
||||
<!-- See also: https://www.spigotmc.org/resources/authme-reloaded.6269/ -->
|
||||
|
||||
<organization>
|
||||
<name>AuthMe-Team</name>
|
||||
<url>https://github.com/AuthMe-Team</url>
|
||||
</organization>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/Xephi/AuthMeReloaded.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:Xephi/AuthMeReloaded.git</developerConnection>
|
||||
@ -56,6 +61,14 @@
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>./messages/</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/messages/</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -74,13 +87,12 @@
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.maxmind.geoip:*</include>
|
||||
<include>javax.mail:*</include>
|
||||
<include>com.sun.mail:*</include>
|
||||
<include>com.comphenix.attribute:*</include>
|
||||
<include>org.mcstats.*:*</include>
|
||||
<include>com.zaxxer:*</include>
|
||||
<include>org.slf4j:*</include>
|
||||
<include>com.zaxxer:HikariCP</include>
|
||||
<include>org.slf4j:slf4j-simple</include>
|
||||
<include>com.maxmind.geoip:geoip-api</include>
|
||||
<include>com.sun.mail:javax.mail</include>
|
||||
<include>com.comphenix.attribute:AttributeStorage</include>
|
||||
<include>org.mcstats.bukkit:metrics</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
@ -164,42 +176,27 @@
|
||||
<url>http://repo.mcstats.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<!-- sgdc3 HikariCP Log4J Repo -->
|
||||
<repository>
|
||||
<id>hikaricp-log4j-releases</id>
|
||||
<url>http://nexus-sgdc3.rhcloud.com/nexus/content/repositories/hikaricp-log4j-releases/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Maven Dependencies -->
|
||||
|
||||
<!-- MySql Connection Pool -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.36</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Database Connection Pool -->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- SQLite Library -->
|
||||
<!-- SQLite Connector -->
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
@ -207,7 +204,13 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Java Email API -->
|
||||
<!-- Java Email API and Implementation -->
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
<version>1.5.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
@ -557,9 +560,7 @@
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>simplechestlock</artifactId>
|
||||
<groupId>
|
||||
com.webkonsept.bukkit.simplechestlock
|
||||
</groupId>
|
||||
<groupId>com.webkonsept.bukkit.simplechestlock</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commandbook</artifactId>
|
||||
|
@ -10,6 +10,7 @@ import java.io.OutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
@ -34,6 +35,7 @@ import org.mcstats.Metrics;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.maxmind.geoip.LookupService;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.zaxxer.hikari.pool.PoolInitializationException;
|
||||
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.api.NewAPI;
|
||||
@ -214,7 +216,18 @@ public class AuthMe extends JavaPlugin {
|
||||
else ConsoleLogger.showError("Error while performing the backup!");
|
||||
}
|
||||
|
||||
try {
|
||||
setupDatabase();
|
||||
} catch (ClassNotFoundException nfe) {
|
||||
ConsoleLogger.showError("Fatal error occurred! Authme initialization ABORTED!");
|
||||
return;
|
||||
} catch (SQLException sqle) {
|
||||
ConsoleLogger.showError("Fatal error occurred! Authme initialization ABORTED!");
|
||||
return;
|
||||
} catch (PoolInitializationException pie) {
|
||||
ConsoleLogger.showError("Fatal error occurred! Authme initialization ABORTED!");
|
||||
return;
|
||||
}
|
||||
|
||||
dataManager = new DataManager(this);
|
||||
|
||||
@ -800,7 +813,7 @@ public class AuthMe extends JavaPlugin {
|
||||
return realIP;
|
||||
}
|
||||
|
||||
public void setupDatabase() {
|
||||
public void setupDatabase() throws ClassNotFoundException, PoolInitializationException, SQLException {
|
||||
/*
|
||||
* Backend MYSQL - FILE - SQLITE
|
||||
*/
|
||||
|
@ -134,11 +134,14 @@ public class DataManager {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} else {
|
||||
try {
|
||||
playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + Bukkit.getOfflinePlayer(name).getUniqueId() + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception e) { // Don't do nothing if the method getUniqueId() isn't avariable ( MC version < 1.7.5 )
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
@ -505,8 +505,12 @@ public class FileCache {
|
||||
else armours[i] = item;
|
||||
}
|
||||
} catch (final RuntimeException e) {
|
||||
//verbose
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
||||
} catch (final Exception e) {
|
||||
//verbose
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
||||
} finally {
|
||||
if (reader != null)
|
||||
@ -515,9 +519,13 @@ public class FileCache {
|
||||
return new DataFileCache(inv, armours, group, op, flying);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
// Verbose
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
// Verbose
|
||||
e.printStackTrace();
|
||||
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
||||
return null;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -22,6 +23,8 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.zaxxer.hikari.pool.PoolInitializationException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
@ -143,7 +146,38 @@ public class AdminCommand implements CommandExecutor {
|
||||
Settings.reloadConfigOptions(newConfig);
|
||||
m.reloadMessages();
|
||||
plugin.database.close();
|
||||
|
||||
try {
|
||||
plugin.setupDatabase();
|
||||
} catch (ClassNotFoundException nfe) {
|
||||
ConsoleLogger.showError("Fatal error occurred! Authme instance ABORTED!");
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
return false;
|
||||
} catch (SQLException sqle) {
|
||||
ConsoleLogger.showError("Fatal error occurred! Authme instance ABORTED!");
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
return false;
|
||||
} catch (PoolInitializationException pie) {
|
||||
ConsoleLogger.showError("Fatal error occurred! Authme instance ABORTED!");
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m.send(sender, "reload");
|
||||
} else if (args[0].equalsIgnoreCase("lastlogin")) {
|
||||
if (args.length != 2) {
|
||||
|
@ -8,7 +8,6 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
@ -45,7 +44,7 @@ public class MySQL implements DataSource {
|
||||
private HikariDataSource ds;
|
||||
private String columnRealName;
|
||||
|
||||
public MySQL() {
|
||||
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
|
||||
this.host = Settings.getMySQLHost;
|
||||
this.port = Settings.getMySQLPort;
|
||||
this.username = Settings.getMySQLUsername;
|
||||
@ -67,73 +66,112 @@ public class MySQL implements DataSource {
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
this.columnLogged = Settings.getMySQLColumnLogged;
|
||||
this.columnRealName = Settings.getMySQLColumnRealName;
|
||||
|
||||
// Set the connection arguments (and check if connection is ok)
|
||||
try {
|
||||
this.connect();
|
||||
this.setup();
|
||||
} catch (ClassNotFoundException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
this.setConnectionArguments();
|
||||
} catch (ClassNotFoundException ne) {
|
||||
ConsoleLogger.showError(ne.getMessage());
|
||||
ConsoleLogger.showError("Can't use the Hikari Connection Pool! Please, report this error to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
return;
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
throw new ClassNotFoundException(ne.getMessage());
|
||||
} catch (IllegalArgumentException ae) { // This means that there are problems with the hikaricp pool arguments!
|
||||
ConsoleLogger.showError(ae.getMessage());
|
||||
ConsoleLogger.showError("Invalid database arguments! Please check your configuration!");
|
||||
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
throw new IllegalArgumentException(ae);
|
||||
} catch (PoolInitializationException ie) { // Can't initialize the connection pool!
|
||||
ConsoleLogger.showError(ie.getMessage());
|
||||
ConsoleLogger.showError("Can't connect to the MySql database! Please check your configuration!");
|
||||
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
throw new PoolInitializationException(ie);
|
||||
}
|
||||
|
||||
// Initialize the database
|
||||
try {
|
||||
this.setupConnection();
|
||||
} catch (SQLException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
ConsoleLogger.showError("Can't initialize the MySQL database... Please check your database settings in the config.yml file! SHUTDOWN...");
|
||||
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
return;
|
||||
} catch (TimeoutException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
return;
|
||||
} catch (PoolInitializationException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
return;
|
||||
throw new SQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void connect()
|
||||
throws ClassNotFoundException, SQLException, TimeoutException,
|
||||
NumberFormatException, PoolInitializationException {
|
||||
private synchronized void setConnectionArguments()
|
||||
throws ClassNotFoundException, IllegalArgumentException {
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setDriverClassName("com.mysql.jdbc.Driver");
|
||||
config.setPoolName("AuthMeMYSQLPool");
|
||||
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
|
||||
config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
||||
config.setUsername(this.username);
|
||||
config.setPassword(this.password);
|
||||
config.setPoolName("AuthMeMYSQLPool");
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
config.addDataSourceProperty("autoReconnect", true);
|
||||
config.setMaxLifetime(30000);
|
||||
config.setInitializationFailFast(false);
|
||||
config.addDataSourceProperty("autoReconnect", false);
|
||||
config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
|
||||
config.setMaxLifetime(180000); // 3 Min
|
||||
config.setIdleTimeout(60000); // 1 Min
|
||||
config.setMaximumPoolSize(50); // 50 (including idle connections)
|
||||
ds = new HikariDataSource(config);
|
||||
ConsoleLogger.info("Connection pool ready");
|
||||
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
|
||||
}
|
||||
|
||||
private synchronized void setup() throws SQLException {
|
||||
private synchronized void reloadArguments()
|
||||
throws ClassNotFoundException, IllegalArgumentException {
|
||||
if (ds != null){
|
||||
ds.close();
|
||||
}
|
||||
setConnectionArguments();
|
||||
ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!");
|
||||
}
|
||||
|
||||
private synchronized Connection getConnection() {
|
||||
Connection con = null;
|
||||
while(con == null){
|
||||
try {
|
||||
con = ds.getConnection();
|
||||
} catch (SQLException ce) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
private synchronized void setupConnection() throws SQLException {
|
||||
Connection con = null;
|
||||
Statement st = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
st = con.createStatement();
|
||||
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1'," + columnLastLogin + " BIGINT NOT NULL DEFAULT '" + System.currentTimeMillis() + "'," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT '" + Settings.defaultWorld + "'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged + " SMALLINT NOT NULL DEFAULT '0'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
@ -185,6 +223,7 @@ public class MySQL implements DataSource {
|
||||
close(st);
|
||||
close(con);
|
||||
}
|
||||
ConsoleLogger.info("MySQL Setup finished");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -193,7 +232,7 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
@ -217,7 +256,7 @@ public class MySQL implements DataSource {
|
||||
PlayerAuth pAuth = null;
|
||||
int id = -1;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
@ -264,7 +303,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnRealName + ") VALUES (?,?,?,?,?);");
|
||||
pst.setString(1, auth.getNickname());
|
||||
@ -473,7 +512,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, auth.getHash());
|
||||
pst.setString(2, auth.getNickname());
|
||||
@ -518,7 +557,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=?, " + columnRealName + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, auth.getIp());
|
||||
pst.setLong(2, auth.getLastLogin());
|
||||
@ -540,7 +579,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
return pst.executeUpdate();
|
||||
@ -560,7 +599,7 @@ public class MySQL implements DataSource {
|
||||
ResultSet rs = null;
|
||||
List<String> list = new ArrayList<String>();
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
rs = pst.executeQuery();
|
||||
@ -587,7 +626,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
||||
int id;
|
||||
ResultSet rs = null;
|
||||
@ -623,7 +662,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + " =?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setDouble(1, auth.getQuitLocX());
|
||||
pst.setDouble(2, auth.getQuitLocY());
|
||||
@ -648,7 +687,7 @@ public class MySQL implements DataSource {
|
||||
ResultSet rs = null;
|
||||
int countIp = 0;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
||||
pst.setString(1, ip);
|
||||
rs = pst.executeQuery();
|
||||
@ -671,7 +710,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + " =? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, auth.getEmail());
|
||||
pst.setString(2, auth.getNickname());
|
||||
@ -694,7 +733,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + " =? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, auth.getSalt());
|
||||
pst.setString(2, auth.getNickname());
|
||||
@ -709,6 +748,21 @@ public class MySQL implements DataSource {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
try {
|
||||
reloadArguments();
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
try {
|
||||
@ -718,21 +772,6 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
try {
|
||||
reconnect(true);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
private void close(Statement st) {
|
||||
if (st != null) {
|
||||
try {
|
||||
@ -770,7 +809,7 @@ public class MySQL implements DataSource {
|
||||
ResultSet rs = null;
|
||||
List<String> countIp = new ArrayList<String>();
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
||||
pst.setString(1, auth.getIp());
|
||||
rs = pst.executeQuery();
|
||||
@ -795,7 +834,7 @@ public class MySQL implements DataSource {
|
||||
ResultSet rs = null;
|
||||
List<String> countIp = new ArrayList<String>();
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
|
||||
pst.setString(1, ip);
|
||||
rs = pst.executeQuery();
|
||||
@ -820,7 +859,7 @@ public class MySQL implements DataSource {
|
||||
ResultSet rs = null;
|
||||
List<String> countEmail = new ArrayList<String>();
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
|
||||
pst.setString(1, email);
|
||||
rs = pst.executeQuery();
|
||||
@ -844,7 +883,7 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
for (String name : banned) {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, name);
|
||||
pst.executeUpdate();
|
||||
@ -857,75 +896,6 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized Connection makeSureConnectionIsReady() {
|
||||
Connection con = null;
|
||||
try {
|
||||
con = ds.getConnection();
|
||||
} catch (Exception te) {
|
||||
try {
|
||||
con = null;
|
||||
reconnect(false);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
} catch (AssertionError ae) {
|
||||
// Make sure assertionerror is caused by the connectionpoolmanager,
|
||||
// else re-throw it
|
||||
if (!ae.getMessage().equalsIgnoreCase("AuthMeDatabaseError"))
|
||||
throw new AssertionError(ae.getMessage());
|
||||
try {
|
||||
con = null;
|
||||
reconnect(false);
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
}
|
||||
while (con == null)
|
||||
try {
|
||||
con = ds.getConnection();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
reconnect(false);
|
||||
con = ds.getConnection();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
private synchronized void reconnect(boolean reload)
|
||||
throws ClassNotFoundException, SQLException, TimeoutException,
|
||||
PoolInitializationException {
|
||||
if (ds != null)
|
||||
ds.close();
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
||||
config.setUsername(this.username);
|
||||
config.setPassword(this.password);
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
config.addDataSourceProperty("autoReconnect", true);
|
||||
config.setInitializationFailFast(false);
|
||||
config.setMaxLifetime(12000);
|
||||
config.setPoolName("AuthMeMYSQLPool");
|
||||
ds = new HikariDataSource(config);
|
||||
if (!reload)
|
||||
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.MYSQL;
|
||||
@ -937,7 +907,7 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
@ -959,7 +929,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setInt(1, 1);
|
||||
pst.setString(2, user);
|
||||
@ -980,7 +950,7 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
if (user != null)
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setString(2, user);
|
||||
@ -1000,7 +970,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setInt(2, 1);
|
||||
@ -1022,7 +992,7 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT COUNT(*) FROM " + tableName + ";");
|
||||
rs = pst.executeQuery();
|
||||
if (rs != null && rs.next()) {
|
||||
@ -1043,7 +1013,7 @@ public class MySQL implements DataSource {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnName + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setString(1, newone);
|
||||
pst.setString(2, oldone);
|
||||
@ -1065,7 +1035,7 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + ";");
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
@ -1116,7 +1086,7 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLogged + "=1;");
|
||||
rs = pst.executeQuery();
|
||||
while (rs.next()) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@ -8,10 +7,10 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import com.zaxxer.hikari.pool.PoolInitializationException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
@ -38,7 +37,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
private String columnLogged;
|
||||
private String columnRealName;
|
||||
|
||||
public SQLite_HIKARI() {
|
||||
public SQLite_HIKARI() throws ClassNotFoundException, SQLException, PoolInitializationException {
|
||||
this.database = Settings.getMySQLDatabase;
|
||||
this.tableName = Settings.getMySQLTablename;
|
||||
this.columnName = Settings.getMySQLColumnName;
|
||||
@ -56,65 +55,127 @@ public class SQLite_HIKARI implements DataSource {
|
||||
this.columnLogged = Settings.getMySQLColumnLogged;
|
||||
this.columnRealName = Settings.getMySQLColumnRealName;
|
||||
|
||||
// Set the connection arguments (and check if connection is ok)
|
||||
try {
|
||||
this.connect();
|
||||
this.setup();
|
||||
} catch (ClassNotFoundException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
this.setConnectionArguments();
|
||||
} catch (ClassNotFoundException ne) {
|
||||
ConsoleLogger.showError(ne.getMessage());
|
||||
ConsoleLogger.showError("Can't use the Hikari Connection Pool! Please, report this error to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
return;
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
throw new ClassNotFoundException(ne.getMessage());
|
||||
} catch (IllegalArgumentException ae) { // This means that there are problems with the hikaricp pool arguments!
|
||||
ConsoleLogger.showError(ae.getMessage());
|
||||
ConsoleLogger.showError("Invalid database arguments! Please check your configuration!");
|
||||
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
throw new IllegalArgumentException(ae);
|
||||
} catch (PoolInitializationException ie) { // Can't initialize the connection pool!
|
||||
ConsoleLogger.showError(ie.getMessage());
|
||||
ConsoleLogger.showError("Can't connect to the SQLite database! Please check your configuration!");
|
||||
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
throw new PoolInitializationException(ie);
|
||||
}
|
||||
|
||||
// Initialize the database
|
||||
try {
|
||||
this.setupConnection();
|
||||
} catch (SQLException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
ConsoleLogger.showError("Can't initialize the MySQL database... Please check your database settings in the config.yml file! SHUTDOWN...");
|
||||
ConsoleLogger.showError("If this error persists, please report it to the developer! SHUTDOWN...");
|
||||
this.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
return;
|
||||
} catch (EOFException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
return;
|
||||
}
|
||||
throw new SQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Connection getConnection() throws SQLException, EOFException {
|
||||
return this.ds.getConnection();
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.SQLITE;
|
||||
}
|
||||
|
||||
private synchronized void connect()
|
||||
throws ClassNotFoundException, SQLException, EOFException {
|
||||
/*
|
||||
* Class.forName("org.sqlite.JDBC"); ConsoleLogger.info(
|
||||
* "SQLite driver loaded"); this.con =
|
||||
* DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database
|
||||
* + ".db");
|
||||
*/
|
||||
Properties props = new Properties();
|
||||
props.setProperty("dataSourceClassName", "org.sqlite.SQLiteDataSource");
|
||||
HikariConfig config = new HikariConfig(props);
|
||||
config.setPoolName("AuthMeSQLiteLPool");
|
||||
private synchronized void setConnectionArguments()
|
||||
throws ClassNotFoundException, IllegalArgumentException {
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setPoolName("AuthMeSQLitePool");
|
||||
config.setDataSourceClassName("org.sqlite.SQLiteDataSource");
|
||||
config.setJdbcUrl("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
|
||||
config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
|
||||
config.setConnectionTestQuery("SELECT 1");
|
||||
config.setMaxLifetime(180000); // 3 Min
|
||||
config.setIdleTimeout(60000); // 1 Min
|
||||
config.setMaximumPoolSize(50); // 50 (including idle connections)
|
||||
ds = new HikariDataSource(config);
|
||||
ConsoleLogger.info("Connection pool ready");
|
||||
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
|
||||
}
|
||||
|
||||
private synchronized void setup() throws SQLException, EOFException {
|
||||
private synchronized Connection getRawConnection() {
|
||||
Connection con = null;
|
||||
while(con == null){
|
||||
try {
|
||||
con = ds.getConnection();
|
||||
} catch (SQLException ce) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
private synchronized Connection getConnection() {
|
||||
Connection con;
|
||||
con = getRawConnection();
|
||||
if(con == null){
|
||||
ds.close();
|
||||
ConsoleLogger.showError("Database connection is LOST! SHUTDOWN...");
|
||||
if (Settings.isStopEnabled) {
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
private synchronized void setupConnection() throws SQLException {
|
||||
Connection con = null;
|
||||
Statement st = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
con = getRawConnection();
|
||||
if(con == null){
|
||||
ds.close();
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't connect to the SQLite database... Please check your database settings in the config.yml file! SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
} else {
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
return;
|
||||
}
|
||||
st = con.createStatement();
|
||||
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT '" + Settings.defaultWorld + "'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
@ -166,14 +227,6 @@ public class SQLite_HIKARI implements DataSource {
|
||||
ConsoleLogger.info("SQLite Setup finished");
|
||||
}
|
||||
|
||||
private void close(Connection con) {
|
||||
try {
|
||||
if (con != null)
|
||||
con.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
Connection con = null;
|
||||
@ -185,7 +238,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
return rs.next();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -218,7 +271,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return null;
|
||||
} finally {
|
||||
@ -230,8 +283,8 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
|
||||
@ -252,7 +305,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setString(6, auth.getRealName());
|
||||
pst.executeUpdate();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -272,7 +325,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setString(1, auth.getHash());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -294,7 +347,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setString(3, auth.getRealName());
|
||||
pst.setString(4, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -313,7 +366,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
return pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return 0;
|
||||
} finally {
|
||||
@ -337,7 +390,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
list.add(rs.getString(columnName));
|
||||
}
|
||||
return list;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
@ -349,14 +402,14 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
|
||||
pst.setString(1, user);
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -368,8 +421,8 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + "=?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
|
||||
@ -379,7 +432,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setString(4, auth.getWorld());
|
||||
pst.setString(5, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -391,9 +444,9 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
int countIp = 0;
|
||||
try {
|
||||
con = getConnection();
|
||||
@ -404,7 +457,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
countIp++;
|
||||
}
|
||||
return countIp;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return 0;
|
||||
} finally {
|
||||
@ -416,15 +469,15 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getEmail());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -447,7 +500,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setString(1, auth.getSalt());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -457,56 +510,11 @@ public class SQLite_HIKARI implements DataSource {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
try {
|
||||
if (ds != null)
|
||||
ds.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
try {
|
||||
connect();
|
||||
setup();
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't reconnect to SQLite database... SHUTDOWN...");
|
||||
AuthMe.getInstance().getServer().shutdown();
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
private void close(Statement st) {
|
||||
if (st != null) {
|
||||
try {
|
||||
st.close();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void close(ResultSet rs) {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
List<String> countIp = new ArrayList<String>();
|
||||
try {
|
||||
con = getConnection();
|
||||
@ -517,11 +525,11 @@ public class SQLite_HIKARI implements DataSource {
|
||||
countIp.add(rs.getString(columnName));
|
||||
}
|
||||
return countIp;
|
||||
} catch (NullPointerException ex) {
|
||||
return new ArrayList<String>();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} catch (NullPointerException npe) {
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
@ -531,9 +539,9 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
List<String> countIp = new ArrayList<String>();
|
||||
try {
|
||||
con = getConnection();
|
||||
@ -544,11 +552,11 @@ public class SQLite_HIKARI implements DataSource {
|
||||
countIp.add(rs.getString(columnName));
|
||||
}
|
||||
return countIp;
|
||||
} catch (NullPointerException ex) {
|
||||
return new ArrayList<String>();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} catch (NullPointerException npe) {
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
@ -558,9 +566,9 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
List<String> countEmail = new ArrayList<String>();
|
||||
try {
|
||||
con = getConnection();
|
||||
@ -571,11 +579,11 @@ public class SQLite_HIKARI implements DataSource {
|
||||
countEmail.add(rs.getString(columnName));
|
||||
}
|
||||
return countEmail;
|
||||
} catch (NullPointerException ex) {
|
||||
return new ArrayList<String>();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return new ArrayList<String>();
|
||||
} catch (NullPointerException npe) {
|
||||
return new ArrayList<String>();
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
@ -585,8 +593,8 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
for (String name : banned) {
|
||||
@ -594,7 +602,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setString(1, name);
|
||||
pst.executeUpdate();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} finally {
|
||||
close(pst);
|
||||
@ -602,16 +610,11 @@ public class SQLite_HIKARI implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.SQLITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
|
||||
@ -619,7 +622,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next())
|
||||
return (rs.getInt(columnLogged) == 1);
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
@ -632,15 +635,15 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
|
||||
pst.setInt(1, 1);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -652,8 +655,8 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
if (user != null)
|
||||
try {
|
||||
con = getConnection();
|
||||
@ -661,7 +664,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
pst.setInt(1, 0);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -673,15 +676,15 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setInt(2, 1);
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -693,10 +696,10 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
int result = 0;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
int result = 0;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT COUNT(*) FROM " + tableName + ";");
|
||||
@ -704,7 +707,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
if (rs != null && rs.next()) {
|
||||
result = rs.getInt(1);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return result;
|
||||
} finally {
|
||||
@ -716,15 +719,15 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
PreparedStatement pst = null;
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnName + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, newone);
|
||||
pst.setString(2, oldone);
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
@ -736,10 +739,10 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<PlayerAuth>();
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
List<PlayerAuth> auths = new ArrayList<PlayerAuth>();
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + ";");
|
||||
@ -758,7 +761,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
if (pAuth != null)
|
||||
auths.add(pAuth);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} finally {
|
||||
@ -770,10 +773,10 @@ public class SQLite_HIKARI implements DataSource {
|
||||
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
List<PlayerAuth> auths = new ArrayList<PlayerAuth>();
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
List<PlayerAuth> auths = new ArrayList<PlayerAuth>();
|
||||
try {
|
||||
con = getConnection();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLogged + "=1;");
|
||||
@ -792,7 +795,7 @@ public class SQLite_HIKARI implements DataSource {
|
||||
if (pAuth != null)
|
||||
auths.add(pAuth);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return auths;
|
||||
} finally {
|
||||
@ -801,4 +804,47 @@ public class SQLite_HIKARI implements DataSource {
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
try {
|
||||
if (ds != null)
|
||||
ds.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void close(Statement st) {
|
||||
if (st != null) {
|
||||
try {
|
||||
st.close();
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void close(ResultSet rs) {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void close(Connection con) {
|
||||
if (con != null) {
|
||||
try {
|
||||
con.close();
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +48,11 @@ public class ModuleManager implements Module {
|
||||
@Override
|
||||
public boolean load() {
|
||||
File dir = new File(plugin.getDataFolder() + File.separator + "modules");
|
||||
if (dir == null || !dir.exists() || !dir.isDirectory() || dir.listFiles() == null || dir.listFiles().length <= 0)
|
||||
String[] files = dir.list();
|
||||
if (files == null || files.length == 0){
|
||||
return false;
|
||||
for (File pathToJar : dir.listFiles()) {
|
||||
}
|
||||
for (File pathToJar : dir.listFiles()) { // FindBugs: "possible null pointers" O_o ?
|
||||
JarFile jarFile = null;
|
||||
try {
|
||||
jarFile = new JarFile(pathToJar);
|
||||
|
@ -1,12 +1,9 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
|
||||
public class Messages extends CustomConfiguration {
|
||||
@ -29,13 +26,11 @@ public class Messages extends CustomConfiguration {
|
||||
* @param filename
|
||||
* The filename to open
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public final void loadDefaults(File file) {
|
||||
InputStream stream = AuthMe.getInstance().getResource(file.getName());
|
||||
if (stream == null)
|
||||
if(file.isFile()){
|
||||
setDefaults(YamlConfiguration.loadConfiguration(file));
|
||||
}
|
||||
return;
|
||||
|
||||
setDefaults(YamlConfiguration.loadConfiguration(stream));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ public final class Settings extends YamlConfiguration {
|
||||
public static String PLUGIN_FOLDER = "." + File.separator + "plugins" + File.separator + "AuthMe";
|
||||
public static final String CACHE_FOLDER = Settings.PLUGIN_FOLDER + File.separator + "cache";
|
||||
public static final String AUTH_FILE = Settings.PLUGIN_FOLDER + File.separator + "auths.db";
|
||||
public static final String MESSAGE_FILE = Settings.PLUGIN_FOLDER + File.separator + "messages";
|
||||
public static final String MESSAGE_FILE = Settings.PLUGIN_FOLDER + File.separator + "messages" + File.separator + "messages";
|
||||
public static final String SETTINGS_FILE = Settings.PLUGIN_FOLDER + File.separator + "config.yml";
|
||||
public static List<String> allowCommands = null;
|
||||
public static List<String> getJoinPermissions = null;
|
||||
|
Loading…
Reference in New Issue
Block a user