1 18 19 package alt.jiapi.event; 20 21 import java.lang.reflect.Method ; 22 import alt.jiapi.instrumentor.Hook; 23 24 31 abstract class EventHook implements Hook { 32 private Object instance; 33 private Method hookMethod; 34 35 36 public EventHook(EventProducer ep) { 37 this.instance = ep; 38 } 39 40 public Method getHookMethod() { 41 if (hookMethod == null) { 42 Class [] params = getMethodParameters(); 43 try { 44 this.hookMethod = 45 instance.getClass().getMethod(getMethodName(), params); 46 } 47 catch (Exception e) { 48 e.printStackTrace(); 50 throw new RuntimeException (e.toString()); 51 } 52 } 53 54 return hookMethod; 55 } 56 57 public Object getInstance() { 58 return instance; 59 } 60 61 protected Class [] getMethodParameters() { 62 return new Class [] {Object .class, String .class}; 63 } 64 65 68 public abstract String getMethodName(); 69 } 70 71 72 73 | Popular Tags |