Ignore registration of a object that is already registered. Preventing duplicate callback invocations. Thanks King_Lemming for pointing this out.

This commit is contained in:
LexManos 2013-06-02 21:44:34 -07:00
parent 0e571eeb19
commit cea0edfdb1

View file

@ -24,6 +24,11 @@ public class EventBus
public void register(Object target) public void register(Object target)
{ {
if (listeners.containsKey(target))
{
return;
}
Set<? extends Class<?>> supers = TypeToken.of(target.getClass()).getTypes().rawTypes(); Set<? extends Class<?>> supers = TypeToken.of(target.getClass()).getTypes().rawTypes();
for (Method method : target.getClass().getMethods()) for (Method method : target.getClass().getMethods())
{ {