aboutsummaryrefslogtreecommitdiffstats
path: root/src/ru/olamedia/olacraft/events/GameEventDispatcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ru/olamedia/olacraft/events/GameEventDispatcher.java')
-rw-r--r--src/ru/olamedia/olacraft/events/GameEventDispatcher.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ru/olamedia/olacraft/events/GameEventDispatcher.java b/src/ru/olamedia/olacraft/events/GameEventDispatcher.java
new file mode 100644
index 0000000..7cae41a
--- /dev/null
+++ b/src/ru/olamedia/olacraft/events/GameEventDispatcher.java
@@ -0,0 +1,22 @@
+package ru.olamedia.olacraft.events;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GameEventDispatcher {
+ private static List<GameEventListener> listeners = new ArrayList<GameEventListener>();
+
+ public static void attach(GameEventListener listener) {
+ listeners.add(listener);
+ }
+
+ public static void detach(GameEventListener listener) {
+ listeners.remove(listener);
+ }
+
+ public static void dispatch(GameEvent e) {
+ for (GameEventListener l : listeners) {
+ l.on(e);
+ }
+ }
+}