public boolean handleClick(Player p, Point clickPoint) { Point mousePos = new Point(this.panelToMapX(clickPoint.x), this.panelToMapY(clickPoint.y)); Monster monster = null; try { for (String key : monsters.keySet()) { monster = (Monster) monsters.get(key); if (monster != null) { if (monster.isInside(mousePos) && !monster.getIsHiding()) { if (selectedMob != monster) { SoundClip cl = new SoundClip("Misc/Click"); selectedMob = monster; } return true; } } } } catch (ConcurrentModificationException concEx) { // another thread was trying to modify monsters while iterating // we'll continue and the new item can be grabbed on the next update } return false; }