mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-28 21:25:44 +01:00
Cleanup
This commit is contained in:
parent
5acf9c0d94
commit
81d240f4a4
@ -116,7 +116,6 @@ public class AuthMe extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
ThreadSafetyUtils.setEnabled(true);
|
||||
// Load the plugin version data from the plugin description file
|
||||
loadPluginInfo(getDescription().getVersion());
|
||||
|
||||
@ -172,6 +171,8 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
// Successful message
|
||||
logger.info("AuthMe " + getPluginVersion() + " build n." + getPluginBuildNumber() + " successfully enabled!");
|
||||
// Start catching wrong sync/async calls
|
||||
ThreadSafety.setEnabled(true);
|
||||
|
||||
// Purge on start if enabled
|
||||
PurgeService purgeService = injector.getSingleton(PurgeService.class);
|
||||
|
@ -2,15 +2,15 @@ package fr.xephi.authme;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public final class ThreadSafetyUtils {
|
||||
public final class ThreadSafety {
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
private ThreadSafetyUtils() {
|
||||
private ThreadSafety() {
|
||||
}
|
||||
|
||||
public static void setEnabled(boolean enabled) {
|
||||
ThreadSafetyUtils.enabled = enabled;
|
||||
ThreadSafety.enabled = enabled;
|
||||
}
|
||||
|
||||
public static void requireSync() {
|
@ -4,7 +4,7 @@ import ch.jalu.datasourcecolumns.data.DataSourceValue;
|
||||
import ch.jalu.datasourcecolumns.data.DataSourceValueImpl;
|
||||
import ch.jalu.datasourcecolumns.data.DataSourceValues;
|
||||
import ch.jalu.datasourcecolumns.predicate.AlwaysTruePredicate;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.columnshandler.AuthMeColumns;
|
||||
@ -31,7 +31,7 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean isAuthAvailable(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
try {
|
||||
return columnsHandler.retrieve(user, AuthMeColumns.NAME).rowExists();
|
||||
} catch (SQLException e) {
|
||||
@ -43,7 +43,7 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public HashedPassword getPassword(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
try {
|
||||
DataSourceValues values = columnsHandler.retrieve(user, AuthMeColumns.PASSWORD, AuthMeColumns.SALT);
|
||||
if (values.rowExists()) {
|
||||
@ -58,7 +58,7 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean saveAuth(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.insert(auth,
|
||||
AuthMeColumns.NAME, AuthMeColumns.NICK_NAME, AuthMeColumns.PASSWORD, AuthMeColumns.SALT,
|
||||
AuthMeColumns.EMAIL, AuthMeColumns.REGISTRATION_DATE, AuthMeColumns.REGISTRATION_IP,
|
||||
@ -68,7 +68,7 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean hasSession(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
try {
|
||||
DataSourceValue<Integer> result = columnsHandler.retrieve(user, AuthMeColumns.HAS_SESSION);
|
||||
return result.rowExists() && Integer.valueOf(1).equals(result.getValue());
|
||||
@ -81,21 +81,21 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.update(auth, AuthMeColumns.LAST_IP, AuthMeColumns.LAST_LOGIN, AuthMeColumns.NICK_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updatePassword(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return updatePassword(auth.getNickname(), auth.getPassword());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updatePassword(String user, HashedPassword password) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.update(user,
|
||||
with(AuthMeColumns.PASSWORD, password.getHash())
|
||||
.and(AuthMeColumns.SALT, password.getSalt()).build());
|
||||
@ -104,7 +104,7 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.update(auth,
|
||||
AuthMeColumns.LOCATION_X, AuthMeColumns.LOCATION_Y, AuthMeColumns.LOCATION_Z,
|
||||
AuthMeColumns.LOCATION_WORLD, AuthMeColumns.LOCATION_YAW, AuthMeColumns.LOCATION_PITCH);
|
||||
@ -113,7 +113,7 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
try {
|
||||
return columnsHandler.retrieve(eq(AuthMeColumns.LAST_IP, ip), AuthMeColumns.NAME);
|
||||
} catch (SQLException e) {
|
||||
@ -125,21 +125,21 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public int countAuthsByEmail(String email) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.count(eqIgnoreCase(AuthMeColumns.EMAIL, email));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.update(auth, AuthMeColumns.EMAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean isLogged(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
try {
|
||||
DataSourceValue<Integer> result = columnsHandler.retrieve(user, AuthMeColumns.IS_LOGGED);
|
||||
return result.rowExists() && Integer.valueOf(1).equals(result.getValue());
|
||||
@ -152,56 +152,56 @@ public abstract class AbstractSqlDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void setLogged(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
columnsHandler.update(user, AuthMeColumns.IS_LOGGED, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void setUnlogged(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
columnsHandler.update(user, AuthMeColumns.IS_LOGGED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void grantSession(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
columnsHandler.update(user, AuthMeColumns.HAS_SESSION, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void revokeSession(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
columnsHandler.update(user, AuthMeColumns.HAS_SESSION, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void purgeLogged() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
columnsHandler.update(eq(AuthMeColumns.IS_LOGGED, 1), AuthMeColumns.IS_LOGGED, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public int getAccountsRegistered() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.count(new AlwaysTruePredicate<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return columnsHandler.update(user, AuthMeColumns.NICK_NAME, realName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public DataSourceValue<String> getEmail(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
try {
|
||||
return columnsHandler.retrieve(user, AuthMeColumns.EMAIL);
|
||||
} catch (SQLException e) {
|
||||
|
@ -10,7 +10,7 @@ import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
@ -84,14 +84,14 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean isAuthAvailable(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return getAuth(user) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public HashedPassword getPassword(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
user = user.toLowerCase();
|
||||
Optional<PlayerAuth> pAuthOpt = cachedAuths.getIfPresent(user);
|
||||
if (pAuthOpt != null && pAuthOpt.isPresent()) {
|
||||
@ -103,7 +103,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public PlayerAuth getAuth(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
user = user.toLowerCase();
|
||||
return cachedAuths.getUnchecked(user).orElse(null);
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean saveAuth(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
boolean result = source.saveAuth(auth);
|
||||
if (result) {
|
||||
cachedAuths.refresh(auth.getNickname());
|
||||
@ -122,7 +122,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updatePassword(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
boolean result = source.updatePassword(auth);
|
||||
if (result) {
|
||||
cachedAuths.refresh(auth.getNickname());
|
||||
@ -133,7 +133,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updatePassword(String user, HashedPassword password) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
user = user.toLowerCase();
|
||||
boolean result = source.updatePassword(user, password);
|
||||
if (result) {
|
||||
@ -145,7 +145,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
boolean result = source.updateSession(auth);
|
||||
if (result) {
|
||||
cachedAuths.refresh(auth.getNickname());
|
||||
@ -156,7 +156,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateQuitLoc(final PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
boolean result = source.updateQuitLoc(auth);
|
||||
if (result) {
|
||||
cachedAuths.refresh(auth.getNickname());
|
||||
@ -167,14 +167,14 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public Set<String> getRecordsToPurge(long until) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.getRecordsToPurge(until);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean removeAuth(String name) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
name = name.toLowerCase();
|
||||
boolean result = source.removeAuth(name);
|
||||
if (result) {
|
||||
@ -198,7 +198,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateEmail(final PlayerAuth auth) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
boolean result = source.updateEmail(auth);
|
||||
if (result) {
|
||||
cachedAuths.refresh(auth.getNickname());
|
||||
@ -209,77 +209,77 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.getAllAuthsByIp(ip);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public int countAuthsByEmail(String email) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.countAuthsByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void purgeRecords(Collection<String> banned) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
source.purgeRecords(banned);
|
||||
cachedAuths.invalidateAll(banned);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean isLogged(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.isLogged(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void setLogged(final String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
source.setLogged(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void setUnlogged(final String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
source.setUnlogged(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean hasSession(final String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.hasSession(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void grantSession(final String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
source.grantSession(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void revokeSession(final String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
source.revokeSession(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void purgeLogged() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
source.purgeLogged();
|
||||
cachedAuths.invalidateAll();
|
||||
}
|
||||
@ -287,14 +287,14 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public int getAccountsRegistered() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.getAccountsRegistered();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean updateRealName(String user, String realName) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
boolean result = source.updateRealName(user, realName);
|
||||
if (result) {
|
||||
cachedAuths.refresh(user);
|
||||
@ -305,7 +305,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public DataSourceValue<String> getEmail(String user) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return cachedAuths.getUnchecked(user)
|
||||
.map(auth -> DataSourceValueImpl.of(auth.getEmail()))
|
||||
.orElse(DataSourceValueImpl.unknownRow());
|
||||
@ -314,14 +314,14 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.getAllAuths();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public List<String> getLoggedPlayersWithEmptyMail() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return playerCache.getCache().values().stream()
|
||||
.filter(auth -> Utils.isEmailEmpty(auth.getEmail()))
|
||||
.map(PlayerAuth::getRealName)
|
||||
@ -331,14 +331,14 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public List<PlayerAuth> getRecentlyLoggedInPlayers() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
return source.getRecentlyLoggedInPlayers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public boolean setTotpKey(String user, String totpKey) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
boolean result = source.setTotpKey(user, totpKey);
|
||||
if (result) {
|
||||
cachedAuths.refresh(user);
|
||||
@ -354,7 +354,7 @@ public class CacheDataSource implements DataSource {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void refreshCache(String playerName) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (cachedAuths.getIfPresent(playerName) != null) {
|
||||
cachedAuths.refresh(playerName);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import ch.jalu.datasourcecolumns.data.DataSourceValue;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.initialization.Reloadable;
|
||||
@ -313,7 +313,7 @@ public interface DataSource extends Reloadable {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
default void refreshCache(String playerName) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.MightBeAsync;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
@ -76,7 +76,7 @@ public class OnJoinVerifier implements Reloadable {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public void checkAntibot(String name, boolean isAuthAvailable) throws FailedVerificationException {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (isAuthAvailable || permissionsManager.hasPermissionOffline(name, PlayerStatePermission.BYPASS_ANTIBOT)) {
|
||||
return;
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class OnJoinVerifier implements Reloadable {
|
||||
* further), false if the player is not refused
|
||||
*/
|
||||
public boolean refusePlayerForFullServer(PlayerLoginEvent event) {
|
||||
ThreadSafetyUtils.requireSync();
|
||||
ThreadSafety.requireSync();
|
||||
final Player player = event.getPlayer();
|
||||
if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL) {
|
||||
// Server is not full, no need to do anything
|
||||
@ -165,7 +165,7 @@ public class OnJoinVerifier implements Reloadable {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public void checkNameCasing(String connectingName, PlayerAuth auth) throws FailedVerificationException {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (auth != null && settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)) {
|
||||
String realName = auth.getRealName(); // might be null or "Player"
|
||||
|
||||
@ -188,7 +188,7 @@ public class OnJoinVerifier implements Reloadable {
|
||||
@ShouldBeAsync
|
||||
public void checkPlayerCountry(String name, String address,
|
||||
boolean isAuthAvailable) throws FailedVerificationException {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if ((!isAuthAvailable || settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED))
|
||||
&& settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)
|
||||
&& !permissionsManager.hasPermissionOffline(name, PlayerStatePermission.BYPASS_COUNTRY_CHECK)
|
||||
@ -205,7 +205,7 @@ public class OnJoinVerifier implements Reloadable {
|
||||
* @throws FailedVerificationException if the verification fails
|
||||
*/
|
||||
public void checkSingleSession(String name) throws FailedVerificationException {
|
||||
ThreadSafetyUtils.requireSync();
|
||||
ThreadSafety.requireSync();
|
||||
if (!settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) {
|
||||
return;
|
||||
}
|
||||
@ -224,7 +224,7 @@ public class OnJoinVerifier implements Reloadable {
|
||||
* @return the player to kick, or null if none applicable
|
||||
*/
|
||||
private Player generateKickPlayer(Collection<Player> onlinePlayers) {
|
||||
ThreadSafetyUtils.requireSync();
|
||||
ThreadSafety.requireSync();
|
||||
for (Player player : onlinePlayers) {
|
||||
if (!permissionsManager.hasPermission(player, PlayerStatePermission.IS_VIP)) {
|
||||
return player;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.mail;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.MightBeAsync;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
@ -54,7 +54,7 @@ public class EmailService {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public boolean sendPasswordMail(String name, String mailAddress, String newPass) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (!hasAllInformation()) {
|
||||
logger.warning("Cannot perform email registration: not all email settings are complete");
|
||||
return false;
|
||||
@ -96,7 +96,7 @@ public class EmailService {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public boolean sendVerificationMail(String name, String mailAddress, String code) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (!hasAllInformation()) {
|
||||
logger.warning("Cannot send verification email: not all email settings are complete");
|
||||
return false;
|
||||
@ -125,7 +125,7 @@ public class EmailService {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public boolean sendRecoveryCode(String name, String email, String code) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
HtmlEmail htmlEmail;
|
||||
try {
|
||||
htmlEmail = sendMailSsl.initializeMail(email);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme.service;
|
||||
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.MightBeAsync;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.initialization.SettingsDependent;
|
||||
@ -108,7 +108,7 @@ public class AntiBotService implements SettingsDependent {
|
||||
* Transitions the anti bot service from active status back to listening.
|
||||
*/
|
||||
private void stopProtection() {
|
||||
ThreadSafetyUtils.requireSync();
|
||||
ThreadSafety.requireSync();
|
||||
if (antiBotStatus != AntiBotStatus.ACTIVE) {
|
||||
return;
|
||||
}
|
||||
@ -144,7 +144,7 @@ public class AntiBotService implements SettingsDependent {
|
||||
* @param started the new protection status
|
||||
*/
|
||||
public void overrideAntiBotStatus(boolean started) {
|
||||
ThreadSafetyUtils.requireSync();
|
||||
ThreadSafety.requireSync();
|
||||
if (antiBotStatus != AntiBotStatus.DISABLED) {
|
||||
if (started) {
|
||||
startProtection();
|
||||
@ -161,7 +161,7 @@ public class AntiBotService implements SettingsDependent {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public boolean shouldKick() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (antiBotStatus == AntiBotStatus.DISABLED) {
|
||||
return false;
|
||||
} else if (antiBotStatus == AntiBotStatus.ACTIVE) {
|
||||
|
@ -11,7 +11,7 @@ import com.maxmind.db.cache.CHMCache;
|
||||
import com.maxmind.db.model.Country;
|
||||
import com.maxmind.db.model.CountryResponse;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
@ -132,7 +132,7 @@ public class GeoIpService {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
private void updateDatabase() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
logger.info("Downloading GEO IP database, because the old database is older than "
|
||||
+ UPDATE_INTERVAL_DAYS + " days or doesn't exist");
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.service;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.MightBeAsync;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
@ -72,7 +72,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public void createAndSendRecoveryCode(Player player, String email) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (!checkEmailCooldown(player)) {
|
||||
return;
|
||||
}
|
||||
@ -96,7 +96,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public void generateAndSendNewPassword(Player player, String email) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (!checkEmailCooldown(player)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package fr.xephi.authme.task.purge;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.annotation.MightBeAsync;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
@ -58,7 +57,7 @@ public class PurgeExecutor {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
public void executePurge(Collection<OfflinePlayer> players, Collection<String> names) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
// Purge other data
|
||||
purgeFromAuthMe(names);
|
||||
purgeEssentials(players);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.task.purge;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
@ -121,7 +121,7 @@ public class PurgeService {
|
||||
*/
|
||||
@ShouldBeAsync
|
||||
void executePurge(Collection<OfflinePlayer> players, Collection<String> names) {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
purgeExecutor.executePurge(players, names);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.task.purge;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.ThreadSafetyUtils;
|
||||
import fr.xephi.authme.ThreadSafety;
|
||||
import fr.xephi.authme.annotation.ShouldBeAsync;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
@ -61,7 +61,7 @@ class PurgeTask extends BukkitRunnable {
|
||||
@Override
|
||||
@ShouldBeAsync
|
||||
public void run() {
|
||||
ThreadSafetyUtils.shouldBeAsync();
|
||||
ThreadSafety.shouldBeAsync();
|
||||
if (toPurge.isEmpty()) {
|
||||
//everything was removed
|
||||
finish();
|
||||
|
Loading…
Reference in New Issue
Block a user