package com.applenick.Wait;

import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.java.JavaPlugin;

/************************************************
			 Created By AppleNick
Copyright © 2016 , AppleNick, All rights reserved.
			http://applenick.com
 *************************************************/
public class Wait extends JavaPlugin implements Listener {
	
	private boolean canLogin = false; // If players can login
	private boolean waitForAll = false; // If the server should wait for all plugins to load
	private String waitForPlugin = "none"; //The name of a specfic plugin to wait for
	private String kickMessage;// The message sent when a player tries to login
	
	@Override
	public void onEnable(){
		//Save Config
		this.saveDefaultConfig();
		
		//Check if blocking All
		waitForAll = this.getConfig().getString("wait-for").equalsIgnoreCase("waitForAll");
		
		//Get name of single plugin if in single mode
		if(!(waitForAll)){
			waitForPlugin = this.getConfig().getString("wait-for");
		}	
		
		//Get the kick message
		kickMessage = ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("kick-message"));
				
		//Register Listener
		this.getServer().getPluginManager().registerEvents(this, this);
		
		if(waitForAll){
			//Schedule the server to allow login after everything is loaded.
			this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
				public void run() {
					canLogin = true;
				}
			}, 0L);
		}
	}
	
	@EventHandler
	public void onPluginEnable(PluginEnableEvent event){
		//Enable logins after the specfic plugin is enabled.
		if(!(waitForAll)){
			if(event.getPlugin().getName().equalsIgnoreCase(waitForPlugin)){
				canLogin = true;
			}
		}
	}
	
	
	@EventHandler
	public void onPlayerJoin(PlayerJoinEvent event){
		if(!(canLogin)){
			event.getPlayer().kickPlayer(kickMessage);
		}else{
			return;
		}
	}
	
}

@@ -527,16 +527,118 @@
 ner %7B%0A%09%0A
+%09private String PREFIX = ChatColor.GRAY + %22%5B%22 + ChatColor.DARK_RED + %22Wait%22 + ChatColor.GRAY + %22%5D%22;%0A%09%0A
 %09private
@@ -834,24 +834,25 @@
 me of a spec
+i
 fic plugin t
@@ -1718,14 +1718,115 @@
 ue;%0A
+%09%09%09%09%09getServer().getConsoleSender().sendMessage(PREFIX + ChatColor.GREEN + %22Players can now login%22);%0A
 %09%09%09%09%7D%0A
-
 %09%09%09%7D
@@ -1942,16 +1942,17 @@
 the spec
+i
 fic plug
@@ -2055,16 +2055,16 @@
 ugin))%7B%0A
-
 %09%09%09%09canL
@@ -2076,16 +2076,116 @@
 = true;%0A
+%09%09%09%09getServer().getConsoleSender().sendMessage(PREFIX + ChatColor.GREEN + %22Players can now login%22);%0A
 %09%09%09%7D%0A%09%09%7D

Add a message when logins are enabled