/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package nz.co.lolnet.james137137.FactionChat;

import org.bukkit.entity.Player;

/**
 *
 * @author James
 */
class AuthMeAPI {

    static boolean enable;

    public AuthMeAPI(boolean aThis) {
        enable = aThis;
    }

    private static boolean isLoggedIn(Player player) {
        if (enable) {
            boolean result;
            try {
                System.out.println("FactionChat debug: Authenticated: " + fr.xephi.authme.api.NewAPI.getInstance().isAuthenticated(player));
                System.out.println("FactionChat debug: Registered: " + fr.xephi.authme.api.NewAPI.getInstance().isRegistered(player.getName()));
                result = fr.xephi.authme.api.NewAPI.getInstance().isAuthenticated(player) && fr.xephi.authme.api.NewAPI.getInstance().isRegistered(player.getName());
            } catch (Exception e) {
                result = fr.xephi.authme.api.API.isAuthenticated(player) && fr.xephi.authme.api.API.isRegistered(player.getName());
            }
            return result;
        }
        return true;
    }

    public static boolean isAllowToChat(Player player) {
        System.out.println("FactionChat debug: " + player.getDisplayName());
        if (!enable) {
            System.out.println("FactionChat debug: AuthMeAPI Enabled = false");
            return true;
        }
        boolean result = isLoggedIn(player);
        System.out.println("FactionChat debug: AuthMeAPI isLoggedIn = " + result);
        System.out.println("FactionChat debug End: " + player.getDisplayName());
        return result;
    }
}

@@ -521,32 +521,40 @@
   boolean result
+ = false
 ;%0D%0A            t
@@ -563,296 +563,8 @@
  %7B%0D%0A
-                System.out.println(%22FactionChat debug: Authenticated: %22 + fr.xephi.authme.api.NewAPI.getInstance().isAuthenticated(player));%0D%0A                System.out.println(%22FactionChat debug: Registered: %22 + fr.xephi.authme.api.NewAPI.getInstance().isRegistered(player.getName()));%0D%0A
     
@@ -975,24 +975,28 @@
 ue;%0D%0A    %7D%0D%0A
+    
 %0D%0A    public
@@ -1055,453 +1055,94 @@
     
-System.out.println(%22FactionChat debug: %22 + player.getDisplayName());%0D%0A        if (!enable) %7B%0D%0A            System.out.println(%22FactionChat debug: AuthMeAPI Enabled = false%22);%0D%0A            return true;%0D%0A        %7D%0D%0A        boolean result = isLoggedIn(player);%0D%0A        System.out.println(%22FactionChat debug: AuthMeAPI isLoggedIn = %22 + result);%0D%0A        System.out.println(%22FactionChat debug End: %22 + player.getDisplayName());%0D%0A        return result
+if (!enable) %7B%0D%0A            return true;%0D%0A        %7D%0D%0A        return isLoggedIn(player)
 ;%0D%0A 

Revert "Added some debug message for FactionChat/issues/12"