Advertisement
Guest User

event

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. package me.aristhena.event;
  2.  
  3. import java.util.Iterator;
  4. import java.lang.reflect.InvocationTargetException;
  5.  
  6. public abstract class Event
  7. {
  8. private boolean cancelled;
  9.  
  10. public Event call() {
  11. this.cancelled = false;
  12. call(this);
  13. return this;
  14. }
  15.  
  16. public boolean isCancelled() {
  17. return this.cancelled;
  18. }
  19.  
  20. public void setCancelled(final boolean state) {
  21. this.cancelled = state;
  22. }
  23.  
  24. private static final void call(final Event event) {
  25. final FlexibleArray<MethodData> dataList = EventManager.get(event.getClass());
  26. if (dataList != null) {
  27. for (final MethodData data : dataList) {
  28. try {
  29. data.target.invoke(data.source, event);
  30. }
  31. catch (IllegalAccessException e2) {
  32. System.out.println("Can't invoke '" + data.target.getName() + "' because it's not accessible.");
  33. }
  34. catch (IllegalArgumentException e3) {
  35. System.out.println("Can't invoke '" + data.target.getName() + "' because the parameter/s don't match.");
  36. }
  37. catch (InvocationTargetException e) {
  38. e.printStackTrace();
  39. }
  40. }
  41. }
  42. }
  43.  
  44. public enum State
  45. {
  46. PRE("PRE", 0),
  47. POST("POST", 1);
  48.  
  49. private State(final String s, final int n) {
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement