package ru.gravit.utils; import java.util.HashSet; import java.util.Set; public class HookSet { public Set> list = new HashSet<>(); @FunctionalInterface public interface Hook { boolean hook(R context) throws HookException; } public void registerHook(Hook hook) { list.add(hook); } public boolean unregisterHook(Hook hook) { return list.remove(hook); } public boolean hook(R context) throws HookException { for(Hook hook : list) { if(hook.hook(context)) return true; } return false; } }