package com.github.games647.fastlogin.bukkit.hooks;

import com.github.games647.fastlogin.core.hooks.AuthPlugin;

import fr.xephi.authme.api.NewAPI;

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> {

    @Override
    public boolean forceLogin(Player player) {
        //skips registration and login
        if (NewAPI.getInstance().isAuthenticated(player)) {
            return false;
        } else {
            NewAPI.getInstance().forceLogin(player);
        }

        return true;
    }

    @Override
    public boolean isRegistered(String playerName) throws Exception {
        return NewAPI.getInstance().isRegistered(playerName);
    }

    @Override
    public boolean forceRegister(Player player, String password) {
        //this automatically registers the player too
        NewAPI.getInstance().forceRegister(player, password);
        return true;
    }
}

@@ -141,16 +141,57 @@
 .NewAPI;
+%0Aimport fr.xephi.authme.api.v3.AuthMeApi;
 %0A%0Aimport
@@ -494,16 +494,354 @@
 yer%3E %7B%0A%0A
+    private final boolean v3APIAvailable;%0A%0A    public AuthMeHook() %7B%0A        boolean apiAvailable = true;%0A        try %7B%0A            Class.forName(%22fr.xephi.authme.api.v3.AuthMeApi%22);%0A        %7D catch (ClassNotFoundException classNotFoundEx) %7B%0A            apiAvailable = false;%0A        %7D%0A%0A        this.v3APIAvailable = apiAvailable;%0A    %7D%0A%0A
     @Ove
@@ -889,24 +889,58 @@
 r player) %7B%0A
+        if (v3APIAvailable) %7B%0A    
         //sk
@@ -966,16 +966,272 @@
 d login%0A
+            if (AuthMeApi.getInstance().isAuthenticated(player)) %7B%0A                return false;%0A            %7D else %7B%0A                AuthMeApi.getInstance().forceLogin(player);%0A            %7D%0A        %7D else %7B%0A            //skips registration and login%0A    
         
@@ -1286,32 +1286,36 @@
 ) %7B%0A            
+    
 return false;%0A  
@@ -1312,32 +1312,36 @@
  false;%0A        
+  
+  
 %7D else %7B%0A       
@@ -1325,32 +1325,36 @@
        %7D else %7B%0A
+    
             NewA
@@ -1382,32 +1382,46 @@
 eLogin(player);%0A
+            %7D%0A
         %7D%0A%0A     
@@ -1527,16 +1527,126 @@
 ption %7B%0A
+        if (v3APIAvailable) %7B%0A            return AuthMeApi.getInstance().isRegistered(playerName);%0A        %7D%0A%0A
         
@@ -1841,16 +1841,136 @@
 yer too%0A
+        if (v3APIAvailable) %7B%0A            AuthMeApi.getInstance().forceRegister(player, password);%0A        %7D else %7B%0A    
         
@@ -2015,32 +2015,43 @@
 yer, password);%0A
+        %7D%0A%0A
         return t

Add support for new authme API