/**
 *
 * EventoZero - Advanced event factory and executor for Bukkit and Spigot.
 * Copyright � 2016 BlackHub OS and contributors.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package br.com.blackhubos.eventozero.factory;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.NullArgumentException;
import org.bukkit.entity.Player;

public class EventHandler {
	
	private final Set<Event> events;
	
	public EventHandler(){
		this.events = new HashSet<>();
	}
	
	public Event getEventByPlayer(final Player player){
		for(Event e : getEvents()){
			if(e.hasPlayerJoined(player)){
				return e;
			}
		}
		return null;
	}
	
	public Set<Event> getEvents(){
		return this.events;
		
	}
	
	public void loadEvent(final Event event){
		if(event != null)
			throw new NullArgumentException("Event is null");
		events.add(event);
	}

}

@@ -991,19 +991,21 @@
 ndler %7B%0A
-%09%0A%09
+%0A    
 private 
@@ -1029,19 +1029,21 @@
 events;%0A
-%09%0A%09
+%0A    
 public E
@@ -1055,20 +1055,27 @@
 andler()
+ 
 %7B%0A
-%09%09
+        
 this.eve
@@ -1097,22 +1097,245 @@
 et%3C%3E();%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    public Event getEventByName(final String name) %7B%0A        for (Event e : getEvents()) %7B%0A            if (e.getEventName().equals(name)) %7B%0A                return e;%0A            %7D%0A        %7D%0A        return null;%0A    %7D%0A%0A    
 public E
@@ -1380,15 +1380,23 @@
 yer)
+ 
 %7B%0A
-%09%09
+        
 for
+ 
 (Eve
@@ -1418,15 +1418,26 @@
 s())
+ 
 %7B%0A
-%09%09%09
+            
 if
+ 
 (e.h
@@ -1463,35 +1463,69 @@
 er))
+ 
 %7B%0A
-%09%09%09%09return e;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09
+                return e;%0A            %7D%0A        %7D%0A        
 retu
@@ -1533,22 +1533,27 @@
 n null;%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 public S
@@ -1573,20 +1573,27 @@
 Events()
+ 
 %7B%0A
-%09%09
+        
 return t
@@ -1608,17 +1608,20 @@
 ts;%0A
-%09%09%0A%09%7D%0A%09%0A%09
+%0A    %7D%0A%0A    
 publ
@@ -1660,14 +1660,22 @@
 ent)
+ 
 %7B%0A
-%09%09
+        
 if
+ 
 (eve
@@ -1689,12 +1689,23 @@
 ull)
-%0A%09%09%09
+ %7B%0A            
 thro
@@ -1754,10 +1754,26 @@
 %22);%0A
-%09%09
+        %7D%0A        
 even
@@ -1791,9 +1791,12 @@
 t);%0A
-%09
+    
 %7D%0A%0A%7D

O que foi alterado: Adicionado o método getEventByName(String name); O que foi corrigido: NADA PARA SER CORRIGIDO