From b4192c7a88bad111bebbd42d391d6e729c8617d6 Mon Sep 17 00:00:00 2001 From: olamedia Date: Fri, 28 Sep 2012 18:46:42 +0600 Subject: initial --- .../olacraft/events/GameEventDispatcher.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/ru/olamedia/olacraft/events/GameEventDispatcher.java (limited to 'src/ru/olamedia/olacraft/events/GameEventDispatcher.java') 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 listeners = new ArrayList(); + + 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); + } + } +} -- cgit v1.2.3