Do no print auto login message on authme session reuse (Related #101)

This commit is contained in:
games647
2016-12-23 22:12:29 +01:00
parent f3ac6090f1
commit a430a079c9
3 changed files with 19 additions and 6 deletions

View File

@ -1,18 +1,21 @@
package com.github.games647.fastlogin.bukkit.hooks;
import com.avaje.ebeaninternal.api.ClassUtil;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import fr.xephi.authme.api.API;
import fr.xephi.authme.api.NewAPI;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
/**
* Github: https://github.com/Xephi/AuthMeReloaded/
*
* Project page:
*
* Bukkit: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
*
* Spigot: https://www.spigotmc.org/resources/authme-reloaded.6269/
*/
public class AuthMeHook implements AuthPlugin<Player> {
@ -20,7 +23,15 @@ public class AuthMeHook implements AuthPlugin<Player> {
private final boolean isNewAPIAvailable;
public AuthMeHook() {
this.isNewAPIAvailable = ClassUtil.isPresent("fr.xephi.authme.api.NewAPI");
boolean apiAvailable = false;
try {
Class.forName("fr.xephi.authme.api.NewAPI");
apiAvailable = true;
} catch (ClassNotFoundException ex) {
Logger.getLogger(AuthMeHook.class.getName()).log(Level.SEVERE, null, ex);
}
this.isNewAPIAvailable = apiAvailable;
}
@Override
@ -28,13 +39,15 @@ public class AuthMeHook implements AuthPlugin<Player> {
public boolean forceLogin(Player player) {
//skips registration and login
if (isNewAPIAvailable) {
if (!NewAPI.getInstance().isAuthenticated(player)) {
if (NewAPI.getInstance().isAuthenticated(player)) {
return false;
} else {
NewAPI.getInstance().forceLogin(player);
}
} else if (!API.isAuthenticated(player)) {
API.forceLogin(player);
}
return true;
}

View File

@ -18,6 +18,7 @@ import ultraauth.managers.PlayerManager;
* Project page:
*
* Bukkit: http://dev.bukkit.org/bukkit-plugins/ultraauth-aa/
*
* Spigot: https://www.spigotmc.org/resources/ultraauth.17044/
*/
public class UltraAuthHook implements AuthPlugin<Player> {

View File

@ -52,7 +52,6 @@ public abstract class ForceLoginMangement<P extends C, C, L extends LoginSession
//update only on success to prevent corrupt data
if (playerProfile != null) {
playerProfile.setUuid(session.getUuid());
//save cracked players too
playerProfile.setPremium(true);
storage.save(playerProfile);
}
@ -67,7 +66,7 @@ public abstract class ForceLoginMangement<P extends C, C, L extends LoginSession
storage.save(playerProfile);
}
} catch (Exception ex) {
core.getPlugin().getLogger().log(Level.INFO, "ERROR ON FORCE LOGIN", ex);
core.getPlugin().getLogger().log(Level.WARNING, "ERROR ON FORCE LOGIN", ex);
}
}