/** * Notify mechanics about a changed block that they are watching. * * @param event */ public void notify(BlockEvent event) { Set<PersistentMechanic> pms = watchBlocks.get(BukkitUtil.toWorldVector(event.getBlock())); if (pms == null) return; for (PersistentMechanic m : pms) { m.onWatchBlockNotification(event); } }
/** * De-registers a mechanic. * * @param m */ public void deregister(PersistentMechanic m) { for (BlockWorldVector p : m.getWatchedPositions()) { Set<PersistentMechanic> watchBlock = watchBlocks.get(p); if (p != null && watchBlock != null) { watchBlock.remove(m); } } }
/** * Register a mechanic. * * @param m */ public void register(PersistentMechanic m) { for (BlockWorldVector p : m.getWatchedPositions()) { Set<PersistentMechanic> set = watchBlocks.get(p); if (set == null) { set = new HashSet<PersistentMechanic>(4); watchBlocks.put(p, set); } set.add(m); } }