aboutsummaryrefslogtreecommitdiffstats
path: root/src/ru/olamedia/olacraft/events/GameEventDispatcher.java
blob: 7cae41a5526fc35275578153c64b68fd0d9a7cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
		}
	}
}