package vg.civcraft.mc.namelayer.listeners;

import java.util.UUID;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

import vg.civcraft.mc.namelayer.NameAPI;
import vg.civcraft.mc.namelayer.database.AssociationList;
import vg.civcraft.mc.namelayer.misc.ClassHandler;
import vg.civcraft.mc.namelayer.misc.ProfileInterface;

public class AssociationListener implements Listener{
	
	private AssociationList associations = NameAPI.getAssociationList();
	private ClassHandler ch = ClassHandler.ch;
	private ProfileInterface game;
	
	public AssociationListener(){
		if (ch != null)
			game = ch.getProfileClass();
	}
	
	private String packageName = getClass().getPackage().getName();
	private String version = packageName.substring(packageName.lastIndexOf('.') + 1);
	@EventHandler(priority=EventPriority.LOWEST)
	public void OnPlayerLogin(PlayerJoinEvent event)
	{
		String playername = event.getPlayer().getName();
		UUID uuid = event.getPlayer().getUniqueId();
		associations.addPlayer(playername, uuid);
		if (game != null)
			game.setPlayerProfle(event.getPlayer());
		event.setJoinMessage(ChatColor.YELLOW + NameAPI.getCurrentName(uuid) + " joined the game");
	}
}

@@ -62,16 +62,42 @@
 .UUID;%0A%0A
+import org.bukkit.Bukkit;%0A
 import o
@@ -117,16 +117,16 @@
 tColor;%0A
-
 import o
@@ -318,16 +318,65 @@
 ameAPI;%0A
+import vg.civcraft.mc.namelayer.NameLayerPlugin;%0A
 import v
@@ -629,39 +629,8 @@
 ions
- = NameAPI.getAssociationList()
 ;%0A%09p
@@ -750,24 +750,24 @@
 ch != null)%0A
-
 %09%09%09game = ch
@@ -786,16 +786,205 @@
 lass();%0A
+%09%09Bukkit.getScheduler().runTaskLater(NameLayerPlugin.getInstance(), new Runnable()%7B%0A%0A%09%09%09@Override%0A%09%09%09public void run() %7B%0A%09%09%09%09associations =  NameAPI.getAssociationList();%0A%09%09%09%7D%0A%09%09%09%0A%09%09%7D, 1);%0A
 %09%7D%0A%09%0A%09pr

Fix issue with associationListener