From de47895e02cabab397d40f6ce3b7bff7a75e71dd Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 11 Sep 2012 17:49:21 -0700 Subject: [PATCH] Fix potential issue with custom events where the constructor is not visible from the EventBus class, Should never arise but meh. --- common/net/minecraftforge/event/EventBus.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/net/minecraftforge/event/EventBus.java b/common/net/minecraftforge/event/EventBus.java index a516f37fc..cce20e92f 100644 --- a/common/net/minecraftforge/event/EventBus.java +++ b/common/net/minecraftforge/event/EventBus.java @@ -1,5 +1,6 @@ package net.minecraftforge.event; +import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Set; @@ -64,11 +65,13 @@ public class EventBus private void register(Class eventType, Object target, Method method) { try - { - Event event = (Event)eventType.newInstance(); + { + Constructor ctr = eventType.getConstructor(); + ctr.setAccessible(true); + Event event = (Event)ctr.newInstance(); ASMEventHandler listener = new ASMEventHandler(target, method); event.getListenerList().register(busID, listener.getPriority(), listener); - + ArrayList others = listeners.get(target); if (others == null) {