Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 347-config-rewrite

This commit is contained in:
ljacqu 2016-01-07 21:51:20 +01:00
commit 7d749801f9
10 changed files with 220 additions and 637 deletions

View File

@ -32,7 +32,6 @@ import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.listener.AuthMePlayerListener16; import fr.xephi.authme.listener.AuthMePlayerListener16;
import fr.xephi.authme.listener.AuthMePlayerListener18; import fr.xephi.authme.listener.AuthMePlayerListener18;
import fr.xephi.authme.listener.AuthMeServerListener; import fr.xephi.authme.listener.AuthMeServerListener;
import fr.xephi.authme.listener.AuthMeServerStop;
import fr.xephi.authme.listener.AuthMeTabCompletePacketAdapter; import fr.xephi.authme.listener.AuthMeTabCompletePacketAdapter;
import fr.xephi.authme.mail.SendMailSSL; import fr.xephi.authme.mail.SendMailSSL;
import fr.xephi.authme.modules.ModuleManager; import fr.xephi.authme.modules.ModuleManager;
@ -307,13 +306,6 @@ public class AuthMe extends JavaPlugin {
// Show settings warnings // Show settings warnings
showSettingsWarnings(); showSettingsWarnings();
// Register a server shutdown hook
try {
Runtime.getRuntime().addShutdownHook(new AuthMeServerStop(this));
} catch (Exception e) {
e.printStackTrace();
}
// Sponsor messages // Sponsor messages
ConsoleLogger.info("AuthMe hooks perfectly with the VeryGames server hosting!"); ConsoleLogger.info("AuthMe hooks perfectly with the VeryGames server hosting!");
ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt."); ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt.");
@ -521,10 +513,10 @@ public class AuthMe extends JavaPlugin {
public void onDisable() { public void onDisable() {
// Save player data // Save player data
Collection<? extends Player> players = Utils.getOnlinePlayers(); Collection<? extends Player> players = Utils.getOnlinePlayers();
if (players != null) {
for (Player player : players) { for (Player player : players) {
this.savePlayer(player); savePlayer(player);
} // TODO: add a MessageKey
player.kickPlayer("Server is restarting or AuthMe plugin was disabled.");
} }
// Do backup on stop if enabled // Do backup on stop if enabled

View File

@ -1,11 +1,5 @@
package fr.xephi.authme.datasource; package fr.xephi.authme.datasource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
@ -13,10 +7,16 @@ import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener; import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalListeners; import com.google.common.cache.RemovalListeners;
import com.google.common.cache.RemovalNotification; import com.google.common.cache.RemovalNotification;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/** /**
*/ */
public class CacheDataSource implements DataSource { public class CacheDataSource implements DataSource {
@ -52,44 +52,17 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method isAuthAvailable.
*
* @param user String
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
return getAuth(user) != null; return getAuth(user) != null;
} }
/**
* Method getAuth.
*
* @param user String
*
* @return PlayerAuth
*
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
user = user.toLowerCase(); user = user.toLowerCase();
return cachedAuths.getUnchecked(user).orNull(); return cachedAuths.getUnchecked(user).orNull();
} }
/**
* Method saveAuth.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(PlayerAuth auth) { public synchronized boolean saveAuth(PlayerAuth auth) {
boolean result = source.saveAuth(auth); boolean result = source.saveAuth(auth);
@ -99,15 +72,6 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method updatePassword.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(PlayerAuth auth) { public synchronized boolean updatePassword(PlayerAuth auth) {
boolean result = source.updatePassword(auth); boolean result = source.updatePassword(auth);
@ -117,15 +81,6 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method updateSession.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public boolean updateSession(PlayerAuth auth) { public boolean updateSession(PlayerAuth auth) {
boolean result = source.updateSession(auth); boolean result = source.updateSession(auth);
@ -135,47 +90,20 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method updateQuitLoc.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public boolean updateQuitLoc(final PlayerAuth auth) { public boolean updateQuitLoc(final PlayerAuth auth) {
boolean result = source.updateSession(auth); boolean result = source.updateQuitLoc(auth);
if (result) { if (result) {
cachedAuths.refresh(auth.getNickname()); cachedAuths.refresh(auth.getNickname());
} }
return result; return result;
} }
/**
* Method getIps.
*
* @param ip String
*
* @return int
*
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public int getIps(String ip) { public int getIps(String ip) {
return source.getIps(ip); return source.getIps(ip);
} }
/**
* Method purgeDatabase.
*
* @param until long
*
* @return int
*
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public int purgeDatabase(long until) { public int purgeDatabase(long until) {
int cleared = source.purgeDatabase(until); int cleared = source.purgeDatabase(until);
@ -189,15 +117,6 @@ public class CacheDataSource implements DataSource {
return cleared; return cleared;
} }
/**
* Method autoPurgeDatabase.
*
* @param until long
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public List<String> autoPurgeDatabase(long until) { public List<String> autoPurgeDatabase(long until) {
List<String> cleared = source.autoPurgeDatabase(until); List<String> cleared = source.autoPurgeDatabase(until);
@ -207,15 +126,6 @@ public class CacheDataSource implements DataSource {
return cleared; return cleared;
} }
/**
* Method removeAuth.
*
* @param name String
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String name) { public synchronized boolean removeAuth(String name) {
name = name.toLowerCase(); name = name.toLowerCase();
@ -226,22 +136,17 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method close.
*
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
try {
exec.shutdown(); exec.shutdown();
exec.awaitTermination(8, TimeUnit.SECONDS);
} catch (InterruptedException e) {
ConsoleLogger.writeStackTrace(e);
}
source.close(); source.close();
} }
/**
* Method reload.
*
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { // unused method public void reload() { // unused method
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -253,15 +158,6 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method updateEmail.
*
* @param auth PlayerAuth
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateEmail(final PlayerAuth auth) { public synchronized boolean updateEmail(final PlayerAuth auth) {
boolean result = source.updateEmail(auth); boolean result = source.updateEmail(auth);
@ -271,55 +167,21 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method getAllAuthsByName.
*
* @param auth PlayerAuth
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) { public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
return source.getAllAuthsByName(auth); return source.getAllAuthsByName(auth);
} }
/**
* Method getAllAuthsByIp.
*
* @param ip String
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByIp(final String ip) { public synchronized List<String> getAllAuthsByIp(final String ip) {
return source.getAllAuthsByIp(ip); return source.getAllAuthsByIp(ip);
} }
/**
* Method getAllAuthsByEmail.
*
* @param email String
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByEmail(final String email) { public synchronized List<String> getAllAuthsByEmail(final String email) {
return source.getAllAuthsByEmail(email); return source.getAllAuthsByEmail(email);
} }
/**
* Method purgeBanned.
*
* @param banned List of String
*
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List)
*/
@Override @Override
public synchronized void purgeBanned(final List<String> banned) { public synchronized void purgeBanned(final List<String> banned) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -331,39 +193,16 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getType.
*
* @return DataSourceType
*
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return source.getType(); return source.getType();
} }
/**
* Method isLogged.
*
* @param user String
*
* @return boolean
*
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
return PlayerCache.getInstance().isAuthenticated(user); return PlayerCache.getInstance().isAuthenticated(user);
} }
/**
* Method setLogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(final String user) { public void setLogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -374,13 +213,6 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method setUnlogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(final String user) { public void setUnlogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -391,11 +223,6 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method purgeLogged.
*
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -407,26 +234,11 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getAccountsRegistered.
*
* @return int
*
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
return source.getAccountsRegistered(); return source.getAccountsRegistered();
} }
/**
* Method updateName.
*
* @param oldOne String
* @param newOne String
*
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override @Override
public void updateName(final String oldOne, final String newOne) { public void updateName(final String oldOne, final String newOne) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -438,25 +250,11 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getAllAuths.
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
return source.getAllAuths(); return source.getAllAuths();
} }
/**
* Method getLoggedPlayers.
*
* @return List
*
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
return new ArrayList<>(PlayerCache.getInstance().getCache().values()); return new ArrayList<>(PlayerCache.getInstance().getCache().values());

View File

@ -70,12 +70,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method connect.
*
* @throws ClassNotFoundException
* @throws SQLException
*/
private synchronized void connect() throws ClassNotFoundException, SQLException { private synchronized void connect() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded"); ConsoleLogger.info("SQLite driver loaded");
@ -83,11 +77,6 @@ public class SQLite implements DataSource {
} }
/**
* Method setup.
*
* @throws SQLException
*/
private synchronized void setup() throws SQLException { private synchronized void setup() throws SQLException {
Statement st = null; Statement st = null;
ResultSet rs = null; ResultSet rs = null;
@ -149,14 +138,6 @@ public class SQLite implements DataSource {
ConsoleLogger.info("SQLite Setup finished"); ConsoleLogger.info("SQLite Setup finished");
} }
/**
* Method isAuthAvailable.
*
* @param user String
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -175,14 +156,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAuth.
*
* @param user String
*
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -205,14 +178,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method saveAuth.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(PlayerAuth auth) { public synchronized boolean saveAuth(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -252,14 +217,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updatePassword.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(PlayerAuth auth) { public synchronized boolean updatePassword(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -287,14 +244,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updateSession.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public boolean updateSession(PlayerAuth auth) { public boolean updateSession(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -314,14 +263,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method purgeDatabase.
*
* @param until long
*
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public int purgeDatabase(long until) { public int purgeDatabase(long until) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -338,14 +279,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method autoPurgeDatabase.
*
* @param until long
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public List<String> autoPurgeDatabase(long until) { public List<String> autoPurgeDatabase(long until) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -368,14 +301,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method removeAuth.
*
* @param user String
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String user) { public synchronized boolean removeAuth(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -392,14 +317,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updateQuitLoc.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public boolean updateQuitLoc(PlayerAuth auth) { public boolean updateQuitLoc(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -420,14 +337,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method getIps.
*
* @param ip String
*
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public int getIps(String ip) { public int getIps(String ip) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -451,14 +360,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method updateEmail.
*
* @param auth PlayerAuth
*
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public boolean updateEmail(PlayerAuth auth) { public boolean updateEmail(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -476,11 +377,6 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method close.
*
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
try { try {
@ -490,20 +386,10 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method reload.
*
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { public void reload() {
} }
/**
* Method close.
*
* @param st Statement
*/
private void close(Statement st) { private void close(Statement st) {
if (st != null) { if (st != null) {
try { try {
@ -514,11 +400,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method close.
*
* @param rs ResultSet
*/
private void close(ResultSet rs) { private void close(ResultSet rs) {
if (rs != null) { if (rs != null) {
try { try {
@ -529,14 +410,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByName.
*
* @param auth PlayerAuth
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public List<String> getAllAuthsByName(PlayerAuth auth) { public List<String> getAllAuthsByName(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -561,14 +434,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByIp.
*
* @param ip String
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public List<String> getAllAuthsByIp(String ip) { public List<String> getAllAuthsByIp(String ip) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -593,14 +458,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByEmail.
*
* @param email String
*
* @return List of String
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public List<String> getAllAuthsByEmail(String email) { public List<String> getAllAuthsByEmail(String email) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -641,24 +498,11 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getType.
*
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return DataSourceType.SQLITE; return DataSourceType.SQLITE;
} }
/**
* Method isLogged.
*
* @param user String
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -679,13 +523,6 @@ public class SQLite implements DataSource {
return false; return false;
} }
/**
* Method setLogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(String user) { public void setLogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -701,13 +538,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method setUnlogged.
*
* @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(String user) { public void setUnlogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -724,11 +554,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method purgeLogged.
*
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -744,12 +569,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAccountsRegistered.
*
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
int result = 0; int result = 0;
@ -785,11 +604,6 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuths.
*
* @return List of PlayerAuth
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();
@ -811,11 +625,6 @@ public class SQLite implements DataSource {
return auths; return auths;
} }
/**
* Method getLoggedPlayers.
*
* @return List of PlayerAuth
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();

View File

@ -221,7 +221,7 @@ public class AuthMePlayerListener implements Listener {
PlayerAuth auth = plugin.getDataSource().getAuth(event.getName()); PlayerAuth auth = plugin.getDataSource().getAuth(event.getName());
if (Settings.preventOtherCase && auth != null && auth.getRealName() != null) { if (Settings.preventOtherCase && auth != null && auth.getRealName() != null) {
String realName = auth.getRealName(); String realName = auth.getRealName();
if(!realName.isEmpty() && !realName.equals("Player") && !realName.equals(event.getName())) { if (!realName.isEmpty() && !realName.equals("Player") && !realName.equals(event.getName())) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
// TODO: Add a message like : MessageKey.INVALID_NAME_CASE // TODO: Add a message like : MessageKey.INVALID_NAME_CASE
event.setKickMessage("You should join using username: " + ChatColor.AQUA + realName + event.setKickMessage("You should join using username: " + ChatColor.AQUA + realName +
@ -274,8 +274,8 @@ public class AuthMePlayerListener implements Listener {
// Get the permissions manager // Get the permissions manager
PermissionsManager permsMan = plugin.getPermissionsManager(); PermissionsManager permsMan = plugin.getPermissionsManager();
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL) {
&& permsMan.hasPermission(player, PlayerPermission.IS_VIP)) { if (permsMan.hasPermission(player, PlayerPermission.IS_VIP)) {
int playersOnline = Utils.getOnlinePlayers().size(); int playersOnline = Utils.getOnlinePlayers().size();
if (playersOnline > plugin.getServer().getMaxPlayers()) { if (playersOnline > plugin.getServer().getMaxPlayers()) {
event.allow(); event.allow();
@ -290,18 +290,17 @@ public class AuthMePlayerListener implements Listener {
event.setResult(PlayerLoginEvent.Result.KICK_FULL); event.setResult(PlayerLoginEvent.Result.KICK_FULL);
} }
} }
} else {
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_FULL_SERVER));
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
return;
}
} }
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
return; return;
} }
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL && !permsMan.hasPermission(player, PlayerPermission.IS_VIP)) {
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_FULL_SERVER));
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
return;
}
final String name = player.getName().toLowerCase(); final String name = player.getName().toLowerCase();
boolean isAuthAvailable = plugin.getDataSource().isAuthAvailable(name); boolean isAuthAvailable = plugin.getDataSource().isAuthAvailable(name);

View File

@ -1,30 +0,0 @@
package fr.xephi.authme.listener;
import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.settings.Settings;
public class AuthMeServerStop extends Thread {
private AuthMe plugin;
public AuthMeServerStop(AuthMe plugin) {
this.plugin = plugin;
}
public void run() {
// TODO: add a MessageKey
if (Settings.kickPlayersBeforeStopping) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
@Override
public void run() {
for (Player p : plugin.getServer().getOnlinePlayers()) {
p.kickPlayer("Server is restarting");
}
}
});
}
}
}

View File

@ -97,6 +97,8 @@ public enum MessageKey {
USAGE_ADD_EMAIL("usage_email_add"), USAGE_ADD_EMAIL("usage_email_add"),
USAGE_CHANGE_EMAIL("usage_email_change"),
USAGE_RECOVER_EMAIL("usage_email_recovery"), USAGE_RECOVER_EMAIL("usage_email_recovery"),
INVALID_NEW_EMAIL("new_email_invalid"), INVALID_NEW_EMAIL("new_email_invalid"),

View File

@ -298,8 +298,8 @@ public class PermissionsManager implements PermissionsService {
} }
Player player = (Player) sender; Player player = (Player) sender;
return hasPermission(player, permissionNode.getNode(), def) return hasPermission(player, permissionNode.getNode(), def);
|| hasPermission(player, permissionNode.getWildcardNode().getNode(), def); // || hasPermission(player, permissionNode.getWildcardNode().getNode(), def);
} }
public boolean hasPermission(Player player, Iterable<PermissionNode> nodes, boolean def) { public boolean hasPermission(Player player, Iterable<PermissionNode> nodes, boolean def) {

View File

@ -1,13 +1,12 @@
package fr.xephi.authme.process.email; package fr.xephi.authme.process.email;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages; import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.StringUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
@ -35,42 +34,37 @@ public class AsyncChangeEmail {
} }
public void process() { public void process() {
try {
String playerName = player.getName().toLowerCase(); String playerName = player.getName().toLowerCase();
if (Settings.getmaxRegPerEmail > 0) {
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
&& plugin.getDataSource().getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
return;
}
}
if (PlayerCache.getInstance().isAuthenticated(playerName)) { if (PlayerCache.getInstance().isAuthenticated(playerName)) {
if (!newEmail.equals(newEmailVerify)) { if (!newEmail.equals(newEmailVerify)) {
m.send(player, MessageKey.CONFIRM_EMAIL_MESSAGE); m.send(player, MessageKey.CONFIRM_EMAIL_MESSAGE);
return; return;
} }
PlayerAuth auth = PlayerCache.getInstance().getAuth(playerName); PlayerAuth auth = PlayerCache.getInstance().getAuth(playerName);
String currentEmail = auth.getEmail();
if (oldEmail != null) { if (oldEmail != null) {
if (auth.getEmail() == null || auth.getEmail().equals("your@email.com") || auth.getEmail().isEmpty()) { if (StringUtils.isEmpty(currentEmail) || currentEmail.equals("your@email.com")) {
m.send(player, MessageKey.USAGE_ADD_EMAIL); m.send(player, MessageKey.USAGE_ADD_EMAIL);
return; return;
} }
if (!oldEmail.equals(auth.getEmail())) { if (!oldEmail.equals(currentEmail)) {
m.send(player, MessageKey.INVALID_OLD_EMAIL); m.send(player, MessageKey.INVALID_OLD_EMAIL);
return; return;
} }
} else {
if (!StringUtils.isEmpty(currentEmail) && !currentEmail.equals("your@email.com")) {
m.send(player, MessageKey.USAGE_CHANGE_EMAIL);
return;
}
} }
if (!Settings.isEmailCorrect(newEmail)) { if (!Settings.isEmailCorrect(newEmail)) {
m.send(player, MessageKey.INVALID_NEW_EMAIL); m.send(player, MessageKey.INVALID_NEW_EMAIL);
return; return;
} }
String old = auth.getEmail();
auth.setEmail(newEmail); auth.setEmail(newEmail);
if (!plugin.getDataSource().updateEmail(auth)) { if (!plugin.getDataSource().updateEmail(auth)) {
m.send(player, MessageKey.ERROR); m.send(player, MessageKey.ERROR);
auth.setEmail(old); auth.setEmail(currentEmail);
return; return;
} }
PlayerCache.getInstance().updatePlayer(auth); PlayerCache.getInstance().updatePlayer(auth);
@ -91,10 +85,6 @@ public class AsyncChangeEmail {
} }
} }
} }
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
ConsoleLogger.writeStackTrace(e);
m.send(player, MessageKey.ERROR);
}
} }
} }

View File

@ -235,8 +235,7 @@ public final class Utils {
} }
public static Player getPlayer(String name) { public static Player getPlayer(String name) {
name = name.toLowerCase(); return wrapper.getServer().getPlayerExact(name);
return wrapper.getServer().getPlayer(name);
} }
public static boolean isNPC(Player player) { public static boolean isNPC(Player player) {

View File

@ -45,120 +45,144 @@ commands:
usage: /converter <datatype> usage: /converter <datatype>
permissions: permissions:
authme.admin.*: authme.admin.*:
description: Gives access to all authme admin commands description: Give access to all admin commands.
children: children:
authme.admin.reload: true authme.admin.accounts: true
authme.admin.register: true authme.admin.changemail: true
authme.admin.changepassword: true authme.admin.changepassword: true
authme.admin.unregister: true
authme.admin.purge: true
authme.seeOtherAccounts: true # This isn't a child of the admin section! Probably doesn't work.
authme.admin.lastlogin: true
authme.admin.getemail: true
authme.admin.chgemail: true
authme.admin.purgelastpos: true
authme.admin.switchantibot: true
authme.bypassantibot: true # This isn't a child of the admin section! Probably doesn't work.
authme.admin.getip: true
authme.admin.converter: true authme.admin.converter: true
authme.admin.resetposition: true authme.admin.firstspawn: true
authme.admin.forcelogin: true authme.admin.forcelogin: true
authme.register: authme.admin.getemail: true
description: Register an account authme.admin.getip: true
default: true authme.admin.lastlogin: true
authme.login: authme.admin.purge: true
description: Login into a account authme.admin.purgebannedplayers: true
default: true authme.admin.purgelastpos: true
authme.changepassword: authme.admin.register: true
description: Change password of a account authme.admin.reload: true
default: true authme.admin.setfirstspawn: true
authme.logout: authme.admin.setspawn: true
description: Logout authme.admin.spawn: true
default: true authme.admin.switchantibot: true
authme.email: authme.admin.unregister: true
description: Email
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: authme.admin.register:
description: AuthMe register command description: Administrator command to register a new user.
default: op
authme.admin.changepassword:
description: AuthMe changepassword command
default: op default: op
authme.admin.unregister: authme.admin.unregister:
description: AuthMe unregister command description: Administrator command to unregister an existing user.
default: op
authme.admin.purge:
description: AuthMe unregister command
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.captcha:
description: Captcha
default: true
authme.admin.setspawn:
description: Set the AuthMe spawn point
default: op
authme.admin.spawn:
description: Teleport to AuthMe spawn point
default: op
authme.vip:
description: Allow vip slot when the server is full
default: op
authme.admin.purgebannedplayers:
description: Purge banned players
default: op
authme.bypassforcesurvival:
description: Bypass all ForceSurvival features
default: false
authme.admin.purgelastpos:
description: Purge last pos of players
default: op
authme.admin.switchantibot:
description: Switch AntiBot mode on/off
default: op
authme.bypassantibot:
description: Bypass the AntiBot check
default: op
authme.admin.setfirstspawn:
description: Set the AuthMe First Spawn Point
default: op
authme.admin.firstspawn:
description: Teleport to AuthMe First Spawn Point
default: op
authme.admin.getip:
description: Get IP from a player ( fake and real )
default: op
authme.admin.converter:
description: Allow /converter command
default: op
authme.admin.resetposition:
description: Reset last position for a player
default: op default: op
authme.admin.forcelogin: authme.admin.forcelogin:
description: Force login for that player description: Administrator command to force-login an existing user.
default: op default: op
authme.canbeforced: authme.admin.changepassword:
description: Can this player be forced to login description: Administrator command to change the password of a user.
default: op
authme.admin.lastlogin:
description: Administrator command to see the last login date and time of a user.
default: op
authme.admin.accounts:
description: Administrator command to see all accounts associated with a user.
default: op
authme.admin.getemail:
description: Administrator command to get the email address of a user, if set.
default: op
authme.admin.changemail:
description: Administrator command to set or change the email address of a user.
default: op
authme.admin.getip:
description: Administrator command to get the last known IP of a user.
default: op
authme.admin.spawn:
description: Administrator command to teleport to the AuthMe spawn.
default: op
authme.admin.setspawn:
description: Administrator command to set the AuthMe spawn.
default: op
authme.admin.firstspawn:
description: Administrator command to teleport to the first AuthMe spawn.
default: op
authme.admin.setfirstspawn:
description: Administrator command to set the first AuthMe spawn.
default: op
authme.admin.purge:
description: Administrator command to purge old user data.
default: op
authme.admin.purgelastpos:
description: Administrator command to purge the last position of a user.
default: op
authme.admin.purgebannedplayers:
description: Administrator command to purge all data associated with banned players.
default: op
authme.admin.switchantibot:
description: Administrator command to toggle the AntiBot protection status.
default: op
authme.admin.converter:
description: Administrator command to convert old or other data to AuthMe data.
default: op
authme.admin.reload:
description: Administrator command to reload the plugin configuration.
default: op
authme.player.*:
description: Permission to use all player (non-admin) commands.
children:
authme.player.allow2accounts: true
authme.player.bypassantibot: true
authme.player.bypassforcesurvival: true
authme.player.canbeforced: true
authme.player.captcha: true
authme.player.changepassword: true
authme.player.email.add: true
authme.player.email.change: true
authme.player.email.recover: true
authme.player.login: true
authme.player.logout: true
authme.player.register: true
authme.player.seeotheraccounts: true
authme.player.unregister: true
authme.player.vip: true
authme.player.bypassantibot:
description: Permission node to bypass AntiBot protection.
default: false
authme.player.vip:
description: Permission node to identify VIP users.
default: false
authme.player.login:
description: Command permission to login.
default: true default: true
authme.player.logout:
description: Command permission to logout.
default: true
authme.player.register:
description: Command permission to register.
default: true
authme.player.unregister:
description: Command permission to unregister.
default: true
authme.player.changepassword:
description: Command permission to change the password.
default: true
authme.player.email.add:
description: Command permission to add an email address.
default: false
authme.player.email.change:
description: Command permission to change the email address.
default: false
authme.player.email.recover:
description: Command permission to recover an account using it's email address.
default: false
authme.player.captcha:
description: Command permission to use captcha.
default: false
authme.player.canbeforced:
description: Permission for users a login can be forced to.
default: false
authme.player.bypassforcesurvival:
description: Permission for users to bypass force-survival mode.
default: false
authme.player.allow2accounts:
description: Permission for users to allow two accounts.
default: false
authme.player.seeotheraccounts:
description: Permission for user to see other accounts.
default: false