package utility; import java.util.HashSet; import java.util.Set; public class Event { private Set listeners = new HashSet(); public void addListener(Runnable listener) { listeners.add(listener); } public void broadcast() { listeners.forEach(x -> x.run()); } }