();
+ poolConnectionEventListener = new PoolConnectionEventListener(); }
+
+/**
+* Closes all unused pooled connections.
+*/
+public synchronized void dispose() throws SQLException {
+ if (isDisposed) {
+ return; }
+ isDisposed = true;
+ SQLException e = null;
+ while (!recycledConnections.isEmpty()) {
+ PooledConnection pconn = recycledConnections.remove();
+ try {
+ pconn.close(); }
+ catch (SQLException e2) {
+ if (e == null) {
+ e = e2; }}}
+ if (e != null) {
+ throw e; }}
+
+/**
+* Retrieves a connection from the connection pool.
+*
+* If maxConnections connections are already in use, the method
+* waits until a connection becomes available or timeout seconds elapsed.
+* When the application is finished using the connection, it must close it
+* in order to return it to the pool.
+*
+* @return
+* a new Connection object.
+* @throws TimeoutException
+* when no connection becomes available within timeout seconds.
+*/
+public Connection getConnection() throws SQLException {
+ return getConnection2(timeoutMs); }
+
+private Connection getConnection2 (long timeoutMs) throws SQLException {
+ // This routine is unsynchronized, because semaphore.tryAcquire() may block.
+ synchronized (this) {
+ if (isDisposed) {
+ throw new IllegalStateException("Connection pool has been disposed."); }}
+ try {
+ if (!semaphore.tryAcquire(timeoutMs, TimeUnit.MILLISECONDS)) {
+ throw new TimeoutException(); }}
+ catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted while waiting for a database connection.",e); }
+ boolean ok = false;
+ try {
+ Connection conn = getConnection3();
+ ok = true;
+ return conn; }
+ finally {
+ if (!ok) {
+ semaphore.release(); }}}
+
+private synchronized Connection getConnection3() throws SQLException {
+ if (isDisposed) {
+ throw new IllegalStateException("Connection pool has been disposed."); } // test again with lock
+ PooledConnection pconn;
+ if (!recycledConnections.isEmpty()) {
+ pconn = recycledConnections.remove(); }
+ else {
+ pconn = dataSource.getPooledConnection();
+ pconn.addConnectionEventListener(poolConnectionEventListener); }
+ Connection conn = pconn.getConnection();
+ activeConnections++;
+ assertInnerState();
+ return conn; }
+
+/**
+* Retrieves a connection from the connection pool and ensures that it is valid
+* by calling {@link Connection#isValid(int)}.
+*
+*
If a connection is not valid, the method tries to get another connection
+* until one is valid (or a timeout occurs).
+*
+*
Pooled connections may become invalid when e.g. the database server is
+* restarted.
+*
+*
This method is slower than {@link #getConnection()} because the JDBC
+* driver has to send an extra command to the database server to test the connection.
+*
+*
+*
This method requires Java 1.6 or newer.
+*
+* @throws TimeoutException
+* when no valid connection becomes available within timeout seconds.
+*/
+public Connection getValidConnection() {
+ long time = System.currentTimeMillis();
+ long timeoutTime = time + timeoutMs;
+ int triesWithoutDelay = getInactiveConnections() + 1;
+ while (true) {
+ Connection conn = getValidConnection2(time, timeoutTime);
+ if (conn != null) {
+ return conn; }
+ triesWithoutDelay--;
+ if (triesWithoutDelay <= 0) {
+ triesWithoutDelay = 0;
+ try {
+ Thread.sleep(250);
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted while waiting for a valid database connection.", e);
+ }
+ }
+ time = System.currentTimeMillis();
+ if (time >= timeoutTime) {
+ throw new TimeoutException("Timeout while waiting for a valid database connection.");
+ }
+ }
+}
+
+private Connection getValidConnection2 (long time, long timeoutTime) {
+ long rtime = Math.max(1, timeoutTime - time);
+ Connection conn;
+ try {
+ conn = getConnection2(rtime); }
+ catch (SQLException e) {
+ return null; }
+ rtime = timeoutTime - System.currentTimeMillis();
+ int rtimeSecs = Math.max(1, (int)((rtime+999)/1000));
+ try {
+ if (conn.isValid(rtimeSecs)) {
+ return conn; }}
+ catch (SQLException e) {}
+ // This Exception should never occur. If it nevertheless occurs, it's because of an error in the
+ // JDBC driver which we ignore and assume that the connection is not valid.
+ // When isValid() returns false, the JDBC driver should have already called connectionErrorOccurred()
+ // and the PooledConnection has been removed from the pool, i.e. the PooledConnection will
+ // not be added to recycledConnections when Connection.close() is called.
+ // But to be sure that this works even with a faulty JDBC driver, we call purgeConnection().
+ purgeConnection(conn);
+ return null; }
+
+// Purges the PooledConnection associated with the passed Connection from the connection pool.
+private synchronized void purgeConnection (Connection conn) {
+ try {
+ doPurgeConnection = true;
+ // (A potential problem of this program logic is that setting the doPurgeConnection flag
+ // has an effect only if the JDBC driver calls connectionClosed() synchronously within
+ // Connection.close().)
+ conn.close(); }
+ catch (SQLException e) {}
+ // ignore exception from close()
+ finally {
+ doPurgeConnection = false; }}
+
+private synchronized void recycleConnection (PooledConnection pconn) {
+ if (isDisposed || doPurgeConnection) {
+ disposeConnection(pconn);
+ return; }
+ if (activeConnections <= 0) {
+ throw new AssertionError(); }
+ activeConnections--;
+ semaphore.release();
+ recycledConnections.add(pconn);
+ assertInnerState(); }
+
+private synchronized void disposeConnection (PooledConnection pconn) {
+ pconn.removeConnectionEventListener(poolConnectionEventListener);
+ if (!recycledConnections.remove(pconn)) {
+ // If the PooledConnection is not in the recycledConnections list,
+ // we assume that the connection was active.
+ if (activeConnections <= 0) {
+ throw new AssertionError(); }
+ activeConnections--;
+ semaphore.release(); }
+ closeConnectionAndIgnoreException(pconn);
+ assertInnerState(); }
+
+private void closeConnectionAndIgnoreException (PooledConnection pconn) {
+ try {
+ pconn.close(); }
+ catch (SQLException e) {
+ log("Error while closing database connection: "+e.toString()); }}
+
+private void log (String msg) {
+ String s = "MiniConnectionPoolManager: "+msg;
+ try {
+ if (logWriter == null) {
+ System.err.println(s); }
+ else {
+ logWriter.println(s); }}
+ catch (Exception e) {}}
+
+private void assertInnerState() {
+ if (activeConnections < 0) {
+ throw new AssertionError(); }
+ if (activeConnections + recycledConnections.size() > maxConnections) {
+ throw new AssertionError(); }
+ if (activeConnections + semaphore.availablePermits() > maxConnections) {
+ throw new AssertionError(); }}
+
+private class PoolConnectionEventListener implements ConnectionEventListener {
+ public void connectionClosed (ConnectionEvent event) {
+ PooledConnection pconn = (PooledConnection)event.getSource();
+ recycleConnection(pconn); }
+ public void connectionErrorOccurred (ConnectionEvent event) {
+ PooledConnection pconn = (PooledConnection)event.getSource();
+ disposeConnection(pconn); }}
+
+/**
+* Returns the number of active (open) connections of this pool.
+*
+*
This is the number of Connection objects that have been
+* issued by {@link #getConnection()}, for which Connection.close()
+* has not yet been called.
+*
+* @return
+* the number of active connections.
+**/
+public synchronized int getActiveConnections() {
+ return activeConnections; }
+
+/**
+* Returns the number of inactive (unused) connections in this pool.
+*
+*
This is the number of internally kept recycled connections,
+* for which Connection.close() has been called and which
+* have not yet been reused.
+*
+* @return
+* the number of inactive connections.
+**/
+public synchronized int getInactiveConnections() {
+ return recycledConnections.size(); }
+
+} // end class MiniConnectionPoolManager
\ No newline at end of file
diff --git a/src/main/java/uk/org/whoami/authme/datasource/MySQLDataSource.java b/src/main/java/uk/org/whoami/authme/datasource/MySQLDataSource.java
new file mode 100644
index 00000000..6a64034d
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/datasource/MySQLDataSource.java
@@ -0,0 +1,579 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.datasource;
+
+import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
+
+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 uk.org.whoami.authme.ConsoleLogger;
+import uk.org.whoami.authme.cache.auth.PlayerAuth;
+import uk.org.whoami.authme.datasource.MiniConnectionPoolManager.TimeoutException;
+import uk.org.whoami.authme.settings.Settings;
+
+public class MySQLDataSource implements DataSource {
+
+ private String host;
+ private String port;
+ private String username;
+ private String password;
+ 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 columnEmail;
+ private String columnID;
+ private List columnOthers;
+ private MiniConnectionPoolManager conPool;
+
+ public MySQLDataSource() throws ClassNotFoundException, SQLException {
+ this.host = Settings.getMySQLHost;
+ this.port = Settings.getMySQLPort;
+ this.username = Settings.getMySQLUsername;
+ this.password = Settings.getMySQLPassword;
+
+ 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.lastlocX = Settings.getMySQLlastlocX;
+ this.lastlocY = Settings.getMySQLlastlocY;
+ this.lastlocZ = Settings.getMySQLlastlocZ;
+ this.columnSalt = Settings.getMySQLColumnSalt;
+ this.columnGroup = Settings.getMySQLColumnGroup;
+ this.columnEmail = Settings.getMySQLColumnEmail;
+ this.columnOthers = Settings.getMySQLOtherUsernameColumn;
+ this.columnID = Settings.getMySQLColumnId;
+
+ connect();
+ setup();
+ }
+
+ private synchronized void connect() throws ClassNotFoundException, SQLException {
+ Class.forName("com.mysql.jdbc.Driver");
+ ConsoleLogger.info("MySQL driver loaded");
+ MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
+ dataSource.setDatabaseName(database);
+ dataSource.setServerName(host);
+ dataSource.setPort(Integer.parseInt(port));
+ dataSource.setUser(username);
+ dataSource.setPassword(password);
+
+ conPool = new MiniConnectionPoolManager(dataSource, 10);
+ ConsoleLogger.info("Connection pool ready");
+ }
+
+ private synchronized void setup() throws SQLException {
+ Connection con = null;
+ Statement st = null;
+ ResultSet rs = null;
+ try {
+ con = conPool.getValidConnection();
+ 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 + " smallint(6) DEFAULT '0',"
+ + lastlocY + " smallint(6) DEFAULT '0',"
+ + lastlocZ + " smallint(6) DEFAULT '0',"
+ + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
+ + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
+
+ 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;");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " smallint(6) NOT NULL DEFAULT '0' AFTER "
+ + columnLastLogin +" , ADD " + lastlocY + " smallint(6) NOT NULL DEFAULT '0' AFTER " + lastlocX + " , ADD " + lastlocZ + " smallint(6) NOT NULL DEFAULT '0' AFTER " + lastlocY + ";");
+ }
+ 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' AFTER " + lastlocZ +";");
+ }
+ } finally {
+ close(rs);
+ close(st);
+ close(con);
+ }
+ }
+
+ @Override
+ public synchronized boolean isAuthAvailable(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ try {
+ con = conPool.getValidConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ + columnName + "=?;");
+
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ return rs.next();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException 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 = conPool.getValidConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ + columnName + "=?;");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ if (rs.next()) {
+ if (rs.getString(columnIp).isEmpty() ) {
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
+ } else {
+ if(!columnSalt.isEmpty()){
+ if(!columnGroup.isEmpty())
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
+ else return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
+ } else {
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
+ }
+ }
+ } else {
+ return null;
+ }
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return null;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return null;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public synchronized boolean saveAuth(PlayerAuth auth) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = conPool.getValidConnection();
+ if ((columnSalt.isEmpty() || columnSalt == null) && (auth.getSalt().isEmpty() || auth.getSalt() == null)) {
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
+ pst.setString(1, auth.getNickname());
+ pst.setString(2, auth.getHash());
+ pst.setString(3, auth.getIp());
+ pst.setLong(4, auth.getLastLogin());
+ pst.executeUpdate();
+ } else {
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") 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.executeUpdate();
+ }
+ if (!columnOthers.isEmpty()) {
+ for(String column : columnOthers) {
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + "." + column + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getNickname());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ }
+ }
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException 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 = conPool.getValidConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getHash());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException 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 = conPool.getValidConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getIp());
+ pst.setLong(2, auth.getLastLogin());
+ pst.setString(3, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException 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 = conPool.getValidConnection();
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + ";");
+ pst.setLong(1, until);
+ return pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public synchronized boolean removeAuth(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = conPool.getValidConnection();
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
+ pst.setString(1, user);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateQuitLoc(PlayerAuth auth) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = conPool.getValidConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET "+ lastlocX + " =?, "+ lastlocY +"=?, "+ lastlocZ +"=? WHERE " + columnName + "=?;");
+ pst.setLong(1, auth.getQuitLocX());
+ pst.setLong(2, auth.getQuitLocY());
+ pst.setLong(3, auth.getQuitLocZ());
+ pst.setString(4, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ //
+ // Check how many registration by given ip has been done
+ //
+
+ @Override
+ public int getIps(String ip) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ int countIp=0;
+ try {
+ con = conPool.getValidConnection();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ + columnIp + "=?;");
+ pst.setString(1, ip);
+ rs = pst.executeQuery();
+ while(rs.next()) {
+ countIp++;
+ }
+ return countIp;
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public boolean updateEmail(PlayerAuth auth) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = conPool.getValidConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET "+ columnEmail + " =? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getEmail());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException 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 = conPool.getValidConnection();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET "+ columnSalt + " =? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getSalt());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public synchronized void close() {
+ try {
+ conPool.dispose();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ }
+ }
+
+ @Override
+ public void reload() {
+ }
+
+ 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());
+ }
+ }
+ }
+
+ private void close(Connection con) {
+ if (con != null) {
+ try {
+ con.close();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ }
+ }
+ }
+
+ @Override
+ public List getAllAuthsByName(PlayerAuth auth) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ List countIp = new ArrayList();
+ try {
+ con = conPool.getValidConnection();
+ 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 (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public List getAllAuthsByIp(String ip) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ List countIp = new ArrayList();
+ try {
+ con = conPool.getValidConnection();
+ 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 (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+ @Override
+ public List getAllAuthsByEmail(String email) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ List countEmail = new ArrayList();
+ try {
+ con = conPool.getValidConnection();
+ 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 (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ }
+
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/datasource/SqliteDataSource.java b/src/main/java/uk/org/whoami/authme/datasource/SqliteDataSource.java
new file mode 100644
index 00000000..c7ced642
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/datasource/SqliteDataSource.java
@@ -0,0 +1,514 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package uk.org.whoami.authme.datasource;
+
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.sqlite.*;
+import uk.org.whoami.authme.ConsoleLogger;
+import uk.org.whoami.authme.cache.auth.PlayerAuth;
+import uk.org.whoami.authme.datasource.MiniConnectionPoolManager.TimeoutException;
+import uk.org.whoami.authme.settings.Settings;
+
+/**
+ *
+ * @author stefano
+ */
+@SuppressWarnings("unused")
+public class SqliteDataSource implements DataSource {
+
+ private String host;
+ private String port;
+ private String username;
+ private String password;
+ 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 int nonActivatedGroup;
+ private String lastlocX;
+ private String lastlocY;
+ private String lastlocZ;
+ private String columnEmail;
+ private String columnID;
+ private Connection con;
+
+ public SqliteDataSource() throws ClassNotFoundException, SQLException {
+ //Settings s = Settings.getInstance();
+ this.host = Settings.getMySQLHost;
+ this.port = Settings.getMySQLPort;
+ this.username = Settings.getMySQLUsername;
+ this.password = Settings.getMySQLPassword;
+
+ 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.nonActivatedGroup = Settings.getNonActivatedGroup;
+ this.columnEmail = Settings.getMySQLColumnEmail;
+ this.columnID = Settings.getMySQLColumnId;
+
+ connect();
+ setup();
+ }
+
+ private synchronized void connect() throws ClassNotFoundException, SQLException {
+ Class.forName("org.sqlite.JDBC");
+ ConsoleLogger.info("SQLite driver loaded");
+
+ this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/"+database+".db");
+
+ }
+
+ private synchronized void setup() throws SQLException {
+ //Connection con = null;
+ Statement st = null;
+ ResultSet rs = null;
+ try {
+ 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 + " smallint(6) DEFAULT '0',"
+ + lastlocY + " smallint(6) DEFAULT '0',"
+ + lastlocZ + " smallint(6) DEFAULT '0',"
+ + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
+ + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
+
+ 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;");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " smallint(6) NOT NULL DEFAULT '0'; "
+ + "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocY + " smallint(6) NOT NULL DEFAULT '0'; "
+ + "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocZ + " smallint(6) NOT NULL DEFAULT '0';");
+ }
+ 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';");
+ }
+ } finally {
+ close(rs);
+ close(st);
+ //close(con);
+ }
+ ConsoleLogger.info("SQLite Setup finished");
+ }
+
+ @Override
+ public synchronized boolean isAuthAvailable(String user) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ try {
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ return rs.next();
+ } catch (SQLException 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 {
+
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ + columnName + "=?;");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ if (rs.next()) {
+ if (rs.getString(columnIp).isEmpty() ) {
+ //System.out.println("[Authme Debug] ColumnIp is empty");
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
+ } else {
+ if(!columnSalt.isEmpty()){
+ //System.out.println("[Authme Debug] column Salt is" + rs.getString(columnSalt));
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
+ } else {
+ //System.out.println("[Authme Debug] column Salt is empty");
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
+
+ }
+ }
+ } else {
+ return null;
+ }
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return null;
+ } finally {
+ close(rs);
+ close(pst);
+ //close(con);
+ }
+ }
+
+ @Override
+ public synchronized boolean saveAuth(PlayerAuth auth) {
+ //Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
+ pst.setString(1, auth.getNickname());
+ pst.setString(2, auth.getHash());
+ pst.setString(3, auth.getIp());
+ pst.setLong(4, auth.getLastLogin());
+ pst.executeUpdate();
+ } else {
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") 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.executeUpdate();
+ }
+ } catch (SQLException 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 {
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getHash());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException 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 {
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getIp());
+ pst.setLong(2, auth.getLastLogin());
+ pst.setString(3, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException 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 {
+
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + ";");
+ pst.setLong(1, until);
+ return pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } finally {
+ close(pst);
+ //close(con);
+ }
+ }
+
+ @Override
+ public synchronized boolean removeAuth(String user) {
+ //Connection con = null;
+ PreparedStatement pst = null;
+ try {
+
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
+ pst.setString(1, user);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ //close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateQuitLoc(PlayerAuth auth) {
+ //Connection con = null;
+ PreparedStatement pst = null;
+ try {
+
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + "=?, "+ lastlocY +"=?, "+ lastlocZ +"=? WHERE " + columnName + "=?;");
+ pst.setLong(1, auth.getQuitLocX());
+ pst.setLong(2, auth.getQuitLocY());
+ pst.setLong(3, auth.getQuitLocZ());
+ pst.setString(4, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ //close(con);
+ }
+ return true;
+ }
+
+ //
+ // Check how many registration by given ip has been done
+ //
+
+ @Override
+ public int getIps(String ip) {
+ //Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ int countIp=0;
+ try {
+
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ + columnIp + "=?;");
+ pst.setString(1, ip);
+ rs = pst.executeQuery();
+ while(rs.next()) {
+ countIp++;
+ }
+ return countIp;
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return 0;
+ } finally {
+ close(rs);
+ close(pst);
+ //close(con);
+ }
+ }
+
+ @Override
+ public boolean updateEmail(PlayerAuth auth) {
+ //Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getEmail());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException 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 {
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + "=? WHERE " + columnName + "=?;");
+ pst.setString(1, auth.getSalt());
+ pst.setString(2, auth.getNickname());
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(pst);
+ //close(con);
+ }
+ return true;
+ }
+
+ @Override
+ public synchronized void close() {
+ try {
+ con.close();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ }
+ }
+
+ @Override
+ public void reload() {
+ }
+
+ 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());
+ }
+ }
+ }
+
+ private void close(Connection con) {
+ if (con != null) {
+ try {
+ con.close();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ }
+ }
+ }
+
+ @Override
+ public List getAllAuthsByName(PlayerAuth auth) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ List countIp = new ArrayList();
+ try {
+ 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 (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (NullPointerException npe) {
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ //close(con);
+ }
+ }
+
+ @Override
+ public List getAllAuthsByIp(String ip) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ List countIp = new ArrayList();
+ try {
+ 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 (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (NullPointerException npe) {
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ //close(con);
+ }
+ }
+
+ @Override
+ public List getAllAuthsByEmail(String email) {
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ List countEmail = new ArrayList();
+ try {
+ 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 (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return new ArrayList();
+ } catch (NullPointerException npe) {
+ return new ArrayList();
+ } finally {
+ close(rs);
+ close(pst);
+ }
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/debug/CardboardBox.java b/src/main/java/uk/org/whoami/authme/debug/CardboardBox.java
new file mode 100644
index 00000000..161d8d24
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/debug/CardboardBox.java
@@ -0,0 +1,53 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ *
+ * http://forums.bukkit.org/threads/cardboard-serializable-itemstack-with-enchantments.75768/
+ */
+package uk.org.whoami.authme.debug;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.inventory.ItemStack;
+
+public class CardboardBox implements Serializable {
+ private static final long serialVersionUID = 729890133797629668L;
+
+ private final int type, amount;
+ private final short damage;
+
+ private final HashMap enchants;
+
+ public CardboardBox(ItemStack item) {
+ this.type = item.getTypeId();
+ this.amount = item.getAmount();
+ this.damage = item.getDurability();
+
+ HashMap map = new HashMap();
+
+ Map enchantments = item.getEnchantments();
+
+ for(Enchantment enchantment : enchantments.keySet()) {
+ map.put(new CardboardEnchantment(enchantment), enchantments.get(enchantment));
+ }
+
+ this.enchants = map;
+ }
+
+ public ItemStack unbox() {
+ ItemStack item = new ItemStack(type, amount, damage);
+
+ HashMap map = new HashMap();
+
+ for(CardboardEnchantment cEnchantment : enchants.keySet()) {
+ map.put(cEnchantment.unbox(), enchants.get(cEnchantment));
+ }
+
+ item.addUnsafeEnchantments(map);
+
+ return item;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/uk/org/whoami/authme/debug/CardboardEnchantment.java b/src/main/java/uk/org/whoami/authme/debug/CardboardEnchantment.java
new file mode 100644
index 00000000..c056ac2d
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/debug/CardboardEnchantment.java
@@ -0,0 +1,25 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package uk.org.whoami.authme.debug;
+
+import java.io.Serializable;
+import org.bukkit.enchantments.Enchantment;
+
+/**
+ * A serializable Enchantment
+ */
+public class CardboardEnchantment implements Serializable {
+ private static final long serialVersionUID = 8973856768102665381L;
+
+ private final int id;
+
+ public CardboardEnchantment(Enchantment enchantment) {
+ this.id = enchantment.getId();
+ }
+
+ public Enchantment unbox() {
+ return Enchantment.getById(this.id);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/uk/org/whoami/authme/events/AuthMeTeleportEvent.java b/src/main/java/uk/org/whoami/authme/events/AuthMeTeleportEvent.java
new file mode 100644
index 00000000..be6ea5b0
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/AuthMeTeleportEvent.java
@@ -0,0 +1,30 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+
+public class AuthMeTeleportEvent extends CustomEvent {
+
+ private Player player;
+ private Location to;
+ private Location from;
+
+ public AuthMeTeleportEvent(Player player, Location to) {
+ this.player = player;
+ this.from = player.getLocation();
+ this.to = to;
+ }
+ public Player getPlayer() {
+ return player;
+ }
+ public void setTo(Location to) {
+ this.to = to;
+ }
+ public Location getTo() {
+ return to;
+ }
+ public Location getFrom() {
+ return from;
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/CustomEvent.java b/src/main/java/uk/org/whoami/authme/events/CustomEvent.java
new file mode 100644
index 00000000..b5f610e0
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/CustomEvent.java
@@ -0,0 +1,36 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.Server;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class CustomEvent extends Event {
+
+
+ private boolean isCancelled;
+ private static final HandlerList handlers = new HandlerList();
+ private static Server s;
+
+
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ public boolean isCancelled() {
+ return this.isCancelled;
+ }
+
+ public void setCancelled(boolean cancelled) {
+ this.isCancelled = cancelled;
+ }
+
+
+ public static Server getServer() {
+ return s;
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/LoginEvent.java b/src/main/java/uk/org/whoami/authme/events/LoginEvent.java
new file mode 100644
index 00000000..4c6cca34
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/LoginEvent.java
@@ -0,0 +1,31 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.entity.Player;
+
+public class LoginEvent extends UncancellableEvent {
+
+
+ private Player player;
+ private boolean isLogin;
+
+ public LoginEvent(Player player, boolean isLogin) {
+ this.player = player;
+ this.isLogin = isLogin;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
+
+ public void setLogin(boolean isLogin) {
+ this.isLogin = isLogin;
+ }
+
+ public boolean isLogin() {
+ return isLogin;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/ProtectInventoryEvent.java b/src/main/java/uk/org/whoami/authme/events/ProtectInventoryEvent.java
new file mode 100644
index 00000000..b6fd1551
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/ProtectInventoryEvent.java
@@ -0,0 +1,58 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import uk.org.whoami.authme.api.API;
+
+public class ProtectInventoryEvent extends CustomEvent {
+
+ private ItemStack[] storedinventory;
+ private ItemStack[] storedarmor;
+ private ItemStack[] emptyInventory = null;
+ private ItemStack[] emptyArmor = null;
+ private Player player;
+
+ public ProtectInventoryEvent(Player player, ItemStack[] storedinventory, ItemStack[] storedarmor) {
+ this.player = player;
+ this.storedinventory = storedinventory;
+ this.storedarmor = storedarmor;
+ }
+
+ public ProtectInventoryEvent(Player player, ItemStack[] storedinventory, ItemStack[] storedarmor, int newInventory, int newArmor) {
+ this.player = player;
+ this.storedinventory = storedinventory;
+ this.storedarmor = storedarmor;
+ this.setNewInventory(new ItemStack[newInventory]);
+ this.setNewArmor(new ItemStack[newArmor]);
+ API.setPlayerInventory(player, new ItemStack[newInventory], new ItemStack[newArmor]);
+ }
+
+ public ItemStack[] getStoredInventory() {
+ return this.storedinventory;
+ }
+
+ public ItemStack[] getStoredArmor() {
+ return this.storedarmor;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ public void setNewInventory(ItemStack[] emptyInventory) {
+ this.emptyInventory = emptyInventory;
+ }
+
+ public ItemStack[] getEmptyInventory() {
+ return this.emptyInventory;
+ }
+
+ public void setNewArmor(ItemStack[] emptyArmor) {
+ this.emptyArmor = emptyArmor;
+ }
+
+ public ItemStack[] getEmptyArmor() {
+ return this.emptyArmor;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/ResetInventoryEvent.java b/src/main/java/uk/org/whoami/authme/events/ResetInventoryEvent.java
new file mode 100644
index 00000000..e2eff209
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/ResetInventoryEvent.java
@@ -0,0 +1,24 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import uk.org.whoami.authme.api.API;
+
+public class ResetInventoryEvent extends CustomEvent {
+
+ private Player player;
+
+ public ResetInventoryEvent(Player player) {
+ this.player = player;
+ API.setPlayerInventory(player, new ItemStack[36], new ItemStack[4]);
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/RestoreInventoryEvent.java b/src/main/java/uk/org/whoami/authme/events/RestoreInventoryEvent.java
new file mode 100644
index 00000000..b2232195
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/RestoreInventoryEvent.java
@@ -0,0 +1,41 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+public class RestoreInventoryEvent extends CustomEvent {
+
+ private ItemStack[] inventory;
+ private ItemStack[] armor;
+ private Player player;
+
+ public RestoreInventoryEvent(Player player, ItemStack[] inventory, ItemStack[] armor) {
+ this.player = player;
+ this.inventory = inventory;
+ this.armor = armor;
+ }
+
+ public ItemStack[] getInventory() {
+ return this.inventory;
+ }
+
+ public void setInventory(ItemStack[] inventory) {
+ this.inventory = inventory;
+ }
+
+ public ItemStack[] getArmor() {
+ return this.armor;
+ }
+
+ public void setArmor(ItemStack[] armor) {
+ this.armor = armor;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/SessionEvent.java b/src/main/java/uk/org/whoami/authme/events/SessionEvent.java
new file mode 100644
index 00000000..9b88cd3a
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/SessionEvent.java
@@ -0,0 +1,27 @@
+package uk.org.whoami.authme.events;
+
+import uk.org.whoami.authme.cache.auth.PlayerAuth;
+
+public class SessionEvent extends CustomEvent {
+
+
+ private PlayerAuth player;
+ private boolean isLogin;
+
+ public SessionEvent(PlayerAuth auth, boolean isLogin) {
+ this.player = auth;
+ this.isLogin = isLogin;
+ }
+
+ public PlayerAuth getPlayerAuth() {
+ return this.player;
+ }
+
+ public void setPlayer(PlayerAuth player) {
+ this.player = player;
+ }
+
+ public boolean isLogin() {
+ return isLogin;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/SpawnTeleportEvent.java b/src/main/java/uk/org/whoami/authme/events/SpawnTeleportEvent.java
new file mode 100644
index 00000000..7bbfc628
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/SpawnTeleportEvent.java
@@ -0,0 +1,35 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+
+public class SpawnTeleportEvent extends CustomEvent {
+
+ private Player player;
+ private Location to;
+ private Location from;
+ private boolean isAuthenticated;
+
+ public SpawnTeleportEvent(Player player, Location from, Location to, boolean isAuthenticated) {
+ this.player = player;
+ this.from = from;
+ this.to = to;
+ this.isAuthenticated = isAuthenticated;
+ }
+ public Player getPlayer() {
+ return player;
+ }
+ public void setTo(Location to) {
+ this.to = to;
+ }
+ public Location getTo() {
+ return to;
+ }
+ public Location getFrom() {
+ return from;
+ }
+ public boolean isAuthenticated() {
+ return isAuthenticated;
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/StoreInventoryEvent.java b/src/main/java/uk/org/whoami/authme/events/StoreInventoryEvent.java
new file mode 100644
index 00000000..1d5a11a8
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/StoreInventoryEvent.java
@@ -0,0 +1,50 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import uk.org.whoami.authme.cache.backup.FileCache;
+
+public class StoreInventoryEvent extends CustomEvent {
+
+
+ private ItemStack[] inventory;
+ private ItemStack[] armor;
+ private Player player;
+
+ public StoreInventoryEvent(Player player) {
+ this.player = player;
+ this.inventory = player.getInventory().getContents();
+ this.armor = player.getInventory().getArmorContents();
+ }
+
+ public StoreInventoryEvent(Player player, FileCache fileCache) {
+ this.player = player;
+ this.inventory = fileCache.readCache(player.getName().toLowerCase()).getInventory();
+ this.armor = fileCache.readCache(player.getName().toLowerCase()).getArmour();
+ }
+
+ public ItemStack[] getInventory() {
+ return this.inventory;
+ }
+
+ public void setInventory(ItemStack[] inventory) {
+ this.inventory = inventory;
+ }
+
+ public ItemStack[] getArmor() {
+ return this.armor;
+ }
+
+ public void setArmor(ItemStack[] armor) {
+ this.armor = armor;
+ }
+
+ public Player getPlayer() {
+ return this.player;
+ }
+
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/events/UncancellableEvent.java b/src/main/java/uk/org/whoami/authme/events/UncancellableEvent.java
new file mode 100644
index 00000000..1c6f17e4
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/events/UncancellableEvent.java
@@ -0,0 +1,26 @@
+package uk.org.whoami.authme.events;
+
+import org.bukkit.Server;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class UncancellableEvent extends Event {
+
+
+ private static final HandlerList handlers = new HandlerList();
+ private static Server s;
+
+
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ public static Server getServer() {
+ return s;
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/filter/ConsoleFilter.java b/src/main/java/uk/org/whoami/authme/filter/ConsoleFilter.java
new file mode 100644
index 00000000..656d1733
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/filter/ConsoleFilter.java
@@ -0,0 +1,23 @@
+package uk.org.whoami.authme.filter;
+
+import java.util.logging.Filter;
+import java.util.logging.LogRecord;
+
+public class ConsoleFilter implements Filter {
+
+ public ConsoleFilter() {}
+
+ @Override
+ public boolean isLoggable(LogRecord record) {
+ String logM = record.getMessage().toLowerCase();
+ if (!logM.contains("issued server command:")) return true;
+ if (!logM.contains("/login") && !logM.contains("/l") && !logM.contains("/reg") && !logM.contains("/changepassword") && !logM.contains("/unregister")
+ && !logM.contains("/authme register") && !logM.contains("/authme changepassword")&& !logM.contains("/authme reg")&& !logM.contains("/authme cp")) return true;
+ String playername = record.getMessage().split(" ")[0];
+ record.setMessage(playername + " issued an AuthMe command!");
+ return true;
+ }
+
+
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/gui/Clickable.java b/src/main/java/uk/org/whoami/authme/gui/Clickable.java
new file mode 100644
index 00000000..7787c9a5
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/gui/Clickable.java
@@ -0,0 +1,7 @@
+package uk.org.whoami.authme.gui;
+
+import org.getspout.spoutapi.event.screen.ButtonClickEvent;
+
+public interface Clickable {
+ public void handleClick(ButtonClickEvent event);
+}
diff --git a/src/main/java/uk/org/whoami/authme/gui/CustomButton.java b/src/main/java/uk/org/whoami/authme/gui/CustomButton.java
new file mode 100644
index 00000000..67ad0695
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/gui/CustomButton.java
@@ -0,0 +1,27 @@
+package uk.org.whoami.authme.gui;
+
+import org.getspout.spoutapi.event.screen.ButtonClickEvent;
+import org.getspout.spoutapi.gui.GenericButton;
+
+public class CustomButton extends GenericButton
+{
+ public Clickable handleRef = null;
+
+ public CustomButton(Clickable c) {
+ handleRef = c;
+ }
+
+ @Override
+ public void onButtonClick(ButtonClickEvent event) {
+ handleRef.handleClick(event);
+ }
+
+ public CustomButton setMidPos(int x, int y)
+ {
+ this.setX(x)
+ .setY(y)
+ .shiftXPos(-(width / 2))
+ .shiftYPos(-(height / 2));
+ return this;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/gui/screens/LoginScreen.java b/src/main/java/uk/org/whoami/authme/gui/screens/LoginScreen.java
new file mode 100644
index 00000000..91e9b13f
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/gui/screens/LoginScreen.java
@@ -0,0 +1,153 @@
+package uk.org.whoami.authme.gui.screens;
+
+/**
+ * @Author Hoezef
+ */
+import java.util.List;
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.getspout.spoutapi.event.screen.ButtonClickEvent;
+import org.getspout.spoutapi.gui.Button;
+import org.getspout.spoutapi.gui.Color;
+import org.getspout.spoutapi.gui.GenericLabel;
+import org.getspout.spoutapi.gui.GenericPopup;
+import org.getspout.spoutapi.gui.GenericTextField;
+import org.getspout.spoutapi.gui.RenderPriority;
+import org.getspout.spoutapi.gui.Widget;
+import org.getspout.spoutapi.gui.WidgetAnchor;
+import org.getspout.spoutapi.player.SpoutPlayer;
+
+import uk.org.whoami.authme.AuthMe;
+import uk.org.whoami.authme.gui.Clickable;
+import uk.org.whoami.authme.gui.CustomButton;
+import uk.org.whoami.authme.settings.SpoutCfg;
+
+public class LoginScreen extends GenericPopup implements Clickable{
+
+ public AuthMe plugin = AuthMe.getInstance();
+ private SpoutCfg spoutCfg = SpoutCfg.getInstance();
+
+ private CustomButton exitBtn;
+ private CustomButton loginBtn;
+ private GenericTextField passBox;
+ private GenericLabel titleLbl;
+ private GenericLabel textLbl;
+ private GenericLabel errorLbl;
+
+ String exitTxt = spoutCfg.getString("LoginScreen.exit button"); //"Quit";
+ String loginTxt = spoutCfg.getString("LoginScreen.login button"); //"Login";
+ String exitMsg = spoutCfg.getString("LoginScreen.exit message"); //"Good Bye";
+ String title = spoutCfg.getString("LoginScreen.title"); //"LOGIN"
+ @SuppressWarnings("unchecked")
+ List textlines = (List) spoutCfg.getList("LoginScreen.text");
+ public SpoutPlayer splayer;
+
+ public LoginScreen(SpoutPlayer player) {
+ this.splayer = player;
+
+ createScreen();
+ }
+
+ private void createScreen() {
+ int objects = textlines.size() + 4;
+ int part = !(textlines.size() <= 5) ? 195 / objects : 20;
+ int h = 3*part/4, w = 8*part;
+
+ titleLbl = new GenericLabel();
+ titleLbl
+ .setText(title)
+ .setTextColor(new Color(1.0F, 0, 0, 1.0F))
+ .setAlign(WidgetAnchor.TOP_CENTER)
+ .setHeight(h)
+ .setWidth(w)
+ .setX(maxWidth / 2 )
+ .setY(25);
+ this.attachWidget(plugin, titleLbl);
+
+ int ystart = 25 + h + part/2;
+ for (int x=0; x.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.listener;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
+
+import uk.org.whoami.authme.AuthMe;
+import uk.org.whoami.authme.Utils;
+import uk.org.whoami.authme.cache.auth.PlayerCache;
+import uk.org.whoami.authme.datasource.DataSource;
+import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
+import uk.org.whoami.authme.settings.Settings;
+
+public class AuthMeBlockListener implements Listener {
+
+ private DataSource data;
+ public AuthMe instance;
+ //private Settings settings = Settings.getInstance();
+
+ public AuthMeBlockListener(DataSource data, AuthMe instance) {
+ this.data = data;
+ this.instance = instance;
+ }
+
+ @EventHandler
+ public void onBlockPlace(BlockPlaceEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if(instance.getCitizensCommunicator().isNPC(player, instance) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ event.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onBlockBreak(BlockBreakEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if(instance.getCitizensCommunicator().isNPC(player, instance) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ event.setCancelled(true);
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/listener/AuthMeChestShopListener.java b/src/main/java/uk/org/whoami/authme/listener/AuthMeChestShopListener.java
new file mode 100644
index 00000000..ea093df7
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/listener/AuthMeChestShopListener.java
@@ -0,0 +1,54 @@
+package uk.org.whoami.authme.listener;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+
+import com.Acrobot.ChestShop.Events.PreTransactionEvent;
+import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
+
+import uk.org.whoami.authme.AuthMe;
+import uk.org.whoami.authme.Utils;
+import uk.org.whoami.authme.cache.auth.PlayerCache;
+import uk.org.whoami.authme.datasource.DataSource;
+import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
+import uk.org.whoami.authme.settings.Settings;
+
+public class AuthMeChestShopListener implements Listener {
+
+ public DataSource database;
+ public AuthMe plugin;
+
+ public AuthMeChestShopListener(DataSource database, AuthMe plugin) {
+ this.database = database;
+ this.plugin = plugin;
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST)
+ public void onPreTransaction(PreTransactionEvent event) {
+ if (event.isCancelled() || event.getClient() == null || event == null) {
+ return;
+ }
+
+ Player player = event.getClient();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!database.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+ event.setCancelled(TransactionOutcome.OTHER);
+
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/listener/AuthMeEntityListener.java b/src/main/java/uk/org/whoami/authme/listener/AuthMeEntityListener.java
new file mode 100644
index 00000000..dea3cb04
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/listener/AuthMeEntityListener.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.listener;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityInteractEvent;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.FoodLevelChangeEvent;
+
+import uk.org.whoami.authme.AuthMe;
+import uk.org.whoami.authme.Utils;
+import uk.org.whoami.authme.cache.auth.PlayerCache;
+import uk.org.whoami.authme.datasource.DataSource;
+import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
+import uk.org.whoami.authme.settings.Settings;
+
+public class AuthMeEntityListener implements Listener{
+
+ private DataSource data;
+ public AuthMe instance;
+ //private Settings settings = Settings.getInstance();
+
+ public AuthMeEntityListener(DataSource data, AuthMe instance) {
+ this.data = data;
+ this.instance = instance;
+ }
+
+ @EventHandler
+ public void onEntityDamage(EntityDamageEvent event) {
+ if (event.isCancelled()) {
+ return;
+ }
+ Entity entity = event.getEntity();
+
+ if (!(entity instanceof Player)) {
+ return;
+ }
+ /*
+ System.out.println("[ Entity Damage ] "+event.getEntity().toString());
+ @Future implementation till CombatTag dont release any apis
+ if(event.getEntity().toString().indexOf("PvPLogger") != -1 ) {
+ System.out.println("la stringa contiene PvPLogger 2");
+ return;
+ }
+ */
+ if(instance.getCitizensCommunicator().isNPC(entity, instance) || Utils.getInstance().isUnrestricted((Player)entity) || CombatTagComunicator.isNPC(entity)) {
+ return;
+ }
+
+ Player player = (Player) entity;
+ String name = player.getName().toLowerCase();
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ player.setFireTicks(0);
+ event.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onEntityTarget(EntityTargetEvent event) {
+ if (event.isCancelled()) {
+ return;
+ }
+
+ Entity entity = event.getEntity();
+ if (!(entity instanceof Player)) {
+ return;
+ }
+
+ Player player = (Player) entity;
+ String name = player.getName().toLowerCase();
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ event.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onFoodLevelChange(FoodLevelChangeEvent event) {
+ if (event.isCancelled()) {
+ return;
+ }
+
+ Entity entity = event.getEntity();
+ if (!(entity instanceof Player)) {
+ return;
+ }
+
+ Player player = (Player) entity;
+ String name = player.getName().toLowerCase();
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ event.setCancelled(true);
+
+ }
+
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void EntityRegainHealthEvent(EntityRegainHealthEvent event) {
+ if (event.isCancelled()) {
+ return;
+ }
+
+ Entity entity = event.getEntity();
+ if (!(entity instanceof Player)) {
+ return;
+ }
+
+ Player player = (Player) entity;
+ String name = player.getName().toLowerCase();
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ event.setCancelled(true);
+ }
+
+ @EventHandler (priority = EventPriority.MONITOR)
+ public void onEntityInteract(EntityInteractEvent event) {
+ if (event.isCancelled() || event == null) {
+ return;
+ }
+
+ if (!(event.getEntity() instanceof Player)) {
+ return;
+ }
+
+ Player player = (Player) event.getEntity();
+ String name = player.getName().toLowerCase();
+
+ if (instance.getCitizensCommunicator().isNPC(player, instance) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+ event.setCancelled(true);
+
+ }
+
+ @EventHandler (priority = EventPriority.LOWEST)
+ public void onLowestEntityInteract(EntityInteractEvent event) {
+ if (event.isCancelled() || event == null) {
+ return;
+ }
+
+ if (!(event.getEntity() instanceof Player)) {
+ return;
+ }
+
+ Player player = (Player) event.getEntity();
+ String name = player.getName().toLowerCase();
+
+ if (instance.getCitizensCommunicator().isNPC(player, instance) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ event.setCancelled(true);
+
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java b/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java
new file mode 100644
index 00000000..b0ebc5a8
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/listener/AuthMePlayerListener.java
@@ -0,0 +1,1085 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.listener;
+
+import java.util.Date;
+import java.util.HashMap;
+
+import net.md_5.bungee.api.connection.ConnectedPlayer;
+import net.md_5.bungee.api.connection.ProxiedPlayer;
+
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.event.block.SignChangeEvent;
+import org.bukkit.event.player.PlayerBedEnterEvent;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.event.player.PlayerInteractEntityEvent;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerKickEvent;
+import org.bukkit.event.player.PlayerLoginEvent;
+import org.bukkit.event.player.PlayerLoginEvent.Result;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerPickupItemEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.scheduler.BukkitScheduler;
+import org.bukkit.scheduler.BukkitTask;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+
+import uk.org.whoami.authme.api.API;
+import uk.org.whoami.authme.cache.backup.DataFileCache;
+import uk.org.whoami.authme.cache.backup.FileCache;
+import uk.org.whoami.authme.AuthMe;
+import uk.org.whoami.authme.ConsoleLogger;
+import uk.org.whoami.authme.Utils;
+import uk.org.whoami.authme.cache.auth.PlayerAuth;
+import uk.org.whoami.authme.cache.auth.PlayerCache;
+import uk.org.whoami.authme.cache.limbo.LimboPlayer;
+import uk.org.whoami.authme.cache.limbo.LimboCache;
+import uk.org.whoami.authme.datasource.DataSource;
+import uk.org.whoami.authme.events.AuthMeTeleportEvent;
+import uk.org.whoami.authme.events.ProtectInventoryEvent;
+import uk.org.whoami.authme.events.RestoreInventoryEvent;
+import uk.org.whoami.authme.events.SessionEvent;
+import uk.org.whoami.authme.events.SpawnTeleportEvent;
+import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
+import uk.org.whoami.authme.settings.Messages;
+import uk.org.whoami.authme.settings.PlayersLogs;
+import uk.org.whoami.authme.settings.Settings;
+import uk.org.whoami.authme.task.MessageTask;
+import uk.org.whoami.authme.task.TimeoutTask;
+
+
+public class AuthMePlayerListener implements Listener {
+
+
+ public static int gm = 0;
+ public static HashMap gameMode = new HashMap();
+ private Utils utils = Utils.getInstance();
+ private Messages m = Messages.getInstance();
+ public AuthMe plugin;
+ private DataSource data;
+ private FileCache playerBackup = new FileCache();
+
+ public AuthMePlayerListener(AuthMe plugin, DataSource data) {
+ this.plugin = plugin;
+ this.data = data;
+ }
+
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player) ) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ String msg = event.getMessage();
+ //WorldEdit GUI Shit
+ if (msg.equalsIgnoreCase("/worldedit cui")) {
+ return;
+ }
+
+ String cmd = msg.split(" ")[0];
+ if (cmd.equalsIgnoreCase("/login") || cmd.equalsIgnoreCase("/register") || cmd.equalsIgnoreCase("/passpartu") || cmd.equalsIgnoreCase("/l") || cmd.equalsIgnoreCase("/reg") || cmd.equalsIgnoreCase("/email") || cmd.equalsIgnoreCase("/captcha")) {
+ return;
+ }
+
+ if (Settings.allowCommands.contains(cmd)) {
+ return;
+ }
+
+ event.setMessage("/notloggedin");
+ event.setCancelled(true);
+ }
+
+ @EventHandler( priority = EventPriority.NORMAL)
+ public void onPlayerNormalChat(AsyncPlayerChatEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+ final Player player = event.getPlayer();
+ final String name = player.getName().toLowerCase();
+
+ if(plugin.CitizensVersion != 0) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin)) {
+ return;
+ }
+ }
+
+ if(plugin.CombatTag != 0) {
+ if (CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+ }
+
+ if (Utils.getInstance().isUnrestricted(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ String cmd = event.getMessage().split(" ")[0];
+
+ if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
+ //System.out.println("debug chat: chat isnt allowed");
+ event.setCancelled(true);
+ return;
+ }
+
+ if (!event.isAsynchronous()) {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ player.sendMessage(m._("reg_msg"));
+ }
+ } else {
+
+ Bukkit.getScheduler().runTask(plugin, new Runnable()
+ {
+ @Override
+ public void run() {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (Settings.isForcedRegistrationEnabled) {
+ player.sendMessage(m._("reg_msg"));
+ }
+ }
+ }});
+ }
+ }
+
+ @EventHandler( priority = EventPriority.HIGH)
+ public void onPlayerHighChat(AsyncPlayerChatEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+
+ final Player player = event.getPlayer();
+ final String name = player.getName().toLowerCase();
+
+ if(plugin.CitizensVersion != 0) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin)) {
+ return;
+ }
+ }
+
+ if(plugin.CombatTag != 0) {
+ if (CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+ }
+
+ if (Utils.getInstance().isUnrestricted(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ String cmd = event.getMessage().split(" ")[0];
+
+ if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
+ //System.out.println("debug chat: chat isnt allowed");
+ event.setCancelled(true);
+ return;
+ }
+
+ if (!event.isAsynchronous()) {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ player.sendMessage(m._("reg_msg"));
+ }
+ } else {
+
+ Bukkit.getScheduler().runTask(plugin, new Runnable()
+ {
+ @Override
+ public void run() {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (Settings.isForcedRegistrationEnabled) {
+ player.sendMessage(m._("reg_msg"));
+ }
+ }
+ }});
+ }
+ }
+
+ @EventHandler( priority = EventPriority.MONITOR)
+ public void onPlayerChat(AsyncPlayerChatEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+
+ final Player player = event.getPlayer();
+ final String name = player.getName().toLowerCase();
+
+ if(plugin.CitizensVersion != 0) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin)) {
+ return;
+ }
+ }
+
+ if(plugin.CombatTag != 0) {
+ if (CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+ }
+
+ if (Utils.getInstance().isUnrestricted(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ String cmd = event.getMessage().split(" ")[0];
+
+ if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
+ //System.out.println("debug chat: chat isnt allowed");
+ event.setCancelled(true);
+ return;
+ }
+
+ if (!event.isAsynchronous()) {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ player.sendMessage(m._("reg_msg"));
+ }
+ } else {
+
+ Bukkit.getScheduler().runTask(plugin, new Runnable()
+ {
+ @Override
+ public void run() {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (Settings.isForcedRegistrationEnabled) {
+ player.sendMessage(m._("reg_msg"));
+ }
+ }
+ }});
+ }
+ }
+
+ @EventHandler( priority = EventPriority.HIGHEST)
+ public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+
+ final Player player = event.getPlayer();
+ final String name = player.getName().toLowerCase();
+
+ if(plugin.CitizensVersion != 0) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin)) {
+ return;
+ }
+ }
+
+ if(plugin.CombatTag != 0) {
+ if (CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+ }
+
+ if (Utils.getInstance().isUnrestricted(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ String cmd = event.getMessage().split(" ")[0];
+
+ if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
+ //System.out.println("debug chat: chat isnt allowed");
+ event.setCancelled(true);
+ return;
+ }
+
+ if (!event.isAsynchronous()) {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ player.sendMessage(m._("reg_msg"));
+ }
+ } else {
+
+ Bukkit.getScheduler().runTask(plugin, new Runnable()
+ {
+ @Override
+ public void run() {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (Settings.isForcedRegistrationEnabled) {
+ player.sendMessage(m._("reg_msg"));
+ }
+ }
+ }});
+ }
+ }
+
+
+ @EventHandler( priority = EventPriority.LOWEST)
+ public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+
+ final Player player = event.getPlayer();
+ final String name = player.getName().toLowerCase();
+
+ if(plugin.CitizensVersion != 0) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin)) {
+ return;
+ }
+ }
+
+ if(plugin.CombatTag != 0) {
+ if (CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+ }
+
+ if (Utils.getInstance().isUnrestricted(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ String cmd = event.getMessage().split(" ")[0];
+
+ if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
+ //System.out.println("debug chat: chat isnt allowed");
+ event.setCancelled(true);
+ return;
+ }
+
+ if (!event.isAsynchronous()) {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ player.sendMessage(m._("reg_msg"));
+ }
+ } else {
+
+ Bukkit.getScheduler().runTask(plugin, new Runnable()
+ {
+ @Override
+ public void run() {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (Settings.isForcedRegistrationEnabled) {
+ player.sendMessage(m._("reg_msg"));
+ }
+ }
+ }});
+ }
+ }
+
+ @EventHandler( priority = EventPriority.LOW)
+ public void onPlayerLowChat(AsyncPlayerChatEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+
+ final Player player = event.getPlayer();
+ final String name = player.getName().toLowerCase();
+
+ if(plugin.CitizensVersion != 0) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin)) {
+ return;
+ }
+ }
+
+ if(plugin.CombatTag != 0) {
+ if (CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+ }
+
+ if (Utils.getInstance().isUnrestricted(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ String cmd = event.getMessage().split(" ")[0];
+
+ if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
+ //System.out.println("debug chat: chat isnt allowed");
+ event.setCancelled(true);
+ return;
+ }
+
+ if (!event.isAsynchronous()) {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ player.sendMessage(m._("reg_msg"));
+ }
+ } else {
+
+ Bukkit.getScheduler().runTask(plugin, new Runnable()
+ {
+ @Override
+ public void run() {
+ if (data.isAuthAvailable(name)) {
+ player.sendMessage(m._("login_msg"));
+ } else {
+ if (Settings.isForcedRegistrationEnabled) {
+ player.sendMessage(m._("reg_msg"));
+ }
+ }
+ }});
+ }
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerMove(PlayerMoveEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+
+ if (!Settings.isMovementAllowed) {
+ event.setTo(event.getFrom());
+ return;
+ }
+
+ if (Settings.getMovementRadius == 0) {
+ return;
+ }
+
+
+ int radius = Settings.getMovementRadius;
+ Location spawn = player.getWorld().getSpawnLocation();
+ if (plugin.mv != null) {
+ try {
+ spawn = plugin.mv.getMVWorldManager().getMVWorld(player.getWorld()).getSpawnLocation();
+ } catch (NullPointerException npe) {
+ } catch (ClassCastException cce) {
+ } catch (NoClassDefFoundError ncdfe) {
+ }
+ }
+
+ if ((spawn.distance(player.getLocation()) > radius) ) {
+ event.getPlayer().teleport(spawn);
+ }
+
+ }
+
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onPlayerLogin(PlayerLoginEvent event) {
+
+ final Player player = event.getPlayer();
+ final String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("same_nick"));
+ return;
+ }
+
+ if(!event.isAsynchronous()) {
+ if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
+ if(!Settings.isSessionsEnabled) {
+ LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
+ } else if(PlayerCache.getInstance().isAuthenticated(name)) {
+ if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
+ LimboCache.getInstance().deleteLimboPlayer(name);
+ }
+ LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
+ }
+ }
+ } else {
+ Bukkit.getScheduler().runTask(plugin, new Runnable() {
+
+ @Override
+ public void run() {
+ if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
+ if(!Settings.isSessionsEnabled) {
+ LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
+ } else if(PlayerCache.getInstance().isAuthenticated(name)) {
+ if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
+ LimboCache.getInstance().deleteLimboPlayer(name);
+ }
+ LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
+ }
+ }
+
+ }
+
+ });
+ }
+
+ //Check if forceSingleSession is set to true, so kick player that has joined with same nick of online player
+ if(player.isOnline() && Settings.isForceSingleSessionEnabled ) {
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
+ //System.out.println(" limbo ? "+limbo.getGroup());
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("same_nick"));
+ if(PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ utils.addNormal(player, limbo.getGroup());
+ LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
+ }
+ return;
+
+ }
+
+ int min = Settings.getMinNickLength;
+ int max = Settings.getMaxNickLength;
+ String regex = Settings.getNickRegex;
+
+ if (name.length() > max || name.length() < min) {
+
+ event.disallow(Result.KICK_OTHER, m._("name_len"));
+ return;
+ }
+ if (!player.getName().matches(regex) || name.equals("Player")) {
+ try {
+ event.disallow(Result.KICK_OTHER, m._("regex").replaceAll("REG_EX", regex));
+ } catch (StringIndexOutOfBoundsException exc) {
+ event.disallow(Result.KICK_OTHER, "allowed char : " + regex);
+ }
+ return;
+ }
+
+ if (Settings.isKickNonRegisteredEnabled) {
+ if (!data.isAuthAvailable(name)) {
+ event.disallow(Result.KICK_OTHER, m._("reg_only"));
+ return;
+ }
+ }
+ }
+
+
+ @EventHandler(priority = EventPriority.HIGHEST)
+ public void onPlayerJoin(PlayerJoinEvent event) {
+ if (event.getPlayer() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ World world = player.getWorld();
+ Location spawnLoc = world.getSpawnLocation();
+ gm = player.getGameMode().getValue();
+ final String name = player.getName().toLowerCase();
+ gameMode.put(name, gm);
+ BukkitScheduler sched = plugin.getServer().getScheduler();
+ final PlayerJoinEvent e = event;
+
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ String ip = player.getAddress().getAddress().getHostAddress();
+ if (Settings.bungee && player instanceof ProxiedPlayer) {
+ ProxiedPlayer pPlayer = (ProxiedPlayer) player;
+ ip = pPlayer.getAddress().getAddress().getHostAddress();
+ } else if (Settings.bungee && player instanceof ConnectedPlayer) {
+ ConnectedPlayer cPlayer = (ConnectedPlayer) player;
+ ip = cPlayer.getAddress().getAddress().getHostAddress();
+ }
+ if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
+ int gM = gameMode.get(name);
+ player.setGameMode(GameMode.getByValue(gM));
+ player.kickPlayer("You are not the Owner of this account, please try another name!");
+ if (Settings.banUnsafeIp)
+ plugin.getServer().banIP(ip);
+ return;
+ }
+
+ if (data.isAuthAvailable(name)) {
+
+
+ if (Settings.isSessionsEnabled) {
+ PlayerAuth auth = data.getAuth(name);
+ long timeout = Settings.getSessionTimeout * 60000;
+ long lastLogin = auth.getLastLogin();
+ long cur = new Date().getTime();
+
+
+ if((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1") ) {
+ if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip) ) {
+ Bukkit.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
+ if(PlayerCache.getInstance().getAuth(name) != null) {
+ PlayerCache.getInstance().updatePlayer(auth);
+ } else {
+ PlayerCache.getInstance().addPlayer(auth);
+ }
+ player.sendMessage(m._("valid_session"));
+ return;
+ } else {
+ int gM = gameMode.get(name);
+ player.setGameMode(GameMode.getByValue(gM));
+ player.kickPlayer(m._("unvalid_session"));
+ return;
+ }
+ } else {
+
+ PlayerCache.getInstance().removePlayer(name);
+ LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
+ }
+ }
+ // isent in session or session was ended correctly
+ LimboCache.getInstance().addLimboPlayer(player);
+
+ try {
+ playerBackup.createCache(name, new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour()), LimboCache.getInstance().getLimboPlayer(name).getGroup(),LimboCache.getInstance().getLimboPlayer(name).getOperator());
+ } catch (NullPointerException npe) {
+ ConsoleLogger.showError("Problem while trying to create player cache for : " + name);
+ }
+
+ } else {
+ if(!Settings.unRegisteredGroup.isEmpty()){
+ utils.setGroup(player, Utils.groupType.UNREGISTERED);
+ }
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+
+
+ if(Settings.protectInventoryBeforeLogInEnabled) {
+ try {
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
+ ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour(), 36, 4);
+ Bukkit.getServer().getPluginManager().callEvent(ev);
+ if (ev.isCancelled()) {
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
+ }
+ } catch (NullPointerException ex) {
+ }
+ }
+
+ if(player.isOp())
+ player.setOp(false);
+
+ if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
+ SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
+ if(!tpEvent.isCancelled()) {
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
+ }
+ player.teleport(tpEvent.getTo());
+ }
+ }
+
+
+ String msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_msg");
+ int time = Settings.getRegistrationTimeout * 20;
+ int msgInterval = Settings.getWarnMessageInterval;
+ if (time != 0) {
+
+ BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name), time);
+ if(!LimboCache.getInstance().hasLimboPlayer(name))
+ LimboCache.getInstance().addLimboPlayer(player);
+
+ LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id.getTaskId());
+ }
+
+ if(!LimboCache.getInstance().hasLimboPlayer(name))
+ LimboCache.getInstance().addLimboPlayer(player);
+ BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
+ LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT.getTaskId());
+
+ if (Settings.isForceSurvivalModeEnabled)
+ sched.runTask(plugin, new Runnable() {
+ public void run() {
+ e.getPlayer().setGameMode(GameMode.SURVIVAL);
+ }
+ });
+ }
+
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerQuit(PlayerQuitEvent event) {
+ if (event.getPlayer() == null) {
+ return;
+ }
+
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
+ if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
+ PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),(int)player.getLocation().getX(),(int)player.getLocation().getY(),(int)player.getLocation().getZ());
+ try {
+ data.updateQuitLoc(auth);
+ } catch (NullPointerException npe) { }
+
+ }
+ }
+
+ if (LimboCache.getInstance().hasLimboPlayer(name)) {
+ //System.out.println("e' nel quit");
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
+ if(Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
+ RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
+ Bukkit.getServer().getPluginManager().callEvent(ev);
+ if (!ev.isCancelled()) {
+ API.setPlayerInventory(player, limbo.getInventory(), limbo.getArmour());
+ }
+ }
+ utils.addNormal(player, limbo.getGroup());
+ player.setOp(limbo.getOperator());
+ //System.out.println("debug quit group reset "+limbo.getGroup());
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
+ LimboCache.getInstance().deleteLimboPlayer(name);
+ if(playerBackup.doesCacheExist(name)) {
+ playerBackup.removeCache(name);
+ }
+ }
+ try {
+ PlayerCache.getInstance().removePlayer(name);
+ } catch (NullPointerException npe) {
+
+ }
+ try {
+ PlayersLogs.players.remove(player.getName());
+ PlayersLogs.getInstance().save();
+ } catch (NullPointerException ex) {
+
+ }
+ if (gameMode.containsKey(name)) gameMode.remove(name);
+ player.saveData();
+ }
+
+ @EventHandler(priority=EventPriority.MONITOR)
+ public void onPlayerKick(PlayerKickEvent event) {
+ if (event.getPlayer() == null) {
+ return;
+ }
+ if (event.isCancelled()) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+
+ if ((plugin.getCitizensCommunicator().isNPC(player, plugin)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
+ return;
+ }
+
+ if ((Settings.isForceSingleSessionEnabled) &&
+ (event.getReason().contains("You logged in from another location"))) {
+ event.setCancelled(true);
+ return;
+ }
+
+ String name = player.getName().toLowerCase();
+ if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) &&
+ (Settings.isSaveQuitLocationEnabled.booleanValue()) && data.isAuthAvailable(name)) {
+ PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), (int)player.getLocation().getX(), (int)player.getLocation().getY(), (int)player.getLocation().getZ());
+ this.data.updateQuitLoc(auth);
+ }
+
+ if (LimboCache.getInstance().hasLimboPlayer(name))
+ {
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
+ if (Settings.protectInventoryBeforeLogInEnabled.booleanValue()) {
+ try {
+ RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
+ Bukkit.getServer().getPluginManager().callEvent(ev);
+ if (!ev.isCancelled()) {
+ API.setPlayerInventory(player, ev.getInventory(), ev.getArmor());
+ }
+ } catch (NullPointerException npe){
+ ConsoleLogger.showError("Problem while restore " + name + "inventory after a kick");
+ }
+ }
+ try {
+ AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
+ if(!tpEvent.isCancelled()) {
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
+ }
+ player.teleport(tpEvent.getTo());
+ }
+ } catch (NullPointerException npe) {
+
+ }
+ this.utils.addNormal(player, limbo.getGroup());
+ player.setOp(limbo.getOperator());
+
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
+ LimboCache.getInstance().deleteLimboPlayer(name);
+ if (this.playerBackup.doesCacheExist(name)) {
+ this.playerBackup.removeCache(name);
+ }
+ }
+ try {
+ PlayerCache.getInstance().removePlayer(name);
+ PlayersLogs.players.remove(player.getName());
+ PlayersLogs.getInstance().save();
+ if (gameMode.containsKey(name)) gameMode.remove(name);
+ player.saveData();
+ } catch (NullPointerException ex) {}
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerPickupItem(PlayerPickupItemEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+
+ final int sign = event.getClickedBlock().getTypeId();
+ if (sign == Material.SIGN_POST.getId() || sign == Material.WALL_SIGN.getId()) {
+ event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
+ }
+
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerDropItem(PlayerDropItemEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+ //System.out.println("player try to drop item");
+
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerBedEnter(PlayerBedEnterEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null) {
+ return;
+ }
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+ event.setCancelled(true);
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onSignChange(SignChangeEvent event) {
+ if (event.isCancelled() || event.getPlayer() == null || event == null) {
+ return;
+ }
+ Player player = event.getPlayer();
+ String name = player.getName().toLowerCase();
+
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
+ return;
+ }
+
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ if (!data.isAuthAvailable(name)) {
+ if (!Settings.isForcedRegistrationEnabled) {
+ return;
+ }
+ }
+ event.setCancelled(true);
+
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/uk/org/whoami/authme/listener/AuthMeSpoutListener.java b/src/main/java/uk/org/whoami/authme/listener/AuthMeSpoutListener.java
new file mode 100644
index 00000000..1357ce6c
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/listener/AuthMeSpoutListener.java
@@ -0,0 +1,35 @@
+package uk.org.whoami.authme.listener;
+
+/**
+ * @Author Hoezef
+ */
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
+
+
+import uk.org.whoami.authme.cache.auth.PlayerCache;
+import uk.org.whoami.authme.datasource.DataSource;
+import uk.org.whoami.authme.gui.screens.LoginScreen;
+import uk.org.whoami.authme.settings.SpoutCfg;
+
+public class AuthMeSpoutListener implements Listener {
+ private DataSource data;
+
+
+ public AuthMeSpoutListener(DataSource data) {
+
+ this.data = data;
+ }
+
+ @EventHandler
+ public void onSpoutCraftEnable(final SpoutCraftEnableEvent event)
+ {
+ if(SpoutCfg.getInstance().getBoolean("LoginScreen.enabled")) {
+ if (data.isAuthAvailable(event.getPlayer().getName().toLowerCase()) && !PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase()) ) {
+ event.getPlayer().getMainScreen().attachPopupScreen(new LoginScreen(event.getPlayer()));
+ }
+ }
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/plugin/manager/CitizensCommunicator.java b/src/main/java/uk/org/whoami/authme/plugin/manager/CitizensCommunicator.java
new file mode 100644
index 00000000..81fe7a60
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/plugin/manager/CitizensCommunicator.java
@@ -0,0 +1,27 @@
+package uk.org.whoami.authme.plugin.manager;
+
+import net.citizensnpcs.api.CitizensAPI;
+import net.citizensnpcs.api.CitizensManager;
+
+import org.bukkit.entity.Entity;
+
+import uk.org.whoami.authme.AuthMe;
+
+public class CitizensCommunicator {
+
+ public AuthMe instance;
+
+ public CitizensCommunicator(AuthMe instance) {
+ this.instance = instance;
+ }
+
+ public boolean isNPC(final Entity player, AuthMe instance) {
+ if (instance.CitizensVersion == 1) {
+ return CitizensManager.isNPC(player);
+ } else if (instance.CitizensVersion == 2) {
+ return CitizensAPI.getNPCRegistry().isNPC(player);
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/plugin/manager/CombatTagComunicator.java b/src/main/java/uk/org/whoami/authme/plugin/manager/CombatTagComunicator.java
new file mode 100644
index 00000000..dafa9b3a
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/plugin/manager/CombatTagComunicator.java
@@ -0,0 +1,72 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package uk.org.whoami.authme.plugin.manager;
+
+import com.trc202.CombatTag.CombatTag;
+import com.trc202.CombatTagApi.CombatTagApi;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+
+/**
+ *
+ * @author stefano
+ */
+public abstract class CombatTagComunicator {
+ static CombatTagApi combatApi;
+
+ public CombatTagComunicator() {
+ if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
+ combatApi = new CombatTagApi((CombatTag)Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
+ }
+ }
+ /**
+ * Checks to see if the player is in combat. The combat time can be configured by the server owner
+ * If the player has died while in combat the player is no longer considered in combat and as such will return false
+ * @param playerName
+ * @return true if player is in combat
+ */
+ public abstract boolean isInCombat(String player);
+
+ /**
+ * Checks to see if the player is in combat. The combat time can be configured by the server owner
+ * If the player has died while in combat the player is no longer considered in combat and as such will return false
+ * @param player
+ * @return true if player is in combat
+ */
+ public abstract boolean isInCombat(Player player);
+
+ /**
+ * Returns the time before the tag is over
+ * -1 if the tag has expired
+ * -2 if the player is not in combat
+ * @param player
+ * @return
+ */
+ public abstract long getRemainingTagTime(String player);
+
+ //(Implemented in 3.8)
+ /**
+ * Returns if the entity is an NPC
+ * @param player
+ * @return true if the player is an NPC
+ */
+ public static boolean isNPC(Entity player) {
+ try {
+ if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
+ combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
+ return combatApi.isNPC(player);
+ }
+ } catch (ClassCastException ex) {
+ return false;
+ } catch (NullPointerException npe) {
+ return false;
+ } catch (NoClassDefFoundError ncdfe) {
+ return false;
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/security/PasswordSecurity.java b/src/main/java/uk/org/whoami/authme/security/PasswordSecurity.java
new file mode 100644
index 00000000..efea449a
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/security/PasswordSecurity.java
@@ -0,0 +1,318 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.security;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.HashMap;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+import uk.org.whoami.authme.AuthMe;
+import uk.org.whoami.authme.settings.Settings;
+
+public class PasswordSecurity {
+
+ private static SecureRandom rnd = new SecureRandom();
+ public static HashMap userSalt = new HashMap();
+
+ private static String getMD5(String message) throws NoSuchAlgorithmException {
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
+
+ md5.reset();
+ md5.update(message.getBytes());
+ byte[] digest = md5.digest();
+
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,
+ digest));
+ }
+
+ private static String getSHA1(String message) throws NoSuchAlgorithmException {
+ MessageDigest sha1 = MessageDigest.getInstance("SHA1");
+ sha1.reset();
+ sha1.update(message.getBytes());
+ byte[] digest = sha1.digest();
+
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,
+ digest));
+ }
+
+ private static String getSHA256(String message) throws NoSuchAlgorithmException {
+ MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
+
+ sha256.reset();
+ sha256.update(message.getBytes());
+ byte[] digest = sha256.digest();
+
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,
+ digest));
+ }
+
+ public static String getWhirlpool(String message) {
+ Whirlpool w = new Whirlpool();
+ byte[] digest = new byte[Whirlpool.DIGESTBYTES];
+ w.NESSIEinit();
+ w.NESSIEadd(message);
+ w.NESSIEfinalize(digest);
+ return Whirlpool.display(digest);
+ }
+
+ private static String getSaltedHash(String message, String salt) throws NoSuchAlgorithmException {
+ return "$SHA$" + salt + "$" + getSHA256(getSHA256(message) + salt);
+ }
+
+ //
+ // VBULLETIN 3.X 4.X METHOD
+ //
+
+ private static String getSaltedMd5(String message, String salt) throws NoSuchAlgorithmException {
+ return "$MD5vb$" + salt + "$" + getMD5(getMD5(message) + salt);
+ }
+
+ private static String getSaltedMyBB(String message, String salt) throws NoSuchAlgorithmException {
+ return getMD5(getMD5(salt)+ getMD5(message));
+ }
+
+ private static String getXAuth(String message, String salt) {
+ String hash = getWhirlpool(salt + message).toLowerCase();
+ int saltPos = (message.length() >= hash.length() ? hash.length() - 1 : message.length());
+ return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
+ }
+
+ private static String getSaltedIPB3(String message, String salt) throws NoSuchAlgorithmException {
+
+ return getMD5(getMD5(salt) + getMD5(message));
+
+ }
+
+ private static String createSalt(int length) throws NoSuchAlgorithmException {
+ byte[] msg = new byte[40];
+ rnd.nextBytes(msg);
+
+ MessageDigest sha1 = MessageDigest.getInstance("SHA1");
+ sha1.reset();
+ byte[] digest = sha1.digest(msg);
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest)).substring(0, length);
+ }
+
+ public static String getHash(HashAlgorithm alg, String password, String name) throws NoSuchAlgorithmException {
+ switch (alg) {
+ case MD5:
+ return getMD5(password);
+ case SHA1:
+ return getSHA1(password);
+ case SHA256:
+ String salt = createSalt(16);
+ return getSaltedHash(password, salt);
+ case MD5VB:
+ String salt2 = createSalt(16);
+ return getSaltedMd5(password, salt2);
+ case WHIRLPOOL:
+ return getWhirlpool(password);
+ case XAUTH:
+ String xsalt = createSalt(12);
+ return getXAuth(password, xsalt);
+ case PHPBB:
+ return getPhpBB(password);
+ case PLAINTEXT:
+ return getPlainText(password);
+ case MYBB:
+ String salt3 = "";
+ try {
+ salt3 = AuthMe.getInstance().database.getAuth(name).getSalt();
+ } catch (NullPointerException npe) {
+ }
+ if (salt3.isEmpty() || salt3 == null) {
+ salt3 = createSalt(8);
+ userSalt.put(name, salt3);
+ }
+ return getSaltedMyBB(password, salt3);
+ case IPB3:
+ String salt4 = "";
+ try {
+ salt4 = AuthMe.getInstance().database.getAuth(name).getSalt();
+ } catch (NullPointerException npe) {
+ }
+ if (salt4.isEmpty() || salt4 == null) {
+ salt4 = createSalt(5);
+ userSalt.put(name, salt4);
+ }
+ return getSaltedIPB3(password, salt4);
+ case PHPFUSION:
+ String salt5 = "";
+ try {
+ salt5 = AuthMe.getInstance().database.getAuth(name).getSalt();
+ } catch (NullPointerException npe) {
+ }
+ if (salt5.isEmpty() || salt5 == null) {
+ salt5 = createSalt(12);
+ userSalt.put(name, getSHA1(salt5));
+ }
+ return getPhPFusion(password, getSHA1(salt5));
+ case SMF:
+ return getSHA1(name.toLowerCase() + password);
+ case XFSHA1:
+ return getSHA1(getSHA1(password) + Settings.getPredefinedSalt);
+ case XFSHA256:
+ return getSHA256(getSHA256(password) + Settings.getPredefinedSalt);
+ case SALTED2MD5:
+ String salt6 = "";
+ try {
+ salt6 = AuthMe.getInstance().database.getAuth(name).getSalt();
+ } catch (NullPointerException npe) {
+ }
+ if (salt6.isEmpty() || salt6 == null) {
+ salt6 = createSalt(Settings.saltLength);
+ userSalt.put(name, salt6);
+ }
+ return getMD5(getMD5(password) + salt6);
+ case JOOMLA:
+ String saltj = "";
+ try {
+ saltj = AuthMe.getInstance().database.getAuth(name).getHash().split(":")[1];
+ } catch (NullPointerException npe) {
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ }
+ if (saltj.isEmpty() || saltj == null) {
+ saltj = createSalt(32);
+ userSalt.put(name, saltj);
+ }
+ return getMD5(password + saltj) + ":" + saltj;
+ default:
+ throw new NoSuchAlgorithmException("Unknown hash algorithm");
+ }
+ }
+
+ public static boolean comparePasswordWithHash(String password, String hash, String playername) throws NoSuchAlgorithmException {
+ //System.out.println("[Authme Debug] debug hashString"+hash);
+ if(hash.contains("$H$")) {
+ PhpBB checkHash = new PhpBB();
+ return checkHash.phpbb_check_hash(password, hash);
+ }
+ if(!Settings.getMySQLColumnSalt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.IPB3) {
+ String saltipb = AuthMe.getInstance().database.getAuth(playername).getSalt();
+ return hash.equals(getSaltedIPB3(password, saltipb));
+ }
+ if(!Settings.getMySQLColumnSalt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.PHPFUSION) {
+ String saltfusion = AuthMe.getInstance().database.getAuth(playername).getSalt();
+ return hash.equals(getPhPFusion(password, saltfusion));
+ }
+ if(!Settings.getMySQLColumnSalt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MYBB) {
+ String saltmybb = AuthMe.getInstance().database.getAuth(playername).getSalt();
+ return hash.equals(getSaltedMyBB(password, saltmybb));
+ }
+ if(Settings.getPasswordHash == HashAlgorithm.SMF) {
+ return hash.equals(getSHA1(playername.toLowerCase() + password));
+ }
+ if(Settings.getPasswordHash == HashAlgorithm.XFSHA1) {
+ return hash.equals(getSHA1(getSHA1(password) + Settings.getPredefinedSalt));
+ }
+ if(Settings.getPasswordHash == HashAlgorithm.XFSHA256) {
+ return hash.equals(getSHA256(getSHA256(password)+ Settings.getPredefinedSalt));
+ }
+ if(!Settings.getMySQLColumnSalt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.SALTED2MD5) {
+ String salt2md5 = AuthMe.getInstance().database.getAuth(playername).getSalt();
+ return hash.equals(getMD5(getMD5(password) + salt2md5));
+ }
+ if(Settings.getPasswordHash == HashAlgorithm.JOOMLA) {
+ String saltj = hash.split(":")[1];
+ return hash.equals(getMD5(password + saltj) + ":" + saltj);
+ }
+ // PlainText Password
+ if(hash.length() < 32 ) {
+ return hash.equals(password);
+ }
+
+ if (hash.length() == 32) {
+ return hash.equals(getMD5(password));
+ }
+
+ if (hash.length() == 40) {
+ return hash.equals(getSHA1(password));
+ }
+
+ if (hash.length() == 140) {
+ int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
+ String salt = hash.substring(saltPos, saltPos + 12);
+ return hash.equals(getXAuth(password, salt));
+ }
+
+ if (hash.contains("$")) {
+ //System.out.println("[Authme Debug] debug hashString"+hash);
+ String[] line = hash.split("\\$");
+ if (line.length > 3 && line[1].equals("SHA")) {
+ return hash.equals(getSaltedHash(password, line[2]));
+ } else {
+ if(line[1].equals("MD5vb")) {
+ //System.out.println("[Authme Debug] password hashed from Authme"+getSaltedMd5(password, line[2]));
+ //System.out.println("[Authme Debug] salt from Authme"+line[2]);
+ //System.out.println("[Authme Debug] equals? Authme: "+hash);
+ //hash = "$MD5vb$" + salt + "$" + hash;
+ return hash.equals(getSaltedMd5(password, line[2]));
+ }
+ }
+ }
+ return false;
+ }
+
+ private static String getPhpBB(String password) {
+ PhpBB hash = new PhpBB();
+ String phpBBhash = hash.phpbb_hash(password);
+ return phpBBhash;
+ }
+
+
+ private static String getPlainText(String password) {
+ return password;
+ }
+
+ public static String getPhPFusion(String msg, String keyString) {
+ String digest = null;
+ String algo = "HmacSHA256";
+ try {
+ SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo);
+ Mac mac = Mac.getInstance(algo);
+ mac.init(key);
+
+ byte[] bytes = mac.doFinal(msg.getBytes("ASCII"));
+
+ StringBuffer hash = new StringBuffer();
+ for (int i = 0; i < bytes.length; i++) {
+ String hex = Integer.toHexString(0xFF & bytes[i]);
+ if (hex.length() == 1) {
+ hash.append('0');
+ }
+ hash.append(hex);
+ }
+ digest = hash.toString();
+ } catch (UnsupportedEncodingException e) {
+ } catch (InvalidKeyException e) {
+ } catch (NoSuchAlgorithmException e) {
+ }
+ return digest;
+ }
+
+ public enum HashAlgorithm {
+
+ MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, PLAINTEXT, MYBB, IPB3, PHPFUSION, SMF, XFSHA1, XFSHA256, SALTED2MD5, JOOMLA
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/security/PhpBB.java b/src/main/java/uk/org/whoami/authme/security/PhpBB.java
new file mode 100644
index 00000000..82f975e6
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/security/PhpBB.java
@@ -0,0 +1,191 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package uk.org.whoami.authme.security;
+
+import java.io.UnsupportedEncodingException;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+
+/**
+ *
+ * @author stefano
+ */
+public class PhpBB {
+ private static final int PHP_VERSION = 4;
+ private String itoa64 =
+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+
+ public String phpbb_hash(String password) {
+ String random_state = unique_id();
+ String random = "";
+ int count = 6;
+
+ if (random.length() < count) {
+ random = "";
+
+ for (int i = 0; i < count; i += 16) {
+ random_state = md5(unique_id() + random_state);
+ random += pack(md5(random_state));
+ }
+ random = random.substring(0, count);
+ }
+
+ String hash = _hash_crypt_private(
+ password, _hash_gensalt_private(random, itoa64));
+ if (hash.length() == 34)
+ return hash;
+
+ return md5(password);
+ }
+
+ private String unique_id() {
+ return unique_id("c");
+ }
+
+ // global $config;
+ // private boolean dss_seeded = false;
+
+ private String unique_id(String extra) {
+ // TODO Generate something random here.
+ return "1234567890abcdef";
+ }
+
+
+ private String _hash_gensalt_private(String input, String itoa64) {
+ return _hash_gensalt_private(input, itoa64, 6);
+ }
+
+ @SuppressWarnings("unused")
+private String _hash_gensalt_private(
+ String input, String itoa64, int iteration_count_log2) {
+ if (iteration_count_log2 < 4 || iteration_count_log2 > 31) {
+ iteration_count_log2 = 8;
+ }
+
+ String output = "$H$";
+ output += itoa64.charAt(
+ Math.min(iteration_count_log2 +
+ ((PHP_VERSION >= 5) ? 5 : 3), 30));
+ output += _hash_encode64(input, 6);
+
+ return output;
+ }
+
+ /**
+ * Encode hash
+ */
+ private String _hash_encode64(String input, int count) {
+ String output = "";
+ int i = 0;
+
+ do {
+ int value = input.charAt(i++);
+ output += itoa64.charAt(value & 0x3f);
+
+ if (i < count)
+ value |= input.charAt(i) << 8;
+
+ output += itoa64.charAt((value >> 6) & 0x3f);
+
+ if (i++ >= count)
+ break;
+
+ if (i < count)
+ value |= input.charAt(i) << 16;
+
+ output += itoa64.charAt((value >> 12) & 0x3f);
+
+ if (i++ >= count)
+ break;
+
+ output += itoa64.charAt((value >> 18) & 0x3f);
+ } while (i < count);
+
+ return output;
+ }
+
+ String _hash_crypt_private(String password, String setting) {
+ String output = "*";
+
+ // Check for correct hash
+ if (!setting.substring(0, 3).equals("$H$"))
+ return output;
+
+ int count_log2 = itoa64.indexOf(setting.charAt(3));
+ if (count_log2 < 7 || count_log2 > 30)
+ return output;
+
+ int count = 1 << count_log2;
+ String salt = setting.substring(4, 12);
+ if (salt.length() != 8)
+ return output;
+
+ String m1 = md5(salt + password);
+ String hash = pack(m1);
+ do {
+ hash = pack(md5(hash + password));
+ } while (--count > 0);
+
+ output = setting.substring(0, 12);
+ output += _hash_encode64(hash, 16);
+
+ return output;
+ }
+
+ public boolean phpbb_check_hash( String password, String hash) {
+ if (hash.length() == 34)
+ return _hash_crypt_private(password, hash).equals(hash);
+ else
+ return md5(password).equals(hash);
+ }
+
+ public static String md5(String data) {
+ try {
+ byte[] bytes = data.getBytes("ISO-8859-1");
+ MessageDigest md5er = MessageDigest.getInstance("MD5");
+ byte[] hash = md5er.digest(bytes);
+ return bytes2hex(hash);
+ } catch (GeneralSecurityException e) {
+ throw new RuntimeException(e);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ static int hexToInt(char ch) {
+ if(ch >= '0' && ch <= '9')
+ return ch - '0';
+
+ ch = Character.toUpperCase(ch);
+ if(ch >= 'A' && ch <= 'F')
+ return ch - 'A' + 0xA;
+
+ throw new IllegalArgumentException("Not a hex character: " + ch);
+ }
+
+ private static String bytes2hex(byte[] bytes) {
+ StringBuffer r = new StringBuffer(32);
+ for (int i = 0; i < bytes.length; i++) {
+ String x = Integer.toHexString(bytes[i] & 0xff);
+ if (x.length() < 2)
+ r.append("0");
+ r.append(x);
+ }
+ return r.toString();
+ }
+
+ static String pack(String hex) {
+ StringBuffer buf = new StringBuffer();
+ for(int i = 0; i < hex.length(); i += 2) {
+ char c1 = hex.charAt(i);
+ char c2 = hex.charAt(i+1);
+ char packed = (char) (hexToInt(c1) * 16 + hexToInt(c2));
+ buf.append(packed);
+ }
+ return buf.toString();
+ }
+}
+
diff --git a/src/main/java/uk/org/whoami/authme/security/RandomString.java b/src/main/java/uk/org/whoami/authme/security/RandomString.java
new file mode 100644
index 00000000..e599d8e6
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/security/RandomString.java
@@ -0,0 +1,35 @@
+package uk.org.whoami.authme.security;
+
+import java.util.Random;
+
+public class RandomString
+{
+
+ private static final char[] symbols = new char[36];
+
+ static {
+ for (int idx = 0; idx < 10; ++idx)
+ symbols[idx] = (char) ('0' + idx);
+ for (int idx = 10; idx < 36; ++idx)
+ symbols[idx] = (char) ('a' + idx - 10);
+ }
+
+ private final Random random = new Random();
+
+ private final char[] buf;
+
+ public RandomString(int length)
+ {
+ if (length < 1)
+ throw new IllegalArgumentException("length < 1: " + length);
+ buf = new char[length];
+ }
+
+ public String nextString()
+ {
+ for (int idx = 0; idx < buf.length; ++idx)
+ buf[idx] = symbols[random.nextInt(symbols.length)];
+ return new String(buf);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/uk/org/whoami/authme/security/Whirlpool.java b/src/main/java/uk/org/whoami/authme/security/Whirlpool.java
new file mode 100644
index 00000000..01201c5b
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/security/Whirlpool.java
@@ -0,0 +1,440 @@
+package uk.org.whoami.authme.security;
+
+/**
+ * The Whirlpool hashing function.
+ *
+ *
+ * References
+ *
+ *
+ * The Whirlpool algorithm was developed by
+ * Paulo S. L. M. Barreto and
+ * Vincent Rijmen.
+ *
+ * See
+ * P.S.L.M. Barreto, V. Rijmen,
+ * ``The Whirlpool hashing function,''
+ * First NESSIE workshop, 2000 (tweaked version, 2003),
+ *
+ *
+ * @author Paulo S.L.M. Barreto
+ * @author Vincent Rijmen.
+ *
+ * @version 3.0 (2003.03.12)
+ *
+ * =============================================================================
+ *
+ * Differences from version 2.1:
+ *
+ * - Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2, 9).
+ *
+ * =============================================================================
+ *
+ * Differences from version 2.0:
+ *
+ * - Generation of ISO/IEC 10118-3 test vectors.
+ * - Bug fix: nonzero carry was ignored when tallying the data length
+ * (this bug apparently only manifested itself when feeding data
+ * in pieces rather than in a single chunk at once).
+ *
+ * Differences from version 1.0:
+ *
+ * - Original S-box replaced by the tweaked, hardware-efficient version.
+ *
+ * =============================================================================
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import java.util.Arrays;
+
+class Whirlpool {
+
+ /**
+ * The message digest size (in bits)
+ */
+ public static final int DIGESTBITS = 512;
+
+ /**
+ * The message digest size (in bytes)
+ */
+ public static final int DIGESTBYTES = DIGESTBITS >>> 3;
+
+ /**
+ * The number of rounds of the internal dedicated block cipher.
+ */
+ protected static final int R = 10;
+
+ /**
+ * The substitution box.
+ */
+ private static final String sbox =
+ "\u1823\uc6E8\u87B8\u014F\u36A6\ud2F5\u796F\u9152" +
+ "\u60Bc\u9B8E\uA30c\u7B35\u1dE0\ud7c2\u2E4B\uFE57" +
+ "\u1577\u37E5\u9FF0\u4AdA\u58c9\u290A\uB1A0\u6B85" +
+ "\uBd5d\u10F4\ucB3E\u0567\uE427\u418B\uA77d\u95d8" +
+ "\uFBEE\u7c66\udd17\u479E\ucA2d\uBF07\uAd5A\u8333" +
+ "\u6302\uAA71\uc819\u49d9\uF2E3\u5B88\u9A26\u32B0" +
+ "\uE90F\ud580\uBEcd\u3448\uFF7A\u905F\u2068\u1AAE" +
+ "\uB454\u9322\u64F1\u7312\u4008\uc3Ec\udBA1\u8d3d" +
+ "\u9700\ucF2B\u7682\ud61B\uB5AF\u6A50\u45F3\u30EF" +
+ "\u3F55\uA2EA\u65BA\u2Fc0\udE1c\uFd4d\u9275\u068A" +
+ "\uB2E6\u0E1F\u62d4\uA896\uF9c5\u2559\u8472\u394c" +
+ "\u5E78\u388c\ud1A5\uE261\uB321\u9c1E\u43c7\uFc04" +
+ "\u5199\u6d0d\uFAdF\u7E24\u3BAB\ucE11\u8F4E\uB7EB" +
+ "\u3c81\u94F7\uB913\u2cd3\uE76E\uc403\u5644\u7FA9" +
+ "\u2ABB\uc153\udc0B\u9d6c\u3174\uF646\uAc89\u14E1" +
+ "\u163A\u6909\u70B6\ud0Ed\ucc42\u98A4\u285c\uF886";
+
+ private static long[][] C = new long[8][256];
+ private static long[] rc = new long[R + 1];
+
+ static {
+ for (int x = 0; x < 256; x++) {
+ char c = sbox.charAt(x/2);
+ long v1 = ((x & 1) == 0) ? c >>> 8 : c & 0xff;
+ long v2 = v1 << 1;
+ if (v2 >= 0x100L) {
+ v2 ^= 0x11dL;
+ }
+ long v4 = v2 << 1;
+ if (v4 >= 0x100L) {
+ v4 ^= 0x11dL;
+ }
+ long v5 = v4 ^ v1;
+ long v8 = v4 << 1;
+ if (v8 >= 0x100L) {
+ v8 ^= 0x11dL;
+ }
+ long v9 = v8 ^ v1;
+ /*
+ * build the circulant table C[0][x] = S[x].[1, 1, 4, 1, 8, 5, 2, 9]:
+ */
+ C[0][x] =
+ (v1 << 56) | (v1 << 48) | (v4 << 40) | (v1 << 32) |
+ (v8 << 24) | (v5 << 16) | (v2 << 8) | (v9 );
+ /*
+ * build the remaining circulant tables C[t][x] = C[0][x] rotr t
+ */
+ for (int t = 1; t < 8; t++) {
+ C[t][x] = (C[t - 1][x] >>> 8) | ((C[t - 1][x] << 56));
+ }
+ }
+ /*
+ for (int t = 0; t < 8; t++) {
+ System.out.println("static const u64 C" + t + "[256] = {");
+ for (int i = 0; i < 64; i++) {
+ System.out.print(" ");
+ for (int j = 0; j < 4; j++) {
+ String v = Long.toHexString(C[t][4*i + j]);
+ while (v.length() < 16) {
+ v = "0" + v;
+ }
+ System.out.print(" LL(0x" + v + "),");
+ }
+ System.out.println();
+ }
+ System.out.println("};");
+ System.out.println();
+ }
+ System.out.println();
+ //*/
+
+ /*
+ * build the round constants:
+ */
+ rc[0] = 0L; /* not used (assigment kept only to properly initialize all variables) */
+ for (int r = 1; r <= R; r++) {
+ int i = 8*(r - 1);
+ rc[r] =
+ (C[0][i ] & 0xff00000000000000L) ^
+ (C[1][i + 1] & 0x00ff000000000000L) ^
+ (C[2][i + 2] & 0x0000ff0000000000L) ^
+ (C[3][i + 3] & 0x000000ff00000000L) ^
+ (C[4][i + 4] & 0x00000000ff000000L) ^
+ (C[5][i + 5] & 0x0000000000ff0000L) ^
+ (C[6][i + 6] & 0x000000000000ff00L) ^
+ (C[7][i + 7] & 0x00000000000000ffL);
+ }
+ /*
+ System.out.println("static const u64 rc[R + 1] = {");
+ for (int r = 0; r <= R; r++) {
+ String v = Long.toHexString(rc[r]);
+ while (v.length() < 16) {
+ v = "0" + v;
+ }
+ System.out.println(" LL(0x" + v + "),");
+ }
+ System.out.println("};");
+ System.out.println();
+ //*/
+ }
+
+ /**
+ * Global number of hashed bits (256-bit counter).
+ */
+ protected byte[] bitLength = new byte[32];
+
+ /**
+ * Buffer of data to hash.
+ */
+ protected byte[] buffer = new byte[64];
+
+ /**
+ * Current number of bits on the buffer.
+ */
+ protected int bufferBits = 0;
+
+ /**
+ * Current (possibly incomplete) byte slot on the buffer.
+ */
+ protected int bufferPos = 0;
+
+ /**
+ * The hashing state.
+ */
+ protected long[] hash = new long[8];
+ protected long[] K = new long[8]; // the round key
+ protected long[] L = new long[8];
+ protected long[] block = new long[8]; // mu(buffer)
+ protected long[] state = new long[8]; // the cipher state
+
+ public Whirlpool() {
+ }
+
+ /**
+ * The core Whirlpool transform.
+ */
+ protected void processBuffer() {
+ /*
+ * map the buffer to a block:
+ */
+ for (int i = 0, j = 0; i < 8; i++, j += 8) {
+ block[i] =
+ (((long)buffer[j ] ) << 56) ^
+ (((long)buffer[j + 1] & 0xffL) << 48) ^
+ (((long)buffer[j + 2] & 0xffL) << 40) ^
+ (((long)buffer[j + 3] & 0xffL) << 32) ^
+ (((long)buffer[j + 4] & 0xffL) << 24) ^
+ (((long)buffer[j + 5] & 0xffL) << 16) ^
+ (((long)buffer[j + 6] & 0xffL) << 8) ^
+ (((long)buffer[j + 7] & 0xffL) );
+ }
+ /*
+ * compute and apply K^0 to the cipher state:
+ */
+ for (int i = 0; i < 8; i++) {
+ state[i] = block[i] ^ (K[i] = hash[i]);
+ }
+ /*
+ * iterate over all rounds:
+ */
+ for (int r = 1; r <= R; r++) {
+ /*
+ * compute K^r from K^{r-1}:
+ */
+ for (int i = 0; i < 8; i++) {
+ L[i] = 0L;
+ for (int t = 0, s = 56; t < 8; t++, s -= 8) {
+ L[i] ^= C[t][(int)(K[(i - t) & 7] >>> s) & 0xff];
+ }
+ }
+ for (int i = 0; i < 8; i++) {
+ K[i] = L[i];
+ }
+ K[0] ^= rc[r];
+ /*
+ * apply the r-th round transformation:
+ */
+ for (int i = 0; i < 8; i++) {
+ L[i] = K[i];
+ for (int t = 0, s = 56; t < 8; t++, s -= 8) {
+ L[i] ^= C[t][(int)(state[(i - t) & 7] >>> s) & 0xff];
+ }
+ }
+ for (int i = 0; i < 8; i++) {
+ state[i] = L[i];
+ }
+ }
+ /*
+ * apply the Miyaguchi-Preneel compression function:
+ */
+ for (int i = 0; i < 8; i++) {
+ hash[i] ^= state[i] ^ block[i];
+ }
+ }
+
+ /**
+ * Initialize the hashing state.
+ */
+ public void NESSIEinit() {
+ Arrays.fill(bitLength, (byte)0);
+ bufferBits = bufferPos = 0;
+ buffer[0] = 0; // it's only necessary to cleanup buffer[bufferPos].
+ Arrays.fill(hash, 0L); // initial value
+ }
+
+ /**
+ * Delivers input data to the hashing algorithm.
+ *
+ * @param source plaintext data to hash.
+ * @param sourceBits how many bits of plaintext to process.
+ *
+ * This method maintains the invariant: bufferBits < 512
+ */
+ public void NESSIEadd(byte[] source, long sourceBits) {
+ /*
+ sourcePos
+ |
+ +-------+-------+-------
+ ||||||||||||||||||||| source
+ +-------+-------+-------
+ +-------+-------+-------+-------+-------+-------
+ |||||||||||||||||||||| buffer
+ +-------+-------+-------+-------+-------+-------
+ |
+ bufferPos
+ */
+ int sourcePos = 0; // index of leftmost source byte containing data (1 to 8 bits).
+ int sourceGap = (8 - ((int)sourceBits & 7)) & 7; // space on source[sourcePos].
+ int bufferRem = bufferBits & 7; // occupied bits on buffer[bufferPos].
+ int b;
+ // tally the length of the added data:
+ long value = sourceBits;
+ for (int i = 31, carry = 0; i >= 0; i--) {
+ carry += (bitLength[i] & 0xff) + ((int)value & 0xff);
+ bitLength[i] = (byte)carry;
+ carry >>>= 8;
+ value >>>= 8;
+ }
+ // process data in chunks of 8 bits:
+ while (sourceBits > 8) { // at least source[sourcePos] and source[sourcePos+1] contain data.
+ // take a byte from the source:
+ b = ((source[sourcePos] << sourceGap) & 0xff) |
+ ((source[sourcePos + 1] & 0xff) >>> (8 - sourceGap));
+ if (b < 0 || b >= 256) {
+ throw new RuntimeException("LOGIC ERROR");
+ }
+ // process this byte:
+ buffer[bufferPos++] |= b >>> bufferRem;
+ bufferBits += 8 - bufferRem; // bufferBits = 8*bufferPos;
+ if (bufferBits == 512) {
+ // process data block:
+ processBuffer();
+ // reset buffer:
+ bufferBits = bufferPos = 0;
+ }
+ buffer[bufferPos] = (byte)((b << (8 - bufferRem)) & 0xff);
+ bufferBits += bufferRem;
+ // proceed to remaining data:
+ sourceBits -= 8;
+ sourcePos++;
+ }
+ // now 0 <= sourceBits <= 8;
+ // furthermore, all data (if any is left) is in source[sourcePos].
+ if (sourceBits > 0) {
+ b = (source[sourcePos] << sourceGap) & 0xff; // bits are left-justified on b.
+ // process the remaining bits:
+ buffer[bufferPos] |= b >>> bufferRem;
+ } else {
+ b = 0;
+ }
+ if (bufferRem + sourceBits < 8) {
+ // all remaining data fits on buffer[bufferPos], and there still remains some space.
+ bufferBits += sourceBits;
+ } else {
+ // buffer[bufferPos] is full:
+ bufferPos++;
+ bufferBits += 8 - bufferRem; // bufferBits = 8*bufferPos;
+ sourceBits -= 8 - bufferRem;
+ // now 0 <= sourceBits < 8; furthermore, all data is in source[sourcePos].
+ if (bufferBits == 512) {
+ // process data block:
+ processBuffer();
+ // reset buffer:
+ bufferBits = bufferPos = 0;
+ }
+ buffer[bufferPos] = (byte)((b << (8 - bufferRem)) & 0xff);
+ bufferBits += (int)sourceBits;
+ }
+ }
+
+ /**
+ * Get the hash value from the hashing state.
+ *
+ * This method uses the invariant: bufferBits < 512
+ */
+ public void NESSIEfinalize(byte[] digest) {
+ // append a '1'-bit:
+ buffer[bufferPos] |= 0x80 >>> (bufferBits & 7);
+ bufferPos++; // all remaining bits on the current byte are set to zero.
+ // pad with zero bits to complete 512N + 256 bits:
+ if (bufferPos > 32) {
+ while (bufferPos < 64) {
+ buffer[bufferPos++] = 0;
+ }
+ // process data block:
+ processBuffer();
+ // reset buffer:
+ bufferPos = 0;
+ }
+ while (bufferPos < 32) {
+ buffer[bufferPos++] = 0;
+ }
+ // append bit length of hashed data:
+ System.arraycopy(bitLength, 0, buffer, 32, 32);
+ // process data block:
+ processBuffer();
+ // return the completed message digest:
+ for (int i = 0, j = 0; i < 8; i++, j += 8) {
+ long h = hash[i];
+ digest[j ] = (byte)(h >>> 56);
+ digest[j + 1] = (byte)(h >>> 48);
+ digest[j + 2] = (byte)(h >>> 40);
+ digest[j + 3] = (byte)(h >>> 32);
+ digest[j + 4] = (byte)(h >>> 24);
+ digest[j + 5] = (byte)(h >>> 16);
+ digest[j + 6] = (byte)(h >>> 8);
+ digest[j + 7] = (byte)(h );
+ }
+ }
+
+ /**
+ * Delivers string input data to the hashing algorithm.
+ *
+ * @param source plaintext data to hash (ASCII text string).
+ *
+ * This method maintains the invariant: bufferBits < 512
+ */
+ public void NESSIEadd(String source) {
+ if (source.length() > 0) {
+ byte[] data = new byte[source.length()];
+ for (int i = 0; i < source.length(); i++) {
+ data[i] = (byte)source.charAt(i);
+ }
+ NESSIEadd(data, 8*data.length);
+ }
+ }
+
+ protected static String display(byte[] array) {
+ char[] val = new char[2*array.length];
+ String hex = "0123456789ABCDEF";
+ for (int i = 0; i < array.length; i++) {
+ int b = array[i] & 0xff;
+ val[2*i] = hex.charAt(b >>> 4);
+ val[2*i + 1] = hex.charAt(b & 15);
+ }
+ return String.valueOf(val);
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/settings/CustomConfiguration.java b/src/main/java/uk/org/whoami/authme/settings/CustomConfiguration.java
new file mode 100644
index 00000000..66523665
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/settings/CustomConfiguration.java
@@ -0,0 +1,88 @@
+package uk.org.whoami.authme.settings;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.bukkit.configuration.InvalidConfigurationException;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public class CustomConfiguration extends YamlConfiguration{
+
+ private File configFile;
+
+ public CustomConfiguration(File file)
+ {
+ this.configFile = file;
+
+ load();
+ }
+
+ public void load()
+ {
+ try {
+ super.load(configFile);
+ } catch (FileNotFoundException e) {
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not find " + configFile.getName() + ", creating new one...");
+ reload();
+ } catch (IOException e) {
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not load " + configFile.getName(), e);
+ } catch (InvalidConfigurationException e) {
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, configFile.getName() + " is no valid configuration file", e);
+ }
+ }
+
+ public boolean reload() {
+ boolean out = true;
+ if (!configFile.exists())
+ {
+ out = loadRessource(configFile);
+ }
+ if (out) load();
+ return out;
+ }
+
+ public void save() {
+ try {
+ super.save(configFile);
+ } catch (IOException ex) {
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not save config to " + configFile.getName(), ex);
+ }
+ }
+
+ public boolean loadRessource(File file) {
+ boolean out = true;
+ if (!file.exists()) {
+ InputStream fis = getClass().getResourceAsStream("/" + file.getName());
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(file);
+ byte[] buf = new byte[1024];
+ int i = 0;
+
+ while ((i = fis.read(buf)) != -1) {
+ fos.write(buf, 0, i);
+ }
+ } catch (Exception e) {
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Failed to load config from JAR");
+ out = false;
+ } finally {
+ try {
+ if (fis != null) {
+ fis.close();
+ }
+ if (fos != null) {
+ fos.close();
+ }
+ } catch (Exception e) {
+ }
+ }
+ }
+ return out;
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/settings/Messages.java b/src/main/java/uk/org/whoami/authme/settings/Messages.java
new file mode 100644
index 00000000..7ae9cbb4
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/settings/Messages.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.settings;
+
+import java.io.File;
+
+public class Messages extends CustomConfiguration {
+
+ private static Messages singleton = null;
+
+
+ public Messages() {
+
+ super(new File(Settings.MESSAGE_FILE+"_"+Settings.messagesLanguage+".yml"));
+ loadDefaults();
+ loadFile();
+ singleton = this;
+
+ }
+
+ private void loadDefaults() {
+ this.set("logged_in", "&cAlready logged in!");
+ this.set("not_logged_in", "&cNot logged in!");
+ this.set("reg_disabled", "&cRegistration is disabled");
+ this.set("user_regged", "&cUsername already registered");
+ this.set("usage_reg", "&cUsage: /register password ConfirmPassword");
+ this.set("usage_log", "&cUsage: /login password");
+ this.set("user_unknown", "&cUsername not registered");
+ this.set("pwd_changed", "&cPassword changed!");
+ this.set("reg_only", "&fRegistered players only! Please visit http://example.com to register");
+ this.set("valid_session", "&cSession login");
+ this.set("login_msg", "&cPlease login with \"/login password\"");
+ this.set("reg_msg", "&cPlease register with \"/register password ConfirmPassword\"");
+ this.set("timeout", "&fLogin Timeout");
+ this.set("wrong_pwd", "&cWrong password");
+ this.set("logout", "&cSuccessful logout");
+ this.set("usage_unreg", "&cUsage: /unregister password");
+ this.set("registered", "&cSuccessfully registered!");
+ this.set("unregistered", "&cSuccessfully unregistered!");
+ this.set("login", "&cSuccessful login!");
+ this.set("no_perm", "&cNo Permission");
+ this.set("same_nick", "&fSame nick is already playing");
+ this.set("reg_voluntarily", "&fYou can register your nickname with the server with the command \"/register password ConfirmPassword\"");
+ this.set("reload", "&fConfiguration and database has been reloaded");
+ this.set("error", "&fAn error ocurred; Please contact the admin");
+ this.set("unknown_user", "&fUser is not in database");
+ this.set("unsafe_spawn","&fYour Quit location was unsafe, teleporting you to World Spawn");
+ this.set("unvalid_session","&fSession Dataes doesnt corrispond Plaese wait the end of session");
+ this.set("max_reg","&fYou have Exceded the max number of Registration for your Account");
+ this.set("password_error","&fPassword doesnt match");
+ this.set("pass_len","&fYour password dind''t reach the minimum length or exeded the max length");
+ this.set("vb_nonActiv","&fYour Account isent Activated yet check your Emails!");
+ this.set("usage_changepassword", "&fUsage: /changepassword oldPassword newPassword");
+ this.set("name_len", "&cYour nickname is too Short or too long");
+ this.set("regex", "&cYour nickname contains illegal characters. Allowed chars: REG_EX");
+ this.set("add_email","&cPlease add your email with : /email add yourEmail confirmEmail");
+ this.set("bad_database_email", "[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin");
+ this.set("recovery_email", "&cForgot your password? Please use /email recovery ");
+ this.set("usage_captcha", "&cUsage: /captcha ");
+ this.set("wrong_captcha", "&cWrong Captcha, please use : /captcha THE_CAPTCHA");
+ this.set("valid_captcha", "&cYour captcha is valid !");
+ }
+
+ private void loadFile() {
+ this.load();
+ this.save();
+
+ }
+
+ public String _(String msg) {
+ String loc = (String) this.get(msg);
+ if (loc != null) {
+ return loc.replace("&", "\u00a7");
+ }
+ return msg;
+ }
+
+
+ public static Messages getInstance() {
+ if (singleton == null) {
+ singleton = new Messages();
+ }
+ return singleton;
+ }
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/settings/PlayersLogs.java b/src/main/java/uk/org/whoami/authme/settings/PlayersLogs.java
new file mode 100644
index 00000000..c84e7f97
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/settings/PlayersLogs.java
@@ -0,0 +1,30 @@
+package uk.org.whoami.authme.settings;
+
+import java.io.File;
+import java.util.List;
+
+public class PlayersLogs extends CustomConfiguration {
+
+ private static PlayersLogs pllog = null;
+ public static List players;
+
+ @SuppressWarnings("unchecked")
+ public PlayersLogs() {
+ super(new File("./plugins/AuthMe/players.yml"));
+ pllog = this;
+ load();
+ save();
+ players = (List) this.getList("players");
+
+ }
+
+ public static PlayersLogs getInstance() {
+ if (pllog == null) {
+ pllog = new PlayersLogs();
+ }
+ return pllog;
+ }
+
+
+
+}
diff --git a/src/main/java/uk/org/whoami/authme/settings/Settings.java b/src/main/java/uk/org/whoami/authme/settings/Settings.java
new file mode 100644
index 00000000..e2b36151
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/settings/Settings.java
@@ -0,0 +1,666 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.settings;
+
+import java.io.File;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.bukkit.configuration.MemoryConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.plugin.Plugin;
+
+import uk.org.whoami.authme.ConsoleLogger;
+import uk.org.whoami.authme.datasource.DataSource;
+import uk.org.whoami.authme.datasource.DataSource.DataSourceType;
+import uk.org.whoami.authme.security.PasswordSecurity;
+import uk.org.whoami.authme.security.PasswordSecurity.HashAlgorithm;
+
+public final class Settings extends YamlConfiguration {
+
+ public static final String PLUGIN_FOLDER = "./plugins/AuthMe";
+ public static final String CACHE_FOLDER = Settings.PLUGIN_FOLDER + "/cache";
+ public static final String AUTH_FILE = Settings.PLUGIN_FOLDER + "/auths.db";
+ public static final String MESSAGE_FILE = Settings.PLUGIN_FOLDER + "/messages";
+ public static final String SETTINGS_FILE = Settings.PLUGIN_FOLDER + "/config.yml";
+ public static List allowCommands = null;
+ public static List getJoinPermissions = null;
+ public static List getUnrestrictedName = null;
+ private static List getRestrictedIp;
+ public static List getMySQLOtherUsernameColumn = null;
+ public static List getForcedWorlds = null;
+
+ public final Plugin plugin;
+ private final File file;
+
+ public static DataSourceType getDataSource;
+ public static HashAlgorithm getPasswordHash;
+ public static HashAlgorithm rakamakHash;
+
+ public static Boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled,
+ isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp,
+ isMovementAllowed, isKickNonRegisteredEnabled, isForceSingleSessionEnabled,
+ isForceSpawnLocOnJoinEnabled, isForceExactSpawnEnabled, isSaveQuitLocationEnabled,
+ isForceSurvivalModeEnabled, isResetInventoryIfCreative, isCachingEnabled, isKickOnWrongPasswordEnabled,
+ getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart,
+ isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
+ useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck;
+
+
+ public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
+ getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
+ getMySQLColumnName, getMySQLColumnPassword, getMySQLColumnIp, getMySQLColumnLastLogin,
+ getMySQLColumnSalt, getMySQLColumnGroup, getMySQLColumnEmail, unRegisteredGroup, backupWindowsPath,
+ getcUnrestrictedName, getRegisteredGroup, messagesLanguage, getMySQLlastlocX, getMySQLlastlocY, getMySQLlastlocZ,
+ rakamakUsers, rakamakUsersIp, getmailAccount, getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
+ getPredefinedSalt, getMailSubject, getMailText;
+
+
+ public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
+ getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
+ passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail;
+
+ protected static YamlConfiguration configFile;
+
+ public Settings(Plugin plugin) {
+ //super(new File(Settings.PLUGIN_FOLDER + "/config.yml"), this.plugin);
+ this.file = new File(plugin.getDataFolder(),"config.yml");
+
+ this.plugin = plugin;
+
+
+
+ //options().indent(4);
+ // Override to always indent 4 spaces
+ if(exists()) {
+ load();
+ }
+ else {
+ loadDefaults(file.getName());
+ load();
+ }
+
+ configFile = (YamlConfiguration) plugin.getConfig();
+
+ //saveDefaults();
+
+ }
+
+
+@SuppressWarnings("unchecked")
+public void loadConfigOptions() {
+
+ plugin.getLogger().info("Loading Configuration File...");
+
+ mergeConfig();
+
+ messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage","en"));
+ isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
+ isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
+ isRegistrationEnabled = configFile.getBoolean("settings.registration.enabled", true);
+ isTeleportToSpawnEnabled = configFile.getBoolean("settings.restrictions.teleportUnAuthedToSpawn",false);
+ getWarnMessageInterval = configFile.getInt("settings.registration.messageInterval",5);
+ isSessionsEnabled = configFile.getBoolean("settings.sessions.enabled",false);
+ getSessionTimeout = configFile.getInt("settings.sessions.timeout",10);
+ getRegistrationTimeout = configFile.getInt("settings.restrictions.timeout",30);
+ isChatAllowed = configFile.getBoolean("settings.restrictions.allowChat",false);
+ getMaxNickLength = configFile.getInt("settings.restrictions.maxNicknameLength",20);
+ getMinNickLength = configFile.getInt("settings.restrictions.minNicknameLength",3);
+ getPasswordMinLen = configFile.getInt("settings.security.minPasswordLength",4);
+ getNickRegex = configFile.getString("settings.restrictions.allowedNicknameCharacters","[a-zA-Z0-9_?]*");
+ isAllowRestrictedIp = configFile.getBoolean("settings.restrictions.AllowRestrictedUser",false);
+ getRestrictedIp = configFile.getStringList("settings.restrictions.AllowedRestrictedUser");
+ isMovementAllowed = configFile.getBoolean("settings.restrictions.allowMovement",false);
+ getMovementRadius = configFile.getInt("settings.restrictions.allowedMovementRadius",100);
+ getJoinPermissions = configFile.getStringList("GroupOptions.Permissions.PermissionsOnJoin");
+ isKickOnWrongPasswordEnabled = configFile.getBoolean("settings.restrictions.kickOnWrongPassword",false);
+ isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered",false);
+ isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession",true);
+ isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled",false);
+ isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
+ isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
+ isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative",false);
+ getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp",1);
+ getPasswordHash = getPasswordHash();
+ getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup","unLoggedInGroup");
+ getDataSource = getDataSource();
+ isCachingEnabled = configFile.getBoolean("DataSource.caching",true);
+ getMySQLHost = configFile.getString("DataSource.mySQLHost","127.0.0.1");
+ getMySQLPort = configFile.getString("DataSource.mySQLPort","3306");
+ getMySQLUsername = configFile.getString("DataSource.mySQLUsername","authme");
+ getMySQLPassword = configFile.getString("DataSource.mySQLPassword","12345");
+ getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase","authme");
+ getMySQLTablename = configFile.getString("DataSource.mySQLTablename","authme");
+ getMySQLColumnEmail = configFile.getString("DataSource.mySQLColumnEmail","email");
+ getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName","username");
+ getMySQLColumnPassword = configFile.getString("DataSource.mySQLColumnPassword","password");
+ getMySQLColumnIp = configFile.getString("DataSource.mySQLColumnIp","ip");
+ getMySQLColumnLastLogin = configFile.getString("DataSource.mySQLColumnLastLogin","lastlogin");
+ getMySQLColumnSalt = configFile.getString("ExternalBoardOptions.mySQLColumnSalt");
+ getMySQLColumnGroup = configFile.getString("ExternalBoardOptions.mySQLColumnGroup","");
+ getMySQLlastlocX = configFile.getString("DataSource.mySQLlastlocX","x");
+ getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY","y");
+ getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ","z");
+ getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
+ unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup","");
+ getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
+ getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup","");
+ getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier" , true);
+ protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
+ passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20);
+ isBackupActivated = configFile.getBoolean("BackupSystem.ActivateBackup",false);
+ isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart",false);
+ isBackupOnStop = configFile.getBoolean("BackupSystem.OnServeStop",false);
+ backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
+ enablePasspartu = configFile.getBoolean("Passpartu.enablePasspartu",false);
+ isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
+ reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
+ allowCommands = (List) configFile.getList("settings.restrictions.allowCommands");
+ if (configFile.contains("allowCommands")) {
+ if (!allowCommands.contains("/login"))
+ allowCommands.add("/login");
+ if (!allowCommands.contains("/register"))
+ allowCommands.add("/register");
+ if (!allowCommands.contains("/l"))
+ allowCommands.add("/l");
+ if (!allowCommands.contains("/reg"))
+ allowCommands.add("/reg");
+ if (!allowCommands.contains("/passpartu"))
+ allowCommands.add("/passpartu");
+ if (!allowCommands.contains("/email"))
+ allowCommands.add("/email");
+ if(!allowCommands.contains("/captcha"))
+ allowCommands.add("/captcha");
+ }
+ rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
+ rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
+ rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
+ rakamakHash = getRakamakHash();
+ noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
+ removePassword = configFile.getBoolean("Security.console.removePassword", true);
+ getmailAccount = configFile.getString("Email.mailAccount", "");
+ getmailPassword = configFile.getString("Email.mailPassword", "");
+ getmailSMTP = configFile.getString("Email.mailSMTP", "smtp.gmail.com");
+ getMailPort = configFile.getInt("Email.mailPort", 465);
+ getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
+ getMySQLOtherUsernameColumn = (List) configFile.getList("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList());
+ displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
+ getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
+ getmailSenderName = configFile.getString("Email.mailSenderName", "");
+ getPredefinedSalt = configFile.getString("Xenoforo.predefinedSalt", "");
+ useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
+ maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
+ captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
+ getMailSubject = configFile.getString("Email.mailSubject", "Your new AuthMe Password");
+ getMailText = configFile.getString("Email.mailText", "Dear , \n\n This is your new AuthMe password for the server : \n\n \n\n \n\n Do not forget to change password after login! \n /changepassword newPassword");
+ emailRegistration = configFile.getBoolean("settings.registration.enableEmailRegistrationSystem", false);
+ saltLength = configFile.getInt("settings.security.doubleMD5SaltLength", 8);
+ getmaxRegPerEmail = configFile.getInt("Email.maxRegPerEmail", 1);
+ multiverse = configFile.getBoolean("Hooks.multiverse", true);
+ chestshop = configFile.getBoolean("Hooks.chestshop", true);
+ notifications = configFile.getBoolean("Hooks.notifications", true);
+ bungee = configFile.getBoolean("Hooks.bungeecord", false);
+ getForcedWorlds = (List) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds");
+ banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
+ doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
+
+ saveDefaults();
+ }
+
+
+@SuppressWarnings("unchecked")
+public static void reloadConfigOptions(YamlConfiguration newConfig) {
+ configFile = newConfig;
+
+ //plugin.getLogger().info("RELoading Configuration File...");
+ messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage","en"));
+ isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
+ isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
+ isRegistrationEnabled = configFile.getBoolean("settings.registration.enabled", true);
+ isTeleportToSpawnEnabled = configFile.getBoolean("settings.restrictions.teleportUnAuthedToSpawn",false);
+ getWarnMessageInterval = configFile.getInt("settings.registration.messageInterval",5);
+ isSessionsEnabled = configFile.getBoolean("settings.sessions.enabled",false);
+ getSessionTimeout = configFile.getInt("settings.sessions.timeout",10);
+ getRegistrationTimeout = configFile.getInt("settings.restrictions.timeout",30);
+ isChatAllowed = configFile.getBoolean("settings.restrictions.allowChat",false);
+ getMaxNickLength = configFile.getInt("settings.restrictions.maxNicknameLength",20);
+ getMinNickLength = configFile.getInt("settings.restrictions.minNicknameLength",3);
+ getPasswordMinLen = configFile.getInt("settings.security.minPasswordLength",4);
+ getNickRegex = configFile.getString("settings.restrictions.allowedNicknameCharacters","[a-zA-Z0-9_?]*");
+ isAllowRestrictedIp = configFile.getBoolean("settings.restrictions.AllowRestrictedUser",false);
+ getRestrictedIp = configFile.getStringList("settings.restrictions.AllowedRestrictedUser");
+ isMovementAllowed = configFile.getBoolean("settings.restrictions.allowMovement",false);
+ getMovementRadius = configFile.getInt("settings.restrictions.allowedMovementRadius",100);
+ getJoinPermissions = configFile.getStringList("GroupOptions.Permissions.PermissionsOnJoin");
+ isKickOnWrongPasswordEnabled = configFile.getBoolean("settings.restrictions.kickOnWrongPassword",false);
+ isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered",false);
+ isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession",true);
+ isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled",false);
+ isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation",false);
+ isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode",false);
+ isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative",false);
+ getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp",1);
+ getPasswordHash = getPasswordHash();
+ getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup","unLoggedInGroup");
+ getDataSource = getDataSource();
+ isCachingEnabled = configFile.getBoolean("DataSource.caching",true);
+ getMySQLHost = configFile.getString("DataSource.mySQLHost","127.0.0.1");
+ getMySQLPort = configFile.getString("DataSource.mySQLPort","3306");
+ getMySQLUsername = configFile.getString("DataSource.mySQLUsername","authme");
+ getMySQLPassword = configFile.getString("DataSource.mySQLPassword","12345");
+ getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase","authme");
+ getMySQLTablename = configFile.getString("DataSource.mySQLTablename","authme");
+ getMySQLColumnEmail = configFile.getString("DataSource.mySQLColumnEmail","email");
+ getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName","username");
+ getMySQLColumnPassword = configFile.getString("DataSource.mySQLColumnPassword","password");
+ getMySQLColumnIp = configFile.getString("DataSource.mySQLColumnIp","ip");
+ getMySQLColumnLastLogin = configFile.getString("DataSource.mySQLColumnLastLogin","lastlogin");
+ getMySQLlastlocX = configFile.getString("DataSource.mySQLlastlocX","x");
+ getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY","y");
+ getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ","z");
+ getMySQLColumnSalt = configFile.getString("ExternalBoardOptions.mySQLColumnSalt","");
+ getMySQLColumnGroup = configFile.getString("ExternalBoardOptions.mySQLColumnGroup","");
+ getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
+ unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup","");
+ getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
+ getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup","");
+ getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier" , true);
+ protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
+ passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20);
+ isBackupActivated = configFile.getBoolean("BackupSystem.ActivateBackup",false);
+ isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart",false);
+ isBackupOnStop = configFile.getBoolean("BackupSystem.OnServeStop",false);
+ backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
+ enablePasspartu = configFile.getBoolean("Passpartu.enablePasspartu",false);
+ isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
+ reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
+ allowCommands = (List) configFile.getList("settings.restrictions.allowCommands");
+ if (configFile.contains("allowCommands")) {
+ if (!allowCommands.contains("/login"))
+ allowCommands.add("/login");
+ if (!allowCommands.contains("/register"))
+ allowCommands.add("/register");
+ if (!allowCommands.contains("/l"))
+ allowCommands.add("/l");
+ if (!allowCommands.contains("/reg"))
+ allowCommands.add("/reg");
+ if (!allowCommands.contains("/passpartu"))
+ allowCommands.add("/passpartu");
+ if (!allowCommands.contains("/email"))
+ allowCommands.add("/email");
+ if(!allowCommands.contains("/captcha"))
+ allowCommands.add("/captcha");
+ }
+ rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
+ rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
+ rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
+ rakamakHash = getRakamakHash();
+ noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
+ removePassword = configFile.getBoolean("Security.console.removePassword", true);
+ getmailAccount = configFile.getString("Email.mailAccount", "");
+ getmailPassword = configFile.getString("Email.mailPassword", "");
+ getmailSMTP = configFile.getString("Email.mailSMTP", "smtp.gmail.com");
+ getMailPort = configFile.getInt("Email.mailPort", 465);
+ getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
+ getMySQLOtherUsernameColumn = (List) configFile.getList("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList());
+ displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
+ getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
+ getmailSenderName = configFile.getString("Email.mailSenderName", "");
+ getPredefinedSalt = configFile.getString("Xenoforo.predefinedSalt", "");
+ useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
+ maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
+ captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
+ getMailSubject = configFile.getString("Email.mailSubject", "Your new AuthMe Password");
+ getMailText = configFile.getString("Email.mailText", "Dear , \n\n This is your new AuthMe password for the server : \n\n \n\n \n\n Do not forget to change password after login! \n /changepassword newPassword");
+ emailRegistration = configFile.getBoolean("settings.registration.enableEmailRegistrationSystem", false);
+ saltLength = configFile.getInt("settings.security.doubleMD5SaltLength", 8);
+ getmaxRegPerEmail = configFile.getInt("Email.maxRegPerEmail", 1);
+ multiverse = configFile.getBoolean("Hooks.multiverse", true);
+ chestshop = configFile.getBoolean("Hooks.chestshop", true);
+ notifications = configFile.getBoolean("Hooks.notifications", true);
+ bungee = configFile.getBoolean("Hooks.bungeecord", false);
+ getForcedWorlds = (List) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds");
+ banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
+ doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
+
+ }
+
+
+public void mergeConfig() {
+
+ if (contains("settings.restrictions.allowedPluginTeleportHandler")) {
+ set("settings.restrictions.allowedPluginTeleportHandler", null);
+ }
+
+ if(!contains("DataSource.mySQLColumnEmail")) {
+ set("DataSource.mySQLColumnEmail","email");
+ }
+
+ if(contains("Email.GmailAccount")) {
+ set("Email.mailAccount", getString("Email.GmailAccount"));
+ set("Email.GmailAccount", null);
+ }
+
+ if(contains("Email.GmailPassword")) {
+ set("Email.mailPassword", getString("Email.GmailPassword"));
+ set("Email.GmailPassword", null);
+ }
+
+ if(!contains("Email.RecoveryPasswordLength")) {
+ set("Email.RecoveryPasswordLength", 8);
+ }
+
+ if(!contains("Email.mailPort")) {
+ set("Email.mailPort", 465);
+ }
+
+ if(!contains("Email.mailSMTP")) {
+ set("Email.mailSMTP", "smtp.gmail.com");
+ }
+
+ if(!contains("Email.mailAccount")) {
+ set("Email.mailAccount", "");
+ }
+
+ if(!contains("Email.mailPassword")) {
+ set("Email.mailPassword", "");
+ }
+
+ if(!contains("ExternalBoardOptions.mySQLOtherUsernameColumns")) {
+ set("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList());
+ }
+
+ if(!contains("settings.restrictions.displayOtherAccounts")) {
+ set("settings.restrictions.displayOtherAccounts", true);
+ }
+
+ if(!contains("DataSource.mySQLColumnId")) {
+ set("DataSource.mySQLColumnId", "id");
+ }
+
+ if(!contains("Email.mailSenderName")) {
+ set("Email.mailSenderName", "");
+ }
+
+ if(!contains("Xenoforo.predefinedSalt")) {
+ set("Xenoforo.predefinedSalt", "");
+ }
+
+ if(!contains("Security.captcha.useCaptcha")) {
+ set("Security.captcha.useCaptcha", false);
+ }
+
+ if(!contains("Security.captcha.maxLoginTry")) {
+ set("Security.captcha.maxLoginTry", 5);
+ }
+
+ if(!contains("Security.captcha.captchaLength")) {
+ set("Security.captcha.captchaLength", 5);
+ }
+
+ if(!contains("Email.mailSubject")) {
+ set("Email.mailSubject", "");
+ }
+
+ if(!contains("Email.mailText")) {
+ set("Email.mailText", "Dear , \n\n This is your new AuthMe password for the server : \n\n \n\n \n\n Do not forget to change password after login! \n /changepassword newPassword");
+ }
+
+ if(!contains("settings.registration.enableEmailRegistrationSystem")) {
+ set("settings.registration.enableEmailRegistrationSystem", false);
+ }
+
+ if(!contains("settings.security.doubleMD5SaltLength")) {
+ set("settings.security.doubleMD5SaltLength", 8);
+ }
+
+ if(!contains("Email.maxRegPerEmail")) {
+ set("Email.maxRegPerEmail", 1);
+ }
+
+ if(!contains("Hooks.multiverse")) {
+ set("Hooks.multiverse", true);
+ set("Hooks.chestshop", true);
+ set("Hooks.notifications", true);
+ set("Hooks.bungeecord", false);
+ }
+
+ if(!contains("settings.restrictions.ForceSpawnOnTheseWorlds")) {
+ set("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList());
+ }
+
+ if(!contains("settings.restrictions.banUnsafedIP")) {
+ set("settings.restrictions.banUnsafedIP", false);
+ }
+
+ if(!contains("settings.registration.doubleEmailCheck")) {
+ set("settings.registration.doubleEmailCheck", false);
+ }
+
+ plugin.getLogger().info("Merge new Config Options if needed..");
+ plugin.saveConfig();
+
+ return;
+ }
+ /**
+ *
+ *
+ *
+ */
+ private static HashAlgorithm getPasswordHash() {
+ String key = "settings.security.passwordHash";
+
+ try {
+ return PasswordSecurity.HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
+ } catch (IllegalArgumentException ex) {
+ ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
+ return PasswordSecurity.HashAlgorithm.SHA256;
+ }
+ }
+
+
+ private static HashAlgorithm getRakamakHash() {
+ String key = "Converter.Rakamak.newPasswordHash";
+
+ try {
+ return PasswordSecurity.HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
+ } catch (IllegalArgumentException ex) {
+ ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
+ return PasswordSecurity.HashAlgorithm.SHA256;
+ }
+ }
+
+ /**
+ *
+ *
+ *
+ */
+ private static DataSourceType getDataSource() {
+ String key = "DataSource.backend";
+
+ try {
+ return DataSource.DataSourceType.valueOf(configFile.getString(key).toUpperCase());
+ } catch (IllegalArgumentException ex) {
+ ConsoleLogger.showError("Unknown database backend; defaulting to file database");
+ return DataSource.DataSourceType.FILE;
+ }
+ }
+
+ /**
+ * Config option for setting and check restricted user by
+ * username;ip , return false if ip and name doesnt amtch with
+ * player that join the server, so player has a restricted access
+ */
+ public static Boolean getRestrictedIp(String name, String ip) {
+
+ Iterator iter = getRestrictedIp.iterator();
+
+ /* setup a few boolean variables to test the parameters */
+ Boolean trueonce = false;
+ Boolean namefound = false;
+
+ while (iter.hasNext()) {
+ String[] args = iter.next().split(";");
+
+ String testname = args[0];
+ String testip = args[1];
+
+ /** Changing this logic to be more customized
+ * test each case against the entire
+ * list not just the first one in the list.*/
+
+ /* Fist Check the name */
+ if(testname.equalsIgnoreCase(name) ) {
+ namefound = true;
+ /* Check to see if the IP is the same */
+ if(testip.equalsIgnoreCase(ip)) {
+ trueonce = true;
+ };
+ }
+ }
+ // if the name is not found in the list let the user pass they are not being monitored
+ if ( namefound == false){
+ return true;
+ }
+ else {
+ // if the name and IP was found once in the list let the user pass they are in the config
+ if ( trueonce == true ){
+ return true;
+ // otherwise nip them in the bud and THEY SHALL NOT PASS!
+ } else {
+ return false;
+ }
+ }
+}
+
+
+ /**
+ * Loads the configuration from disk
+ *
+ * @return True if loaded successfully
+ */
+ public final boolean load() {
+ try {
+ load(file);
+ return true;
+ } catch (Exception ex) {
+ return false;
+ }
+ }
+
+ public final void reload() {
+ load();
+ loadDefaults(file.getName());
+ }
+
+ /**
+ * Saves the configuration to disk
+ *
+ * @return True if saved successfully
+ */
+ public final boolean save() {
+ try {
+ save(file);
+ return true;
+ } catch (Exception ex) {
+ return false;
+ }
+ }
+
+ /**
+ * Simple function for if the Configuration file exists
+ *
+ * @return True if configuration exists on disk
+ */
+ public final boolean exists() {
+ return file.exists();
+ }
+
+ /**
+ * Loads a file from the plugin jar and sets as default
+ *
+ * @param filename The filename to open
+ */
+ public final void loadDefaults(String filename) {
+ InputStream stream = plugin.getResource(filename);
+ if(stream == null) return;
+
+ setDefaults(YamlConfiguration.loadConfiguration(stream));
+ }
+
+ /**
+ * Saves current configuration (plus defaults) to disk.
+ *
+ * If defaults and configuration are empty, saves blank file.
+ *
+ * @return True if saved successfully
+ */
+ public final boolean saveDefaults() {
+ options().copyDefaults(true);
+ options().copyHeader(true);
+ boolean success = save();
+ options().copyDefaults(false);
+ options().copyHeader(false);
+
+ return success;
+ }
+
+
+ /**
+ * Clears current configuration defaults
+ */
+ public final void clearDefaults() {
+ setDefaults(new MemoryConfiguration());
+ }
+
+ /**
+* Check loaded defaults against current configuration
+*
+* @return false When all defaults aren't present in config
+*/
+ public boolean checkDefaults() {
+ if (getDefaults() == null) {
+ return true;
+ }
+ return getKeys(true).containsAll(getDefaults().getKeys(true));
+ }
+ /*
+ public static Settings getInstance() {
+ if (singleton == null) {
+ singleton = new Settings();
+ }
+ return singleton;
+ }
+*/
+ public static String checkLang(String lang) {
+ for(messagesLang language: messagesLang.values()) {
+ //System.out.println(language.toString());
+ if(lang.toLowerCase().contains(language.toString())) {
+ ConsoleLogger.info("Set Language: "+lang);
+ return lang;
+ }
+ }
+ ConsoleLogger.info("Set Default Language: En ");
+ return "en";
+ }
+
+ public enum messagesLang {
+ en, de, br, cz, pl, fr, ru, hu, sk, es
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/settings/SpoutCfg.java b/src/main/java/uk/org/whoami/authme/settings/SpoutCfg.java
new file mode 100644
index 00000000..93efed4f
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/settings/SpoutCfg.java
@@ -0,0 +1,45 @@
+package uk.org.whoami.authme.settings;
+
+/**
+ * @Author Hoezef
+ */
+import java.io.File;
+import java.util.ArrayList;
+
+public class SpoutCfg extends CustomConfiguration{
+
+ private static SpoutCfg instance = null;
+
+ public SpoutCfg(File file)
+ {
+ super(file);
+ loadDefaults();
+ load();
+ save();
+ }
+
+ @SuppressWarnings("serial")
+ private void loadDefaults() {
+ this.set("Spout GUI enabled", true);
+ //Login:
+ this.set("LoginScreen.enabled", true);
+ this.set("LoginScreen.exit button", "Quit");
+ this.set("LoginScreen.exit message", "Good Bye");
+ this.set("LoginScreen.login button", "Login");
+ this.set("LoginScreen.title", "LOGIN");
+ this.set("LoginScreen.text", new ArrayList() {{
+ add("Sample text");
+ add("Change this at spout.yml");
+ add("------------------");
+ add("AuthMe Reloaded by d4rkwarriors");
+ }});
+ //Registration:
+ //this.set("RegistrationScreen.enabled",true);
+
+ }
+
+ public static SpoutCfg getInstance() {
+ if (instance == null) instance = new SpoutCfg(new File("plugins/AuthMe", "spout.yml"));
+ return instance;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/uk/org/whoami/authme/task/MessageTask.java b/src/main/java/uk/org/whoami/authme/task/MessageTask.java
new file mode 100644
index 00000000..2bb0613b
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/task/MessageTask.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.task;
+
+import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitScheduler;
+import org.bukkit.scheduler.BukkitTask;
+
+import uk.org.whoami.authme.AuthMe;
+import uk.org.whoami.authme.cache.auth.PlayerCache;
+import uk.org.whoami.authme.cache.limbo.LimboCache;
+
+public class MessageTask implements Runnable {
+
+ private AuthMe plugin;
+ private String name;
+ private String msg;
+ private int interval;
+
+ public MessageTask(AuthMe plugin, String name, String msg, int interval) {
+ this.plugin = plugin;
+ this.name = name;
+ this.msg = msg;
+ this.interval = interval;
+ }
+
+ @Override
+ public void run() {
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ for (Player player : plugin.getServer().getOnlinePlayers()) {
+ if (player.getName().toLowerCase().equals(name)) {
+ player.sendMessage(msg);
+
+ BukkitScheduler sched = plugin.getServer().getScheduler();
+ BukkitTask late = sched.runTaskLater(plugin, this, interval * 20);
+ if(LimboCache.getInstance().hasLimboPlayer(name)) {
+ LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late.getTaskId());
+ }
+
+ }
+ }
+ }
+}
diff --git a/src/main/java/uk/org/whoami/authme/task/TimeoutTask.java b/src/main/java/uk/org/whoami/authme/task/TimeoutTask.java
new file mode 100644
index 00000000..4b3e013a
--- /dev/null
+++ b/src/main/java/uk/org/whoami/authme/task/TimeoutTask.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2011 Sebastian Köhler .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package uk.org.whoami.authme.task;
+
+import org.bukkit.GameMode;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import uk.org.whoami.authme.ConsoleLogger;
+import uk.org.whoami.authme.cache.backup.FileCache;
+import uk.org.whoami.authme.cache.auth.PlayerCache;
+import uk.org.whoami.authme.cache.limbo.LimboPlayer;
+import uk.org.whoami.authme.cache.limbo.LimboCache;
+import uk.org.whoami.authme.listener.AuthMePlayerListener;
+import uk.org.whoami.authme.settings.Messages;
+
+
+public class TimeoutTask implements Runnable {
+
+ private JavaPlugin plugin;
+ private String name;
+ private Messages m = Messages.getInstance();
+ private FileCache playerCache = new FileCache();
+
+ public TimeoutTask(JavaPlugin plugin, String name) {
+ this.plugin = plugin;
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void run() {
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ return;
+ }
+
+ for (Player player : plugin.getServer().getOnlinePlayers()) {
+ if (player.getName().toLowerCase().equals(name)) {
+ if (LimboCache.getInstance().hasLimboPlayer(name)) {
+ LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
+ player.getServer().getScheduler().cancelTask(inv.getTimeoutTaskId());
+
+ if(playerCache.doesCacheExist(name)) {
+ playerCache.removeCache(name);
+ }
+ }
+ int gm = AuthMePlayerListener.gameMode.get(name);
+ player.setGameMode(GameMode.getByValue(gm));
+ ConsoleLogger.info("Set " + player.getName() + " to gamemode: " + GameMode.getByValue(gm).name());
+ player.kickPlayer(m._("timeout"));
+ break;
+ }
+ }
+ }
+}
diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..54a8422c
--- /dev/null
+++ b/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: ../lib/mail.jar
+
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 00000000..459d7e1d
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,126 @@
+DataSource:
+ mySQLColumnName: username
+ mySQLTablename: authme
+ mySQLUsername: authme
+ backend: file
+ mySQLColumnLastLogin: lastlogin
+ mySQLDatabase: authme
+ mySQLPort: '3306'
+ mySQLColumnIp: ip
+ mySQLHost: 127.0.0.1
+ mySQLColumnPassword: password
+ mySQLPassword: '12345'
+ caching: true
+ mySQLlastlocX: x
+ mySQLlastlocY : y
+ mySQLlastlocZ : z
+ mySQLColumnEmail: email
+ mySQLColumnId: id
+GroupOptions:
+ UnregisteredPlayerGroup: ''
+ RegisteredPlayerGroup: ''
+ Permissions:
+ PermissionsOnJoin: []
+settings:
+ sessions:
+ enabled: false
+ timeout: 10
+ restrictions:
+ allowChat: false
+ allowCommands:
+ - /login
+ - /register
+ - /l
+ - /reg
+ - /passpartu
+ - /email
+ - /captcha
+ maxRegPerIp: 1
+ maxNicknameLength: 20
+ ForceSingleSession: true
+ ForceSpawnLocOnJoinEnabled: false
+ SaveQuitLocation: false
+ AllowRestrictedUser: false
+ AllowedRestrictedUser: []
+ kickNonRegistered: false
+ kickOnWrongPassword: false
+ teleportUnAuthedToSpawn: false
+ minNicknameLength: 3
+ allowMovement: false
+ timeout: 30
+ allowedNicknameCharacters: '[a-zA-Z0-9_?]*'
+ allowedMovementRadius: 100
+ enablePasswordVerifier: true
+ ProtectInventoryBeforeLogIn: true
+ displayOtherAccounts: true
+ ForceSpawnOnTheseWorlds:
+ - world
+ - world_nether
+ - world_the_end
+ banUnsafedIP: false
+ GameMode:
+ ForceSurvivalMode: false
+ ResetInventoryIfCreative: false
+ security:
+ minPasswordLength: 4
+ unLoggedinGroup: unLoggedinGroup
+ passwordHash: SHA256
+ doubleMD5SaltLength: 8
+ registration:
+ enabled: true
+ messageInterval: 5
+ force: true
+ enableEmailRegistrationSystem: false
+ doubleEmailCheck: false
+ unrestrictions:
+ UnrestrictedName: []
+ messagesLanguage: en
+ExternalBoardOptions:
+ mySQLColumnSalt: ''
+ mySQLColumnGroup: ''
+ nonActivedUserGroup: -1
+ mySQLOtherUsernameColumns: []
+Xenoforo:
+ predefinedSalt: ''
+permission:
+ EnablePermissionCheck: false
+BackupSystem:
+ ActivateBackup: false
+ OnServerStart: false
+ OnServerStop: true
+ MysqlWindowsPath: 'C:\\Program Files\\MySQL\\MySQL Server 5.1\\'
+Passpartu:
+ enablePasspartu: false
+Security:
+ SQLProblem:
+ stopServer: true
+ ReloadCommand:
+ useReloadCommandSupport: true
+ console:
+ noConsoleSpam: false
+ removePassword: true
+ captcha:
+ useCaptcha: false
+ maxLoginTry: 5
+ captchaLength: 5
+Converter:
+ Rakamak:
+ fileName: users.rak
+ useIP: false
+ ipFileName: UsersIp.rak
+ newPasswordHash: SHA256
+Email:
+ mailSMTP: smtp.gmail.com
+ mailPort: 465
+ mailAccount: ''
+ mailPassword: ''
+ mailSenderName: ''
+ RecoveryPasswordLength: 8
+ mailSubject: 'Your new AuthMe Password'
+ mailText: 'Dear , \n\n This is your new AuthMe password for the server \n\n : \n\n \n\nDo not forget to change password after login! \n /changepassword newPassword'
+ maxRegPerEmail: 1
+Hooks:
+ multiverse: true
+ chestshop: true
+ bungeecord: false
+ notifications: true
\ No newline at end of file
diff --git a/src/main/resources/messages_br.yml b/src/main/resources/messages_br.yml
new file mode 100644
index 00000000..10c8fe51
--- /dev/null
+++ b/src/main/resources/messages_br.yml
@@ -0,0 +1,38 @@
+unknown_user: '&fUsuario inexistente'
+not_logged_in: '&cNao conectado!'
+reg_voluntarily: '&fPara registrar um nickname, digite: "/register senha senha"'
+usage_log: '&cPara entrar digite: "/login senha"'
+wrong_pwd: '&cErro. Senha Incorreta.'
+unregistered: '&cDesregistrado com sucesso!'
+reg_disabled: '&cNovos registros estao desativados.'
+valid_session: '&cSessao de login'
+login: '&cLogado com sucesso!'
+vb_nonActiv: '&fSua conta nao esta ativada, verifique os seus e-mails!'
+user_regged: '&cEste nome ja foi registrado antes.'
+usage_reg: '&cPara registrar digite: "/register senha senha"'
+max_reg: '&fNumero maximo de registros excedido.'
+no_perm: '&cSem permissao!'
+error: '&fOcorreu um erro de sistema, por favor reporte ao ADM.'
+login_msg: '&cPara entrar digite: "/login password"'
+reg_msg: '&cPara registrar um nick digite: "/register senha senha"'
+usage_unreg: '&cPara desregistrar digite: /unregister senha'
+pwd_changed: '&cSenha modificada!'
+user_unknown: '&cNome de usuario nao existe. Verifique.'
+password_error: '&fErro! Senha incorreta!'
+unvalid_session: '&fSessao invalida! Desconecte e reconecte-se novamente.'
+reg_only: '&fRegistro permitido somente para nomes na Whitelist!'
+logged_in: '&cJa esta logado!'
+logout: '&cSaida realizada com sucesso.'
+same_nick: '&fEste nick ja esta online...'
+registered: '&cRegistrado com sucesso!'
+pass_len: '&fSenha muito curta.'
+reload: '&fAuthMe Recarregado.'
+timeout: '&fDemorou....'
+name_len: '&cYour nickname is too Short or too long'
+regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
+add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
+bad_database_email: '[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin'
+recovery_email: '&cForgot your password? Please use /email recovery '
+usage_captcha: '&cUsage: /captcha '
+wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
+valid_captcha: '&cYour captcha is valid !'
\ No newline at end of file
diff --git a/src/main/resources/messages_cz.yml b/src/main/resources/messages_cz.yml
new file mode 100644
index 00000000..1546bffc
--- /dev/null
+++ b/src/main/resources/messages_cz.yml
@@ -0,0 +1,40 @@
+unknown_user: '&cHrac neni registrovan.'
+not_logged_in: '&cNeprihlasen!'
+reg_voluntarily: '&cRegistruj se prikazem "/register heslo heslo".'
+usage_log: '&cPouziti: "/login vaseheslo".'
+wrong_pwd: '&cSpatne heslo.'
+unregistered: '&cUspesna unregistrace!'
+reg_disabled: '&cRegistrace je zakazana!'
+valid_session: '&cAutomaticke znovuprihlaseni.'
+login: '&cUspesne prihlaseni!'
+user_regged: '&cUzivatelske jmeno je jiz registrovano.'
+usage_reg: '&cPouziti: "/register heslo heslo".'
+no_perm: '&cNemas opravneni.'
+error: '&cVyskytla se chyba kontaktujte admina ...'
+login_msg: '&cProsim prihlaste se "/login vaseheslo".'
+reg_msg: '&cProsim zaregistrujte se "/register heslo heslo".'
+usage_unreg: '&cPouziti: "/unregister vaseheslo".'
+pwd_changed: '&cHeslo zmeneno!'
+user_unknown: '&cUzivatelske jmeno neni registrovano.'
+reg_only: '&cServer je pouze pro registrovane! Navstivte http://bit.ly/zyEzzS.'
+logged_in: '&cJste jiz prihlasen!'
+logout: '&cOdhlaseni bylo uspesne.'
+same_nick: '&cNekdo jiz hraje se stejnym nickem.'
+registered: '&cRegistrace byla uspesna!'
+reload: '&cPrenacteni AuthMe probehlo uspesne.'
+timeout: '&cCas na prihlaseni vyprsel!'
+unsafe_spawn: '&cVase pozice pri odpojeni byla nebezpecna, teleportuji na spawn!'
+unvalid_session: '&cChybna data pri cteni pockejte do vyprseni.'
+max_reg: '&cJiz jste prekrocil(a) limit pro pocet uctu z vasi IP.'
+password_error: '&cHesla se neshoduji!'
+pass_len: '&cVase heslo nedosahuje minimalni delky (4).'
+vb_nonActiv: '&cVas ucet neni aktivaovany, zkontrolujte si vas E-mail.'
+usage_changepassword: '&cPouziti: "/changepassword stareHeslo noveHeslo".'
+name_len: '&cYour nickname is too Short or too long'
+regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
+add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
+bad_database_email: '[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin'
+recovery_email: '&cForgot your password? Please use /email recovery '
+usage_captcha: '&cUsage: /captcha '
+wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
+valid_captcha: '&cYour captcha is valid !'
\ No newline at end of file
diff --git a/src/main/resources/messages_de.yml b/src/main/resources/messages_de.yml
new file mode 100644
index 00000000..14261073
--- /dev/null
+++ b/src/main/resources/messages_de.yml
@@ -0,0 +1,41 @@
+unknown_user: '&fBenutzer ist nicht in der Datenbank'
+unsafe_spawn: '&fDeine Logoutposition war unsicher, du wurdest zum Spawn teleportiert'
+not_logged_in: '&cNicht eingelogt!'
+reg_voluntarily: '&fDu kannst dich mit folgendem Befehl registrieren
+ "/register passwort"'
+usage_log: '&cBenutze: /login passwort'
+wrong_pwd: '&cFalsches Passwort'
+unregistered: '&cErfolgreich unregistriert!'
+reg_disabled: '&cRegistrierungen sind deaktiviert'
+valid_session: '&cErfolgreich eingelogt'
+login: '&cErfolgreich eingelogt!'
+vb_nonActiv: '&fDein Account ist noch nicht aktiviert, bitte pruefe deine E-Mails!'
+user_regged: '&cBenutzername wurde schon registriert'
+usage_reg: '&cBenutze: /register passwort'
+max_reg: '&fDu hast die maximale Anzahl an Accounts erreicht'
+no_perm: '&cKeine Rechte'
+error: '&fEin Fehler ist unterlaufen, bitte kontaktiere einen Admin'
+login_msg: '&cBitte logge dich ein mit "/login passwort"'
+reg_msg: '&cBitte registriere dich mit "/register passwort"'
+usage_unreg: '&cBenutze: /unregister passwort'
+pwd_changed: '&cPasswort geaendert!'
+user_unknown: '&cBenutzername nicht registriert'
+password_error: '&fPasswort falsch'
+unvalid_session: '&fPerioden login Fehler, bitte warte...'
+reg_only: '&fNur registrierte Spieler! Bitte besuche http://example.com zum registrieren'
+logged_in: '&cSchon eingelogt!'
+logout: '&cErfolgreich ausgelogt'
+same_nick: '&fSelber Name spielt bereits'
+registered: '&cErfolgreich registriert!'
+pass_len: '&fIhr Passwort erreicht nicht die minimale Laenge oder überschreitet die maximale Laenge'
+reload: '&fKonfiguration und Datenbank neu geladen'
+timeout: '&fLogin dauerte zu lange'
+usage_changepassword: '&fBenutze: /changepassword altesPasswort neuesPasswort'
+name_len: '&cYour nickname is too Short or too long'
+regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
+add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
+bad_database_email: '[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin'
+recovery_email: '&cForgot your password? Please use /email recovery '
+usage_captcha: '&cUsage: /captcha '
+wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
+valid_captcha: '&cYour captcha is valid !'
\ No newline at end of file
diff --git a/src/main/resources/messages_en.yml b/src/main/resources/messages_en.yml
new file mode 100644
index 00000000..846cb60f
--- /dev/null
+++ b/src/main/resources/messages_en.yml
@@ -0,0 +1,42 @@
+unknown_user: '&fUser is not in database'
+unsafe_spawn: '&fYour Quit location was unsafe, teleporting you to World Spawn'
+not_logged_in: '&cNot logged in!'
+reg_voluntarily: '&fYou can register your nickname with the server with the command "/register password ConfirmPassword"'
+usage_log: '&cUsage: /login password'
+wrong_pwd: '&cWrong password'
+unregistered: '&cSuccessfully unregistered!'
+reg_disabled: '&cRegistration is disabled'
+valid_session: '&cSession login'
+login: '&cSuccessful login!'
+vb_nonActiv: '&fYour Account isent Activated yet check your Emails!'
+user_regged: '&cUsername already registered'
+usage_reg: '&cUsage: /register password ConfirmPassword'
+max_reg: '&fYou have Exeded the max number of Registration for your Account'
+no_perm: '&cNo Permission'
+error: '&fAn error ocurred; Please contact the admin'
+login_msg: '&cPlease login with "/login password"'
+reg_msg: '&cPlease register with "/register password ConfirmPassword"'
+usage_unreg: '&cUsage: /unregister password'
+pwd_changed: '&cPassword changed!'
+user_unknown: '&cUsername not registered'
+password_error: '&fPassword doesnt match'
+unvalid_session: '&fSession Dataes doesnt corrispond Plaese wait the end of session'
+reg_only: '&fRegistered players only! Please visit http://example.com to register'
+logged_in: '&cAlready logged in!'
+logout: '&cSuccessful logout'
+same_nick: '&fSame nick is already playing'
+registered: '&cSuccessfully registered!'
+pass_len: '&fYour password dind''t reach the minimum length or exeded the max length'
+reload: '&fConfiguration and database has been reloaded'
+timeout: '&fLogin Timeout'
+usage_changepassword: '&fUsage: /changepassword oldPassword newPassword'
+name_len: '&cYour nickname is too Short or too long'
+regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
+add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
+bad_database_email: '[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin'
+recovery_email: '&cForgot your password? Please use /email recovery '
+usage_captcha: '&cUsage: /captcha '
+wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
+valid_captcha: '&cYour captcha is valid !'
+
+
diff --git a/src/main/resources/messages_es.yml b/src/main/resources/messages_es.yml
new file mode 100644
index 00000000..da2682b7
--- /dev/null
+++ b/src/main/resources/messages_es.yml
@@ -0,0 +1,41 @@
+# This file must be in ANSI if win, or UTF-8 if linux.
+unknown_user: '&fEl usuario no está en la base de datos'
+unsafe_spawn: '&fTu lugar de desconexión es inseguro, teletransportándote al punto inicial del mundo'
+not_logged_in: '&c¡No has iniciado sesión!'
+reg_voluntarily: '&fRegístrate con: "/register Contraseña ConfirmarContraseña"'
+usage_log: '&cUso: /login contraseña'
+wrong_pwd: '&cContraseña incorrecta'
+unregistered: '&c¡Cuenta eliminada del registro!'
+reg_disabled: '&cEl registro está desactivado'
+valid_session: '&cInicio de sesión'
+login: '&c¡Sesión iniciada!'
+vb_nonActiv: '&fTu cuenta no está activada aún, ¡revisa tu correo!'
+user_regged: '&cUsuario ya registrado'
+usage_reg: '&cUso: /register Contraseña ConfirmarContraseña'
+max_reg: '&fHas excedido la cantidad máxima de registros para tu cuenta'
+no_perm: '&cNo tienes permiso'
+error: '&fHa ocurrido un error. Por favor contacta al administrador.'
+login_msg: '&cInicia sesión con "/login contraseña"'
+reg_msg: '&cPor favor, regístrate con "/register Contraseña ConfirmarContraseña"'
+usage_unreg: '&cUso: /unregister contraseña'
+pwd_changed: '&c¡Contraseña cambiada!'
+user_unknown: '&cUsuario no registrado'
+password_error: '&fLas contraseñas no son iguales'
+unvalid_session: '&fLos datos de sesión no corresponden. Por favor espera a terminar la sesión.'
+reg_only: '&f¡Sólo para jugadores registrados! Por favor visita http://www.example.com/ para registrarte'
+logged_in: '&c¡Ya has iniciado sesión!'
+logout: '&cDesconectado correctamente.'
+same_nick: '&fYa hay un usuario con ese nick conectado (posible error)'
+registered: '&c¡Registrado correctamente!'
+pass_len: '&fTu contraseña es muy larga o muy corta'
+reload: '&fLa configuración y la base de datos han sido recargados'
+timeout: '&fTiempo de espera para inicio de sesión excedido'
+usage_changepassword: '&fUso: /changepw contraseñaaActual contraseñaNueva'
+name_len: '&cTu nombre de usuario es muy largo o muy corto'
+regex: '&cTu usuario tiene carácteres no admitidos, los cuales son: REG_EX'
+add_email: '&cPor favor agrega tu e-mail con: /email add tuEmail confirmarEmail'
+bad_database_email: '[AuthMe] El comando /email sólo está disponible con MySQL y SQLite, contacta a un administrador'
+recovery_email: '&c¿Olvidaste tu contraseña? Por favor usa /email recovery '
+usage_captcha: '&cUso: /captcha '
+wrong_captcha: '&cCaptcha incorrecto, please use : /captcha EL_CAPTCHA'
+valid_captcha: '&c¡ Captcha ingresado correctamente !'
diff --git a/src/main/resources/messages_fr.yml b/src/main/resources/messages_fr.yml
new file mode 100644
index 00000000..60b4982f
--- /dev/null
+++ b/src/main/resources/messages_fr.yml
@@ -0,0 +1,40 @@
+unknown_user: '&fUtilisateur non enregistrer'
+unsafe_spawn: '&fTeleportation dans un endroit sur'
+not_logged_in: '&cNon connecter!'
+reg_voluntarily: '&fVous venez d arriver? faites un "/register motdepasse confirmermotdepasse"'
+usage_log: '&cUtilisez: /login motdepasse'
+wrong_pwd: '&cMauvais MotDePasse'
+unregistered: '&cVous avez ete desenregistrer!'
+reg_disabled: '&cL''enregistrement est desactiver'
+valid_session: '&cVous etes authentifier'
+login: '&cLogin effectuer!'
+vb_nonActiv: '&fCe compte n''est pas activer, consultez vos emails!'
+user_regged: '&cCe nom est deja utiliser'
+usage_reg: '&cUtilisez la commande /register motdepasse confirmermotdepasse'
+max_reg: '&fLimite d''enregistrement atteinte pour cet account'
+no_perm: '&cVous n''avez pas la permission'
+error: '&fUne erreur est apparue, veuillez contacter un administrateur'
+login_msg: '&cConnectez-vous via un /login motdepasse'
+reg_msg: '&cUtilisez /register motdepasse confirmermotdepasse'
+usage_unreg: '&cUtilisez: /unregister password'
+pwd_changed: '&cMotdePasse changer avec succes!'
+user_unknown: '&c Ce pseudo n est pas enregistrer'
+password_error: '&fCe mot de passe est incorrect'
+unvalid_session: '&fSession invalide, relancez le jeu ou attendez la fin de la session'
+reg_only: '&fSeul les joueurs enregistrer sont admis!'
+logged_in: '&cVous etes deja connecter!'
+logout: '&cVous avez ete deconnecter'
+same_nick: '&fUne personne ayant ce pseudo joue deja !'
+registered: '&cEnregistrement reussi!'
+pass_len: '&fVotre mot de passe ne respecte pas les normes de longueurs'
+reload: '&fConfig et BDD ont ete relancer'
+timeout: '&fVous avez ete expulser, trop lent pour vous enregistrer !'
+usage_changepassword: '&fCommande /changepassword ancienmdp nouveaumdp'
+name_len: '&cVotre pseudo est trop long ou trop court'
+regex: '&cVotre pseudo contient des caracteres interdits! Caracteres Autorises: REG_EX'
+add_email: '&cMerci d''ajouter votre email : /email add yourEmail confirmEmail'
+bad_database_email: '[AuthMe] La commande /email est disponible uniquement pour MySQL et SQLite, contactez un Admin'
+recovery_email: '&cOublie de MotDePasse? Utilisez /email recovery '
+usage_captcha: '&cTrop de Mauvais MotDePasse, utilisez: /captcha '
+wrong_captcha: '&cCaptcha Incorrect, entrez de nouveau : /captcha THE_CAPTCHA'
+valid_captcha: '&cLe Captcha est valide, Merci!'
\ No newline at end of file
diff --git a/src/main/resources/messages_hu.yml b/src/main/resources/messages_hu.yml
new file mode 100644
index 00000000..0f302655
--- /dev/null
+++ b/src/main/resources/messages_hu.yml
@@ -0,0 +1,40 @@
+reg_only: Csak regisztrlt jtkosoknak! Jelentkezni a yndicraft@freemail.hu e-mail cmen lehet
+usage_unreg: '&cHasznlat: /unregister jelsz'
+registered: '&aSikeres regisztrci. dvzllek!'
+user_regged: '&cJtkosnv mr regisztrlva'
+login_msg: '&cKrlek jelentkezz be: "/login jelsz"'
+not_logged_in: '&cNem vagy bejelentkezve!'
+logout: '&cSikeresen kijelentkeztl'
+usage_log: '&cBejelentkezs: /login jelsz'
+unknown_user: User is not in database
+reg_voluntarily: Regisztrlhatod beceneved a szerveren a kvetkez parancsal "/register jelsz jelsz"
+reg_disabled: '&cRegisztrci letiltva'
+no_perm: '&cNincs engedlyed'
+usage_reg: '&cHasznlat: /register jelsz jelszjra'
+unregistered: '&cRegisztrci sikeresen trlve!'
+same_nick: Ezen a jtkosnven mr jtszanak
+valid_session: '&cSession login'
+pwd_changed: '&cJelsz cserlve!'
+reload: Beltsok s adatbzis jratltve!
+timeout: Bejelentkezsi idtllps
+error: Hiba lpett fel; Lpj kapcsolatba a tulajjal'
+logged_in: '&cMr be vagy jelentkezve!'
+login: '&aSikeresen Belptl! dvzllek!!!'
+wrong_pwd: '&4Hibs jelsz'
+user_unknown: '&cJtkosnv nem regisztrlt'
+reg_msg: '&cKrlek Regisztrlj: "/register jelsz jelszjra"'
+unsafe_spawn: A kilpsi helyzeted nem biztonsgos, teleportls a kezd Spawnra.
+max_reg: Csak egy karakterrel Registrlhatsz!!!
+password_error: A jelsz nem illik ssze
+unvalid_session: Session Dataes doesnt corrispond Plaese wait the end of session
+pass_len: A jelszavad nem ri el a minimlis hosszat
+vb_nonActiv: Your Account isent Activated yet check your Emails!
+usage_changepassword: 'hasznlat: /changepassword rgiJelsz jJelsz'
+name_len: '&cYour nickname is too Short or too long'
+regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
+add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
+bad_database_email: '[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin'
+recovery_email: '&cForgot your password? Please use /email recovery '
+usage_captcha: '&cUsage: /captcha '
+wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
+valid_captcha: '&cYour captcha is valid !'
diff --git a/src/main/resources/messages_pl.yml b/src/main/resources/messages_pl.yml
new file mode 100644
index 00000000..e0d12938
--- /dev/null
+++ b/src/main/resources/messages_pl.yml
@@ -0,0 +1,40 @@
+logged_in: '&fJestes juz zalogowany!'
+not_logged_in: '&4Nie jestes zalogowany!'
+reg_disabled: '&4Rejestracja jest wylaczona'
+user_regged: '&4Gracz juz jest zarejestrowany'
+usage_reg: '&4Uzycie: /register haslo ponownie_haslo'
+usage_log: '&cUzycie: /login haslo'
+user_unknown: '&fGracz nie jest zarejestrowany'
+pwd_changed: '&fHaslo zostalo zmienione!'
+reg_only: '&fTylko zarejestrowani uzytkownicy maja do tego dostep!'
+valid_session: '&cSesja logowania'
+login_msg: '&2Prosze sie zalogowac przy uzyciu &6/login '
+reg_msg: '&2Prosze sie zarejestrowac przy uzyciu &6/register '
+timeout: '&fUplynal limit czasu zalogowania'
+wrong_pwd: '&cNiepoprawne haslo'
+logout: '&cPomyslnie wylogowany'
+usage_unreg: '&cUzycie: /unregister haslo'
+registered: '&aPomyslnie zarejestrowany!'
+unregistered: '&4Pomyslnie odrejestrowany!'
+login: '&aHaslo zaakceptowane!'
+no_perm: '&4Nie masz uprawnien'
+same_nick: '&fTen nick juz gra'
+reg_voluntarily: '&fMozesz zarejestrowac swoj nick na serwerze przy uzyciu "/register haslo ponownie_haslo"'
+reload: '&fKonfiguracja bazy danych zostala przeladowana'
+error: '&fBlad prosimy napisac do aministracji'
+unknown_user: '&fUzytkownika nie ma w bazie danych'
+unsafe_spawn: '&fTwoje pozycja jest niebezpieczna. Zostaniesz przeniesiony na bezpieczny spawn.'
+unvalid_session: '&fSesja zakonczona!'
+max_reg: '&fPrzekroczyles limit zarejestrowanych kont na serwerze.'
+password_error: '&fHaslo niepoprawne!'
+pass_len: '&fTwoje haslo jest za krotkie lub za dlugie! Sprobuj ponownie..'
+vb_nonActiv: '&fTwoje konto nie zostalo aktywowane! Sprawdz maila.'
+usage_changepassword: '&fUzycie: /changepassword starehaslo nowehaslo'
+name_len: '&cYour nickname is too Short or too long'
+regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
+add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
+bad_database_email: '[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin'
+recovery_email: '&cForgot your password? Please use /email recovery '
+usage_captcha: '&cUsage: /captcha '
+wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
+valid_captcha: '&cYour captcha is valid !'
diff --git a/src/main/resources/messages_ru.yml b/src/main/resources/messages_ru.yml
new file mode 100644
index 00000000..488b1716
--- /dev/null
+++ b/src/main/resources/messages_ru.yml
@@ -0,0 +1,42 @@
+unknown_user: '&cЭтого игрока нет в базе'
+unsafe_spawn: '&6Твоё расположение перед выходом из игры было небезопасным - &aты
+ перенесён на спавн'
+not_logged_in: '&cТы не в игре!'
+reg_voluntarily: '&eЗарегистрируйся - &d/reg ПАРОЛЬ ПОВТОР_ПАРОЛЯ &eили &d/register
+ ПАРОЛЬ ПОВТОР_ПАРОЛЯ'
+usage_log: '&eСинтаксис: &d/l ПАРОЛЬ &eили &d/login ПАРОЛЬ'
+wrong_pwd: '&cНеправильный пароль'
+unregistered: '&aРегистрация снята'
+reg_disabled: '&6Регистрация отключена'
+valid_session: '&aСессия открыта'
+login: '&aТы в игре'
+vb_nonActiv: '&aТвой аккаунт активирован. &5Проверь свою электронную почту.'
+user_regged: '&cЭтот игрок уже зарегистрирован'
+usage_reg: '&eСинтаксис: &d/reg ПАРОЛЬ ПОВТОР_ПАРОЛЯ &eили &d/register ПАРОЛЬ ПОВТОР_ПАРОЛЯ'
+max_reg: '&cТы превысил максимальное число регистраций'
+no_perm: '&cНет разрешения'
+error: '&cЧто-то пошло не так... &5Свяжись с администратором.'
+login_msg: '&eВойди в игру - &d/l ПАРОЛЬ &eили &d/login ПАРОЛЬ'
+reg_msg: '&eЗарегистрируйся - &d/reg ПАРОЛЬ ПОВТОР_ПАРОЛЯ &eили &d/register ПАРОЛЬ
+ ПОВТОР_ПАРОЛЯ'
+usage_unreg: '&eСинтаксис: &d/unregister ПАРОЛЬ'
+pwd_changed: '&aПароль изменён'
+user_unknown: '&cТакой игрок не зарегистрирован'
+password_error: '&cПароль не найден'
+unvalid_session: '&cДата сессии некорректна. &5Дождись конца сессии.'
+reg_only: '&cРегистрация только для игроков! &5Зайди на &dhttp://example.com &5для
+ регистрации.'
+logged_in: '&cТы уже в матрице!'
+logout: '&aТы вышел с сервера'
+same_nick: '&cЭтот игрок уже играет'
+registered: '&aУспешная регистрация'
+pass_len: '&cТвой пароль либо слишком длинный, либо слишком короткий'
+reload: '&aКонфигурация и база данных перезагружена'
+timeout: '&cТы не успел войти в игру'
+usage_changepassword: '&eСинтаксис: &d/changepassword СТАРЫЙ_ПАРОЛЬ НОВЫЙ_ПАРОЛЬ'
+name_len: '&cТвой ник либо слишком длинный, либо слишком короткий'
+regex: '&cТвой ник содержит недопустимые символы. Разрешено использовать: REG_EX'
+add_email: '&eДобавь свой email: &d/email add АДРЕС_ПОЧТЫ ПОВТОР_АДРЕСА_ПОЧТЫ'
+bad_database_email: '&c[AuthMe] Команда &d/email&c доступна только при работе с MySQL
+ или SQLite'
+recovery_email: '&cЗабыл пароль? Используй команду &d/email recovery <АДРЕС_ПОЧТЫ>'
diff --git a/src/main/resources/messages_sk.yml b/src/main/resources/messages_sk.yml
new file mode 100644
index 00000000..38f23846
--- /dev/null
+++ b/src/main/resources/messages_sk.yml
@@ -0,0 +1,44 @@
+# Slovak translate by Judzi #
+# www.judzi.eu | judzi@cs-gaming.eu #
+# 02.02.2013 - 4:35 AM - Thanks for use #
+
+logged_in: '&cAktuálne si uz prihláseny!'
+not_logged_in: '&cNie si este prihláseny!'
+reg_disabled: '&cRegistrácia nie je povolená'
+user_regged: '&cZadané meno je uz zaregistrované'
+usage_reg: '&cPríkaz: /register heslo zopakujHeslo'
+usage_log: '&cPríkaz: /login heslo'
+user_unknown: '&cZadané meno nie je zaregistrované!'
+pwd_changed: '&cHeslo zmenené!'
+reg_only: '&fVstup iba pre registrovanych! Navstiv http://www.cs-gaming.eu pre registráciu'
+valid_session: '&cZapamätané prihlásenie'
+login_msg: '&cPrihlás sa príkazom "/login heslo"'
+reg_msg: '&cZaregistruj sa príkazom "/register heslo zopakujHeslo"'
+timeout: '&fVyprsal cas na prihlásenie'
+wrong_pwd: '&cZadal si zlé heslo'
+logout: '&cBol si úspesne odhláseny'
+usage_unreg: '&cPríkaz: /unregister heslo'
+registered: '&cBol si úspesne zaregistrovany'
+unregistered: '&cUcet bol vymazany!'
+login: '&cBol si úspesne prihláseny!'
+no_perm: '&cZiadne'
+same_nick: '&fHrác s tymto nickom uz hrá!'
+reg_voluntarily: '&fZaregistruj sa pomocou príkazu "/register heslo zopakujHeslo"'
+reload: '&fKonfigurácia a databáza bola obnovená'
+error: '&fNastala chyba; Kontaktujte administrátora'
+unknown_user: '&fHrac nie je v databázi'
+unsafe_spawn: '&fTvoj pozícia bol nebezpecná, teleportujem hraca na spawn'
+unvalid_session: '&fZapamätane casove data nie su doveryhodne. Cakaj na ukoncenie spojenia'
+max_reg: '&fDosiahol si maximum registrovanych uctov.'
+password_error: '&fHeslá sa nezhodujú'
+pass_len: '&fHeslo je velmi kratke alebo dlhe'
+vb_nonActiv: '&fUcet nie je aktivny. Prezri si svoj e-mail!'
+usage_changepassword: '&fPríkaz: /changepassword stareHeslo noveHeslo'
+name_len: '&cTvoje meno je velmi krátke alebo dlhé'
+regex: '&cTvoje meno obsahuje zakázané znaky. Povolené znaky: REG_EX'
+add_email: '&cPridaj svoj e-mail príkazom "/email add email zopakujEmail"'
+bad_database_email: '[AuthMe] Tento príkaz je dostupny iba pri MySQL SQLite'
+recovery_email: '&cZabudol si heslo? Pouzi príkaz /email recovery '
+usage_captcha: '&cUsage: /captcha '
+wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
+valid_captcha: '&cYour captcha is valid !'
\ No newline at end of file
diff --git a/src/main/resources/players.yml b/src/main/resources/players.yml
new file mode 100644
index 00000000..cf746f52
--- /dev/null
+++ b/src/main/resources/players.yml
@@ -0,0 +1 @@
+players: []
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 00000000..1f07e70b
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,128 @@
+name: AuthMe
+author: darkwarriros,Xephi
+website: http://www.multiplayer-italia.com/
+description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
+main: uk.org.whoami.authme.AuthMe
+version: 2.7.10b1
+softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag]
+commands:
+ register:
+ description: Register an account
+ usage: /register password confirmpassword
+ aliases: reg
+ login:
+ description: Login into a account
+ usage: /login password
+ aliases: l
+ changepassword:
+ description: Change password of a account
+ usage: /changepassword oldPassword newPassword
+ logout:
+ description: Logout
+ usage: /logout
+ unregister:
+ description: unregister your account
+ usage: /unregister password
+ passpartu:
+ description: compare passpartu token
+ usage: /passpartu token
+ authme:
+ description: AuthMe op commands
+ usage: '/authme reload|register playername password|changepassword playername password|unregister playername|version'
+ email:
+ description: Add Email or recover password
+ usage: '/email add your@email.com your@email.com|change oldEmail newEmail|recovery your@email.com'
+ captcha:
+ description: Captcha
+ usage: /captcha theCaptcha
+permissions:
+ authme.player.*:
+ description: Gives access to all authme player commands
+ default: true
+ children:
+ authme.register: true
+ authme.login: true
+ authme.changepassword: true
+ authme.logout: true
+ authme.unregister: true
+ authme.passpartu: true
+ authme.l: true
+ authme.reg: true
+ authme.admin.*:
+ description: Gives access to all authme admin commands
+ children:
+ authme.admin.reload: true
+ authme.admin.register: true
+ authme.admin.changepassword: true
+ authme.admin.unregister: true
+ authme.admin.purge: true
+ authme.seeOtherAccounts: true
+ authme.admin.lastlogin: true
+ authme.admin.getemail: true
+ authme.admin.chgemail: true
+ authme.register:
+ description: Register an account
+ default: true
+ authme.login:
+ description: Login into a account
+ default: true
+ authme.changepassword:
+ description: Change password of a account
+ default: true
+ authme.logout:
+ description: Logout
+ default: true
+ authme.email:
+ description: Email
+ default: true
+ authme.passpartu:
+ description: passpartu
+ default: true
+ authme.allow2accounts:
+ description: allow more accounts for same ip
+ default: false
+ authme.seeOtherAccounts:
+ description: display other accounts about a player when he logs in
+ default: false
+ authme.unregister:
+ description: unregister your account
+ default: true
+ authme.admin.reload:
+ description: AuthMe reload commands
+ default: op
+ authme.admin.register:
+ description: AuthMe register command
+ default: op
+ authme.admin.changepassword:
+ description: AuthMe changepassword command
+ default: op
+ authme.admin.unregister:
+ description: AuthMe unregister command
+ default: op
+ authme.admin.purge:
+ description: AuthMe unregister command
+ default: op
+ authme.admin.convertflattosql:
+ description: Convert File to Sql method
+ default: op
+ authme.admin.convertfromrakamak:
+ description: Convert from Rakamak database to AuthMe
+ default: op
+ authme.admin.lastlogin:
+ description: Get last login date about a player
+ default: op
+ authme.admin.getemail:
+ description: Get last email about a player
+ default: op
+ authme.admin.chgemail:
+ description: Change a player email
+ default: op
+ authme.admin.accounts:
+ description: Display Players Accounts
+ default: op
+ authme.admin.xauthimport:
+ description: Import xAuth Database to AuthMe Database
+ default: op
+ authme.captcha:
+ description: Captcha
+ default: true
diff --git a/src/plugin.yml b/src/plugin.yml
new file mode 100644
index 00000000..14add553
--- /dev/null
+++ b/src/plugin.yml
@@ -0,0 +1,97 @@
+name: AuthMe
+author: darkwarriros,Xephi
+website: http://www.multiplayer-italia.com/
+description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
+main: uk.org.whoami.authme.AuthMe
+version: 2.7.2b3
+softdepend: [Vault]
+commands:
+ register:
+ description: Register an account
+ usage: /register password confirmpassword
+ aliases: reg
+ login:
+ description: Login into a account
+ usage: /login password
+ aliases: l
+ changepassword:
+ description: Change password of a account
+ usage: /changepassword oldPassword newPassword
+ logout:
+ description: Logout
+ usage: /logout
+ unregister:
+ description: unregister your account
+ usage: /unregister password
+ passpartu:
+ description: compare passpartu token
+ usage: /passpartu token
+ authme:
+ description: AuthMe op commands
+ usage: '/authme reload|register playername password|changepassword playername password|unregister playername|version'
+permissions:
+ authme.player.*:
+ description: Gives access to all authme player commands
+ default: true
+ children:
+ authme.register: true
+ authme.login: true
+ authme.changepassword: true
+ authme.logout: true
+ authme.unregister: true
+ authme.passpartu: true
+ authme.l: true
+ authme.reg: true
+ authme.admin.*:
+ description: Gives access to all authme admin commands
+ children:
+ authme.admin.reload: true
+ authme.admin.register: true
+ authme.admin.changepassword: true
+ authme.admin.unregister: true
+ authme.admin.purge: true
+ authme.register:
+ description: Register an account
+ default: true
+ authme.login:
+ description: Login into a account
+ default: true
+ authme.changepassword:
+ description: Change password of a account
+ default: true
+ authme.logout:
+ description: Logout
+ default: true
+ authme.passpartu:
+ description: passpartu
+ default: true
+ authme.allow2accounts:
+ description: allow more accounts for same ip
+ default: false
+ authme.unregister:
+ description: unregister your account
+ default: true
+ authme.admin.reload:
+ description: AuthMe reload commands
+ default: op
+ authme.admin.register:
+ description: AuthMe register command
+ default: op
+ authme.admin.changepassword:
+ description: AuthMe changepassword command
+ default: op
+ authme.admin.unregister:
+ description: AuthMe unregister command
+ default: op
+ authme.admin.purge:
+ description: AuthMe unregister command
+ default: op
+ authme.admin.convertflattosql:
+ description: Convert File to Sql method
+ default: op
+ authme.admin.convertfromrakamak:
+ description: Convert from Rakamak database to AuthMe
+ default: op
+ authme.admin.lastlogin:
+ description: Get last login date about a player
+ default: op
\ No newline at end of file