package nz.co.lolnet.james137137.FactionChat.API;

import java.util.HashMap;
import org.bukkit.entity.Player;

/**
 *
 * @author James
 */
public class StaffJoinFeature {

    public static HashMap<String, String> StaffFactionsDirect = new HashMap<>(); // StafffName, targetName

    public static boolean isRedirected(Object player) {
        if (player instanceof String) {
            return StaffFactionsDirect.containsKey((String) player);
        } else if (player instanceof Player) {
            return StaffFactionsDirect.containsKey(((Player) (player)).getName());
        }
        return false;
    }

    public static void clearPlayer(Object player) {
        if (player instanceof String) {
            StaffFactionsDirect.remove((String) player);
        } else if (player instanceof Player) {
            StaffFactionsDirect.remove(((Player) (player)).getName());
        }
    }
    
    public static String getTarget(Object player)
    {
        if (!isRedirected(player))
        {
            return (String) player;
        }
        if (player instanceof String) {
            String playerName = StaffFactionsDirect.get((String) player);
            return playerName;
        } else if (player instanceof Player) {
            String playerName = StaffFactionsDirect.get(((Player) (player)).getName());
            return playerName;
        }
        return null;
    }
    
    public static void setTarget(Object player, String target)
    {
        if (player instanceof String) {
            StaffFactionsDirect.put((String) player,target);
        } else if (player instanceof Player) {
            StaffFactionsDirect.put(((Player) (player)).getName(),target);
        }
    }
}

@@ -73,16 +73,101 @@
 shMap;%0D%0A
+import nz.co.lolnet.james137137.FactionChat.FactionChat;%0D%0Aimport org.bukkit.Bukkit;%0D%0A
 import o
@@ -1028,22 +1028,22 @@
  static 
-String
+Object
  getTarg
@@ -1137,17 +1137,8 @@
 turn
- (String)
  pla
@@ -1282,33 +1282,281 @@
         
-return playerName
+System.out.println(playerName);%0D%0A            Player player1 = Bukkit.getServer().getPlayer(playerName);%0D%0A            if (player1 == null)%0D%0A            %7B%0D%0A                clearPlayer(player);%0D%0A                return player;%0D%0A            %7D%0D%0A            return player1
 ;%0D%0A     
@@ -1695,31 +1695,115 @@
             
-return 
+System.out.println(playerName);%0D%0A            Player player1 = Bukkit.getServer().getPlayer(
 playerName;%0D
@@ -1800,16 +1800,17 @@
 ayerName
+)
 ;%0D%0A     
@@ -1816,30 +1816,195 @@
     
+   
-%7D%0D%0A        return null
+ if (player1 == null)%0D%0A            %7B%0D%0A                clearPlayer(player);%0D%0A                return player;%0D%0A            %7D%0D%0A            return player1;%0D%0A        %7D%0D%0A        return player
 ;%0D%0A 
@@ -2330,12 +2330,330 @@
 %0D%0A    %7D%0D
+%0A%0D%0A    private static Player getPlayer(String playerName) %7B%0D%0A        for (Player player : FactionChat.plugin.getServer().getOnlinePlayers())%0D%0A        %7B%0D%0A            if (player.getName().equalsIgnoreCase(playerName))%0D%0A            %7B%0D%0A                return player;%0D%0A            %7D%0D%0A        %7D%0D%0A        return null;%0D%0A    %7D%0D
 %0A%7D%0D%0A

Revert "reverted back to better method"