diff options
author | olamedia <[email protected]> | 2012-09-28 18:46:42 +0600 |
---|---|---|
committer | olamedia <[email protected]> | 2012-09-28 18:46:42 +0600 |
commit | b4192c7a88bad111bebbd42d391d6e729c8617d6 (patch) | |
tree | b05a586dbc60c5427fcc7f3fe01cf2fdcb970272 /src/ru/olamedia/olacraft/events/GameEventDispatcher.java |
initial
Diffstat (limited to 'src/ru/olamedia/olacraft/events/GameEventDispatcher.java')
-rw-r--r-- | src/ru/olamedia/olacraft/events/GameEventDispatcher.java | 22 |
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); + } + } +} |