diff --git a/pom.xml b/pom.xml
index c5f2e8f62..e02a3baeb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,571 +1,576 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- fr.xephi
- authme
- 5.0-SNAPSHOT
+ fr.xephi
+ authme
+ 5.0-SNAPSHOT
- AuthMeReloaded
- Authentication plugin for CraftBukkit/Spigot!
- 2013
- http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
-
+ AuthMeReloaded
+ Authentication plugin for CraftBukkit/Spigot!
+ 2013
+ http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
+
-
- scm:git:https://github.com/Xephi/AuthMeReloaded.git
- scm:git:git@github.com:Xephi/AuthMeReloaded.git
- http://github.com/Xephi/AuthMeReloaded
-
+
+ scm:git:https://github.com/Xephi/AuthMeReloaded.git
+ scm:git:git@github.com:Xephi/AuthMeReloaded.git
+ http://github.com/Xephi/AuthMeReloaded
+
-
-
- jenkins
- http://ci.xephi.fr/job/AuthMeReloaded/
-
+
+
+ jenkins
+ http://ci.xephi.fr/job/AuthMeReloaded/
+
-
- GitHub
- https://github.com/Xephi/AuthMeReloaded/issues
-
+
+ GitHub
+ https://github.com/Xephi/AuthMeReloaded/issues
+
-
-
- The GNU General Public Licence version 3 (GPLv3)
- http://www.gnu.org/licenses/gpl-3.0.html
-
-
+
+
+ The GNU General Public Licence version 3 (GPLv3)
+ http://www.gnu.org/licenses/gpl-3.0.html
+
+
-
- UTF-8
-
- 1.7
-
- 1.8.8-R0.1-SNAPSHOT
-
+
+ UTF-8
+
+ 1.7
+
+ 1.8.8-R0.1-SNAPSHOT
+
-
- AuthMe-${project.version}
-
-
- .
- true
- ${basedir}/src/main/resources/
-
- *.yml
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.3
-
-
- ${javaVersion}
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.4.1
-
-
-
- com.maxmind.geoip:*
- javax.mail:*
- com.sun.mail:*
- com.comphenix.attribute:*
- org.mcstats.*:*
- com.zaxxer:*
- org.slf4j:*
-
-
-
-
- org.mcstats
- fr.xephi.authme
-
-
-
-
-
- package
-
- shade
-
-
-
-
-
-
+
+ AuthMe-${project.version}
+
+
+ .
+ true
+ ${basedir}/src/main/resources/
+
+ *.yml
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.3
+
+
+ ${javaVersion}
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.1
+
+
+
+ com.maxmind.geoip:*
+ javax.mail:*
+ com.sun.mail:*
+ com.comphenix.attribute:*
+ org.mcstats.*:*
+ com.zaxxer:*
+ org.slf4j:*
+
+
+
+
+ org.mcstats
+ fr.xephi.authme
+
+
+
+
+
+ package
+
+ shade
+
+
+
+
+
+
-
+
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/groups/public
-
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/groups/public
+
-
-
- ess-repo
- https://ci.drtshock.net/plugin/repository/everything
-
+
+
+ ess-repo
+ https://ci.drtshock.net/plugin/repository/everything
+
-
-
- citizensapi-repo
- http://ci.citizensnpcs.co/plugin/repository/project/CitizensAPI/LastSuccessful/repository
-
+
+
+ citizensapi-repo
+ http://ci.citizensnpcs.co/plugin/repository/project/CitizensAPI/LastSuccessful/repository
+
-
-
- minelink-thirdparty
- http://repo.minelink.net/content/repositories/public
-
+
+
+ minelink-thirdparty
+ http://repo.minelink.net/content/repositories/public
+
-
-
- comphenix-snapshots
- http://repo.comphenix.net/content/repositories/public
-
+
+
+ comphenix-snapshots
+ http://repo.comphenix.net/content/repositories/public
+
-
-
- onarandombox
- http://repo.onarandombox.com/content/groups/public
-
+
+
+ onarandombox
+ http://repo.onarandombox.com/content/groups/public
+
-
-
- vault-repo
- http://nexus.theyeticave.net/content/repositories/pub_releases
-
+
+
+ vault-repo
+ http://nexus.theyeticave.net/content/repositories/pub_releases
+
-
-
- luricos-releases
- http://repo.luricos.de/content/repositories/releases
-
+
+
+ luricos-releases
+ http://repo.luricos.de/content/repositories/releases
+
-
-
- xephi-repo
- http://ci.xephi.fr/plugin/repository/everything/
-
+
+
+ xephi-repo
+ http://ci.xephi.fr/plugin/repository/everything/
+
-
-
- mcstats-snapshots
- http://repo.mcstats.org/content/repositories/snapshots/
-
+
+
+ mcstats-snapshots
+ http://repo.mcstats.org/content/repositories/snapshots/
+
-
+
-
+
-
+
-
-
- org.slf4j
- slf4j-simple
- 1.7.12
- compile
-
-
- com.zaxxer
- HikariCP
- 2.4.1
- compile
-
-
- org.slf4j
- slf4j-api
-
-
- org.slf4j
- slf4j-simple
-
-
-
+
+
+ mysql
+ mysql-connector-java
+ 5.1.36
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.12
+ compile
+
+
+ com.zaxxer
+ HikariCP
+ 2.4.1
+ compile
+
+
+ org.slf4j
+ slf4j-api
+
+
+ org.slf4j
+ slf4j-simple
+
+
+
-
-
- org.xerial
- sqlite-jdbc
- 3.8.11.1
- compile
-
+
+
+ org.xerial
+ sqlite-jdbc
+ 3.8.11.1
+ compile
+
-
-
- com.sun.mail
- javax.mail
- 1.5.4
- compile
-
+
+
+ com.sun.mail
+ javax.mail
+ 1.5.4
+ compile
+
-
-
- com.maxmind.geoip
- geoip-api
- 1.2.15
- compile
-
+
+
+ com.maxmind.geoip
+ geoip-api
+ 1.2.15
+ compile
+
-
-
- org.mcstats.bukkit
- metrics
- R8-SNAPSHOT
- compile
-
-
- org.bukkit
- bukkit
-
-
-
+
+
+ org.mcstats.bukkit
+ metrics
+ R8-SNAPSHOT
+ compile
+
+
+ org.bukkit
+ bukkit
+
+
+
-
-
- org.bukkit
- bukkit
- ${bukkitVersion}
- provided
-
+
+
+ org.bukkit
+ bukkit
+ ${bukkitVersion}
+ provided
+
-
-
- com.comphenix.attribute
- AttributeStorage
- 0.0.2-SNAPSHOT
- compile
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
-
+
+
+ com.comphenix.attribute
+ AttributeStorage
+ 0.0.2-SNAPSHOT
+ compile
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+
-
-
- net.milkbowl.vault
- VaultAPI
- 1.5
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
-
+
+
+ net.milkbowl.vault
+ VaultAPI
+ 1.5
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+
-
-
- net.citizensnpcs
- citizensapi
- 2.0.16-SNAPSHOT
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
-
+
+
+ net.citizensnpcs
+ citizensapi
+ 2.0.16-SNAPSHOT
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+
-
-
- com.onarandombox.multiversecore
- Multiverse-Core
- 2.5
- jar
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- AllPay
- com.fernferret.allpay
-
-
- Vault
- net.milkbowl.vault
-
-
- CommandHandler
- com.pneumaticraft.commandhandler
-
-
-
+
+
+ com.onarandombox.multiversecore
+ Multiverse-Core
+ 2.5
+ jar
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ AllPay
+ com.fernferret.allpay
+
+
+ Vault
+ net.milkbowl.vault
+
+
+ CommandHandler
+ com.pneumaticraft.commandhandler
+
+
+
-
-
- net.ess3
- EssentialsX
- 2.0.1-SNAPSHOT
- provided
-
-
- org.spigotmc
- spigot-api
-
-
-
+
+
+ net.ess3
+ EssentialsX
+ 2.0.1-SNAPSHOT
+ provided
+
+
+ org.spigotmc
+ spigot-api
+
+
+
-
-
- net.minelink
- CombatTagPlus
- 1.2.1-SNAPSHOT
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- CombatTagPlusHook
- net.minelink
-
-
- CombatTagPlusFactions-v1_6
- net.minelink
-
-
- CombatTagPlusCompat-v1_7_R3
- net.minelink
-
-
- CombatTagPlusFactions-v1_8
- net.minelink
-
-
- CombatTagPlusCompat-v1_7_R4
- net.minelink
-
-
- CombatTagPlusWG-v5
- net.minelink
-
-
- CombatTagPlusWG-v6
- net.minelink
-
-
- CombatTagPlusCompat-API
- net.minelink
-
-
- CombatTagPlusFactions-v2_6
- net.minelink
-
-
- CombatTagPlusCompat-v1_8_R3
- net.minelink
-
-
- CombatTagPlusFactions-v2_7
- net.minelink
-
-
- CombatTagPlusCompat-v1_8_R2
- net.minelink
-
-
- CombatTagPlusCompat-v1_8_R1
- net.minelink
-
-
- metrics-lite
- org.mcstats.bukkit
-
-
-
+
+
+ net.minelink
+ CombatTagPlus
+ 1.2.1-SNAPSHOT
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ CombatTagPlusHook
+ net.minelink
+
+
+ CombatTagPlusFactions-v1_6
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_7_R3
+ net.minelink
+
+
+ CombatTagPlusFactions-v1_8
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_7_R4
+ net.minelink
+
+
+ CombatTagPlusWG-v5
+ net.minelink
+
+
+ CombatTagPlusWG-v6
+ net.minelink
+
+
+ CombatTagPlusCompat-API
+ net.minelink
+
+
+ CombatTagPlusFactions-v2_6
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_8_R3
+ net.minelink
+
+
+ CombatTagPlusFactions-v2_7
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_8_R2
+ net.minelink
+
+
+ CombatTagPlusCompat-v1_8_R1
+ net.minelink
+
+
+ metrics-lite
+ org.mcstats.bukkit
+
+
+
-
-
- com.trc202
- CombatTag
- 6.2.1-SNAPSHOT
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
-
+
+
+ com.trc202
+ CombatTag
+ 6.2.1-SNAPSHOT
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+
-
-
- de.luricos.bukkit
- xAuth
- 2.6
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- updater
- net.gravitydevelopment.updater
-
-
- lombok
- org.projectlombok
-
-
- EssentialsGroupManager
- net.ess3
-
-
- PermissionsEx
- ru.tehkode
-
-
- AccountsClient
- com.mojang
-
-
-
+
+
+ de.luricos.bukkit
+ xAuth
+ 2.6
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ updater
+ net.gravitydevelopment.updater
+
+
+ lombok
+ org.projectlombok
+
+
+ EssentialsGroupManager
+ net.ess3
+
+
+ PermissionsEx
+ ru.tehkode
+
+
+ AccountsClient
+ com.mojang
+
+
+
-
-
- com.acrobot.chestshop
- chestshop
- 3.8.12
- provided
-
-
- org.bukkit
- bukkit
-
-
- org.bukkit
- craftbukkit
-
-
- Vault
- net.milkbowl.vault
-
-
- odditem
- info.somethingodd
-
-
- scrollingmenusign
- me.desht
-
-
- truezip
- de.schlichtherle
-
-
- residence
- net.t00thpick1
-
-
- Heroes
- com.herocraftonline.heroes
-
-
- HeroChat
- com.dthielke.herochat
-
-
- worldguard
- com.sk89q
-
-
- worldedit
- com.sk89q
-
-
- lwc
- com.griefcraft.lwc
-
-
- js
- rhino
-
-
- jchronic
- com.sk89q
-
-
- deadbolt
- com.daemitus.deadbolt
-
-
- bukkit-classloader-check
- com.sk89q.spigot
-
-
- jsr305
- com.google.code.findbugs
-
-
- opencsv
- net.sf.opencsv
-
-
- simplechestlock
-
+
+
+ com.acrobot.chestshop
+ chestshop
+ 3.8.12
+ provided
+
+
+ org.bukkit
+ bukkit
+
+
+ org.bukkit
+ craftbukkit
+
+
+ Vault
+ net.milkbowl.vault
+
+
+ odditem
+ info.somethingodd
+
+
+ scrollingmenusign
+ me.desht
+
+
+ truezip
+ de.schlichtherle
+
+
+ residence
+ net.t00thpick1
+
+
+ Heroes
+ com.herocraftonline.heroes
+
+
+ HeroChat
+ com.dthielke.herochat
+
+
+ worldguard
+ com.sk89q
+
+
+ worldedit
+ com.sk89q
+
+
+ lwc
+ com.griefcraft.lwc
+
+
+ js
+ rhino
+
+
+ jchronic
+ com.sk89q
+
+
+ deadbolt
+ com.daemitus.deadbolt
+
+
+ bukkit-classloader-check
+ com.sk89q.spigot
+
+
+ jsr305
+ com.google.code.findbugs
+
+
+ opencsv
+ net.sf.opencsv
+
+
+ simplechestlock
+
com.webkonsept.bukkit.simplechestlock
-
-
- commandbook
- com.sk89q
-
-
- lockette
- org.yi.acru.bukkit.lockette
-
-
-
+
+
+ commandbook
+ com.sk89q
+
+
+ lockette
+ org.yi.acru.bukkit.lockette
+
+
+
-
+
diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java
index 5c284d019..ac11a6022 100644
--- a/src/main/java/fr/xephi/authme/datasource/MySQL.java
+++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java
@@ -112,9 +112,10 @@ public class MySQL implements DataSource {
private synchronized void connect()
throws ClassNotFoundException, SQLException, TimeoutException,
NumberFormatException, PoolInitializationException {
- HikariConfig config = new HikariConfig();
+ HikariConfig config = new HikariConfig();
config.setPoolName("AuthMeMYSQLPool");
- config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
+ config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
+ config.setDriverClassName("com.mysql.jdbc.Driver");
config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
config.setUsername(this.username);
config.setPassword(this.password);
diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite_HIKARI.java b/src/main/java/fr/xephi/authme/datasource/SQLite_HIKARI.java
new file mode 100644
index 000000000..6f1350e31
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/datasource/SQLite_HIKARI.java
@@ -0,0 +1,804 @@
+package fr.xephi.authme.datasource;
+
+import java.io.EOFException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+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 fr.xephi.authme.AuthMe;
+import fr.xephi.authme.ConsoleLogger;
+import fr.xephi.authme.cache.auth.PlayerAuth;
+import fr.xephi.authme.settings.Settings;
+
+public class SQLite_HIKARI implements DataSource {
+
+ private String database;
+ private String tableName;
+ private String columnName;
+ private String columnPassword;
+ private String columnIp;
+ private String columnLastLogin;
+ private String columnSalt;
+ private String columnGroup;
+ private String lastlocX;
+ private String lastlocY;
+ private String lastlocZ;
+ private String lastlocWorld;
+ private String columnEmail;
+ private String columnID;
+ private HikariDataSource ds;
+ private String columnLogged;
+ private String columnRealName;
+
+ public SQLite_HIKARI() {
+ this.database = Settings.getMySQLDatabase;
+ this.tableName = Settings.getMySQLTablename;
+ this.columnName = Settings.getMySQLColumnName;
+ this.columnPassword = Settings.getMySQLColumnPassword;
+ this.columnIp = Settings.getMySQLColumnIp;
+ this.columnLastLogin = Settings.getMySQLColumnLastLogin;
+ this.columnSalt = Settings.getMySQLColumnSalt;
+ this.columnGroup = Settings.getMySQLColumnGroup;
+ this.lastlocX = Settings.getMySQLlastlocX;
+ this.lastlocY = Settings.getMySQLlastlocY;
+ this.lastlocZ = Settings.getMySQLlastlocZ;
+ this.lastlocWorld = Settings.getMySQLlastlocWorld;
+ this.columnEmail = Settings.getMySQLColumnEmail;
+ this.columnID = Settings.getMySQLColumnId;
+ this.columnLogged = Settings.getMySQLColumnLogged;
+ this.columnRealName = Settings.getMySQLColumnRealName;
+
+ try {
+ this.connect();
+ this.setup();
+ } catch (ClassNotFoundException e) {
+ ConsoleLogger.showError(e.getMessage());
+ 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 (SQLException e) {
+ ConsoleLogger.showError(e.getMessage());
+ 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)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
+ return;
+ }
+ }
+
+ private Connection getConnection() throws SQLException, EOFException {
+ return this.ds.getConnection();
+ }
+
+ 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");
+ ds = new HikariDataSource(config);
+ ConsoleLogger.info("Connection pool ready");
+ }
+
+ private synchronized void setup() throws SQLException, EOFException {
+ Connection con = null;
+ Statement st = null;
+ ResultSet rs = null;
+ try {
+ 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," + 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);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnIp + " VARCHAR(40) NOT NULL;");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT DEFAULT '0';");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world';");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com';");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " BIGINT DEFAULT '0';");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, columnRealName);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnRealName + " VARCHAR(255) NOT NULL DEFAULT 'Player';");
+ }
+ } finally {
+ close(rs);
+ close(st);
+ close(con);
+ }
+ 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;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ return rs.next();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public synchronized PlayerAuth getAuth(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=LOWER(?);");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ if (rs.next()) {
+ if (rs.getString(columnIp).isEmpty()) {
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "192.168.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ } else {
+ if (!columnSalt.isEmpty()) {
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ } else {
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ }
+ }
+ } else {
+ return null;
+ }
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return null;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public synchronized boolean saveAuth(PlayerAuth auth) {
+ PreparedStatement pst = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnRealName + ") VALUES (?,?,?,?,?);");
+ pst.setString(1, auth.getNickname());
+ pst.setString(2, auth.getHash());
+ pst.setString(3, auth.getIp());
+ pst.setLong(4, auth.getLastLogin());
+ pst.setString(5, auth.getRealName());
+ pst.executeUpdate();
+ } else {
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + "," + columnRealName + ") VALUES (?,?,?,?,?,?);");
+ pst.setString(1, auth.getNickname());
+ pst.setString(2, auth.getHash());
+ pst.setString(3, auth.getIp());
+ pst.setLong(4, auth.getLastLogin());
+ pst.setString(5, auth.getSalt());
+ pst.setString(6, auth.getRealName());
+ pst.executeUpdate();
+ }
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public synchronized boolean updatePassword(PlayerAuth auth) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getHash());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateSession(PlayerAuth auth) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=?, " + columnRealName + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getIp());
+ pst.setLong(2, auth.getLastLogin());
+ pst.setString(3, auth.getRealName());
+ pst.setString(4, auth.getNickname());
+ pst.executeUpdate();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public int purgeDatabase(long until) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + ";");
+ pst.setLong(1, until);
+ return pst.executeUpdate();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public List autoPurgeDatabase(long until) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ List list = new ArrayList();
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + ";");
+ pst.setLong(1, until);
+ rs = pst.executeQuery();
+ while (rs.next()) {
+ list.add(rs.getString(columnName));
+ }
+ return list;
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public synchronized boolean removeAuth(String user) {
+ PreparedStatement pst = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
+ pst.setString(1, user);
+ pst.executeUpdate();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateQuitLoc(PlayerAuth auth) {
+ PreparedStatement pst = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + "=?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
+ pst.setDouble(1, auth.getQuitLocX());
+ pst.setDouble(2, auth.getQuitLocY());
+ pst.setDouble(3, auth.getQuitLocZ());
+ pst.setString(4, auth.getWorld());
+ pst.setString(5, auth.getNickname());
+ pst.executeUpdate();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public int getIps(String ip) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ int countIp = 0;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
+ pst.setString(1, ip);
+ rs = pst.executeQuery();
+ while (rs.next()) {
+ countIp++;
+ }
+ return countIp;
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public boolean updateEmail(PlayerAuth auth) {
+ PreparedStatement pst = null;
+ Connection con = 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) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateSalt(PlayerAuth auth) {
+ if (columnSalt.isEmpty()) {
+ return false;
+ }
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getSalt());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ 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 getAllAuthsByName(PlayerAuth auth) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ List countIp = new ArrayList();
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
+ pst.setString(1, auth.getIp());
+ rs = pst.executeQuery();
+ while (rs.next()) {
+ countIp.add(rs.getString(columnName));
+ }
+ return countIp;
+ } catch (NullPointerException ex) {
+ return new ArrayList();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public List getAllAuthsByIp(String ip) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ List countIp = new ArrayList();
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
+ pst.setString(1, ip);
+ rs = pst.executeQuery();
+ while (rs.next()) {
+ countIp.add(rs.getString(columnName));
+ }
+ return countIp;
+ } catch (NullPointerException ex) {
+ return new ArrayList();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public List getAllAuthsByEmail(String email) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ List countEmail = new ArrayList();
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
+ pst.setString(1, email);
+ rs = pst.executeQuery();
+ while (rs.next()) {
+ countEmail.add(rs.getString(columnName));
+ }
+ return countEmail;
+ } catch (NullPointerException ex) {
+ return new ArrayList();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public void purgeBanned(List banned) {
+ PreparedStatement pst = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ for (String name : banned) {
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
+ pst.setString(1, name);
+ pst.executeUpdate();
+ }
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ } finally {
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public DataSourceType getType() {
+ return DataSourceType.SQLITE;
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE LOWER(" + columnName + ")=?;");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ if (rs.next())
+ return (rs.getInt(columnLogged) == 1);
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ return false;
+ }
+
+ @Override
+ public void setLogged(String user) {
+ PreparedStatement pst = null;
+ Connection con = 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) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ PreparedStatement pst = null;
+ Connection con = null;
+ if (user != null)
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
+ pst.setInt(1, 0);
+ pst.setString(2, user);
+ pst.executeUpdate();
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public void purgeLogged() {
+ PreparedStatement pst = null;
+ Connection con = 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) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public int getAccountsRegistered() {
+ int result = 0;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT COUNT(*) FROM " + tableName + ";");
+ rs = pst.executeQuery();
+ if (rs != null && rs.next()) {
+ result = rs.getInt(1);
+ }
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return result;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return result;
+ }
+
+ @Override
+ public void updateName(String oldone, String newone) {
+ PreparedStatement pst = null;
+ Connection con = 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) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public List getAllAuths() {
+ List auths = new ArrayList();
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + ";");
+ rs = pst.executeQuery();
+ while (rs.next()) {
+ PlayerAuth pAuth = null;
+ if (rs.getString(columnIp).isEmpty()) {
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ } else {
+ if (!columnSalt.isEmpty()) {
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ } else {
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ }
+ }
+ if (pAuth != null)
+ auths.add(pAuth);
+ }
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return auths;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return auths;
+ }
+
+ @Override
+ public List getLoggedPlayers() {
+ List auths = new ArrayList();
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ Connection con = null;
+ try {
+ con = getConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLogged + "=1;");
+ rs = pst.executeQuery();
+ while (rs.next()) {
+ PlayerAuth pAuth = null;
+ if (rs.getString(columnIp).isEmpty()) {
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "127.0.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ } else {
+ if (!columnSalt.isEmpty()) {
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ } else {
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), rs.getString(columnRealName));
+ }
+ }
+ if (pAuth != null)
+ auths.add(pAuth);
+ }
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return auths;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return auths;
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/modules/ModuleManager.java b/src/main/java/fr/xephi/authme/modules/ModuleManager.java
new file mode 100644
index 000000000..fc1d07f62
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/modules/ModuleManager.java
@@ -0,0 +1,100 @@
+package fr.xephi.authme.modules;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import fr.xephi.authme.AuthMe;
+import fr.xephi.authme.ConsoleLogger;
+
+public class ModuleManager implements Module {
+
+ private AuthMe plugin;
+ private ModuleManager instance;
+ private List modules = new ArrayList();
+
+ public ModuleManager(AuthMe plugin) {
+ this.plugin = plugin;
+ }
+
+ @Override
+ public String getName() {
+ return "AuthMe Module Manager";
+ }
+
+ @Override
+ public AuthMe getInstanceOfAuthMe() {
+ return this.plugin;
+ }
+
+ @Override
+ public Module getInstance() {
+ if (this.instance == null)
+ instance = new ModuleManager(AuthMe.getInstance());
+ return instance;
+ }
+
+ @Override
+ public ModuleType getType() {
+ return (Module.ModuleType.MANAGER);
+ }
+
+ @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)
+ return false;
+ for (File pathToJar : dir.listFiles()) {
+ JarFile jarFile = null;
+ try {
+ jarFile = new JarFile(pathToJar);
+ Enumeration> e = jarFile.entries();
+ URL[] urls = { new URL("jar:file:" + pathToJar.getAbsolutePath() + "!/") };
+ URLClassLoader cl = URLClassLoader.newInstance(urls);
+
+ while (e.hasMoreElements()) {
+ JarEntry je = (JarEntry) e.nextElement();
+ if (je.isDirectory() || !je.getName().endsWith("Main.class")) {
+ continue;
+ }
+ String className = je.getName().substring(0, je.getName().length() - 6);
+ className = className.replace('/', '.');
+ Class> c = cl.loadClass(className);
+ Module mod = (Module) c.newInstance();
+ mod.load();
+ modules.add(mod);
+ break;
+
+ }
+ } catch (Exception ex) {
+ ConsoleLogger.showError("Cannot load " + pathToJar.getName() + " jar file !");
+ } finally {
+ if (jarFile != null)
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean unload() {
+ try {
+ for (Module mod : modules) {
+ mod.unload();
+ modules.remove(mod);
+ }
+ } catch (Exception e) {
+ }
+ return true;
+ }
+
+}