mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-29 18:27:36 +02:00
@ -42,6 +42,7 @@ public class AuthMeHook implements AuthPlugin<Player>, Listener {
|
||||
@Override
|
||||
public boolean forceLogin(Player player) {
|
||||
if (AuthMeApi.getInstance().isAuthenticated(player)) {
|
||||
plugin.getLog().warn(ALREADY_AUTHENTICATED, player);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.games647.fastlogin.bukkit.hook;
|
||||
|
||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
|
||||
|
||||
import io.github.lucaseasedup.logit.CancelledState;
|
||||
@ -22,11 +23,21 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class LogItHook implements AuthPlugin<Player> {
|
||||
|
||||
private final FastLoginBukkit plugin;
|
||||
|
||||
public LogItHook(FastLoginBukkit plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean forceLogin(Player player) {
|
||||
SessionManager sessionManager = LogItCore.getInstance().getSessionManager();
|
||||
return sessionManager.isSessionAlive(player)
|
||||
|| sessionManager.startSession(player) == CancelledState.NOT_CANCELLED;
|
||||
if (sessionManager.isSessionAlive(player)) {
|
||||
plugin.getLog().warn(ALREADY_AUTHENTICATED, player);
|
||||
return false;
|
||||
}
|
||||
|
||||
return sessionManager.startSession(player) == CancelledState.NOT_CANCELLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,11 @@ public class LoginSecurityHook implements AuthPlugin<Player> {
|
||||
@Override
|
||||
public boolean forceLogin(Player player) {
|
||||
PlayerSession session = LoginSecurity.getSessionManager().getPlayerSession(player);
|
||||
if (session.isAuthorized()) {
|
||||
plugin.getLog().warn(ALREADY_AUTHENTICATED, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
return session.isAuthorized()
|
||||
|| session.performAction(new LoginAction(AuthService.PLUGIN, plugin)).isSuccess();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class UltraAuthHook implements AuthPlugin<Player> {
|
||||
//not thread-safe
|
||||
Future<Boolean> future = Bukkit.getScheduler().callSyncMethod(plugin, () -> {
|
||||
if (UltraAuthAPI.isAuthenticated(player)) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
UltraAuthAPI.authenticatedPlayer(player);
|
||||
|
@ -35,7 +35,8 @@ public class xAuthHook implements AuthPlugin<Player> {
|
||||
xAuthPlayer xAuthPlayer = xAuthPlugin.getPlayerManager().getPlayer(player);
|
||||
if (xAuthPlayer != null) {
|
||||
if (xAuthPlayer.isAuthenticated()) {
|
||||
return true;
|
||||
plugin.getLog().warn("Player {} is already authenticated", player);
|
||||
return false;
|
||||
}
|
||||
|
||||
//we checked that the player is premium (paid account)
|
||||
|
@ -8,6 +8,8 @@ package com.github.games647.fastlogin.core.hooks;
|
||||
*/
|
||||
public interface AuthPlugin<P> {
|
||||
|
||||
String ALREADY_AUTHENTICATED = "Player {} is already authenticated. Cancelling force login.";
|
||||
|
||||
/**
|
||||
* Login the premium (paid account) player after the player joined successfully the server.
|
||||
*
|
||||
|
Reference in New Issue
Block a user