mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 17:47:38 +01:00
Fix test / use new DataSource method / add space before keywords
This commit is contained in:
parent
273c318e96
commit
c7ba06e2b9
@ -270,10 +270,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
@Override
|
||||
public void refreshCache(String playerName) {
|
||||
if (cachedAuths.getIfPresent(playerName) == null) {
|
||||
return;
|
||||
if (cachedAuths.getIfPresent(playerName) != null) {
|
||||
cachedAuths.refresh(playerName);
|
||||
}
|
||||
cachedAuths.refresh(playerName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,19 +4,18 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.data.VerificationCodeManager;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.CacheDataSource;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.process.SyncProcessManager;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.SessionService;
|
||||
import fr.xephi.authme.service.ValidationService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeService;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import fr.xephi.authme.service.ValidationService;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -109,9 +108,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
}
|
||||
|
||||
// remove player from cache
|
||||
if (database instanceof CacheDataSource) {
|
||||
((CacheDataSource) database).getCachedAuths().invalidate(name);
|
||||
}
|
||||
database.invalidateCache(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.datasource.CacheDataSource;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.initialization.SettingsDependent;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
@ -22,13 +21,13 @@ import javax.inject.Inject;
|
||||
*/
|
||||
public class BungeeService implements SettingsDependent, PluginMessageListener {
|
||||
|
||||
private AuthMe plugin;
|
||||
private BukkitService service;
|
||||
private final AuthMe plugin;
|
||||
private final BukkitService service;
|
||||
private final DataSource dataSource;
|
||||
|
||||
private boolean isEnabled;
|
||||
private String destinationServerOnLogin;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
/*
|
||||
* Constructor.
|
||||
@ -59,7 +58,7 @@ public class BungeeService implements SettingsDependent, PluginMessageListener {
|
||||
|
||||
private void sendBungeecordMessage(String... data) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
for(String element : data) {
|
||||
for (String element : data) {
|
||||
out.writeUTF(element);
|
||||
}
|
||||
service.sendPluginMessage("BungeeCord", out.toByteArray());
|
||||
@ -81,7 +80,7 @@ public class BungeeService implements SettingsDependent, PluginMessageListener {
|
||||
}
|
||||
|
||||
public void sendAuthMeBungeecordMessage(String type, String playerName) {
|
||||
if(!isEnabled) {
|
||||
if (isEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,13 +89,13 @@ public class BungeeService implements SettingsDependent, PluginMessageListener {
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
|
||||
if(!isEnabled) {
|
||||
if (!isEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(data);
|
||||
String subchannel = in.readUTF();
|
||||
if(!"Authme".equals(subchannel)) {
|
||||
if (!"Authme".equals(subchannel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -113,7 +112,7 @@ public class BungeeService implements SettingsDependent, PluginMessageListener {
|
||||
dataSource.refreshCache(name);
|
||||
break;
|
||||
default:
|
||||
ConsoleLogger.debug("Received unsupported bungeecord message type! (" + type + ")");
|
||||
ConsoleLogger.debug("Received unsupported bungeecord message type! ({0})", type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractR
|
||||
private static List<Method> getDataSourceMethods() {
|
||||
List<Method> publicMethods = new ArrayList<>();
|
||||
for (Method method : DataSource.class.getDeclaredMethods()) {
|
||||
if (!IGNORED_METHODS.contains(method.getName())) {
|
||||
if (!IGNORED_METHODS.contains(method.getName()) && !method.isSynthetic()) {
|
||||
publicMethods.add(method);
|
||||
}
|
||||
}
|
||||
|
@ -117,12 +117,9 @@ public final class ListenerConsistencyTest {
|
||||
}
|
||||
|
||||
private static boolean isTestableMethod(Method method) {
|
||||
// Exclude any methods with "$" in it: jacoco creates a "$jacocoInit" method we want to ignore, and
|
||||
// methods like "access$000" are created by the compiler when a private member is being accessed by an inner
|
||||
// class, which is not of interest for us
|
||||
// Also exclude getters
|
||||
// Exclude getters and synthetic methods
|
||||
String methodName = method.getName();
|
||||
if (Modifier.isPrivate(method.getModifiers()) || methodName.contains("$") || methodName.startsWith("get") || methodName.startsWith("is")) {
|
||||
if (Modifier.isPrivate(method.getModifiers()) || method.isSynthetic() || methodName.startsWith("get") || methodName.startsWith("is")) {
|
||||
return false;
|
||||
}
|
||||
// Skip reload() method (implementation of Reloadable interface)
|
||||
|
Loading…
Reference in New Issue
Block a user